Merge lp:~osomon/oxide/icon into lp:~oxide-developers/oxide/oxide.trunk

Proposed by Olivier Tilloy
Status: Merged
Merged at revision: 578
Proposed branch: lp:~osomon/oxide/icon
Merge into: lp:~oxide-developers/oxide/oxide.trunk
Diff against target: 220 lines (+82/-1)
10 files modified
qt/core/browser/oxide_qt_web_view.cc (+4/-0)
qt/core/browser/oxide_qt_web_view.h (+1/-0)
qt/core/glue/oxide_qt_web_view_adapter.h (+1/-0)
qt/quick/api/oxideqquickwebview.cc (+15/-0)
qt/quick/api/oxideqquickwebview_p.h (+4/-0)
qt/quick/api/oxideqquickwebview_p_p.h (+3/-1)
qt/tests/qmltests/api/tst_WebView_icon.html (+5/-0)
qt/tests/qmltests/api/tst_WebView_icon.qml (+32/-0)
shared/browser/oxide_web_view.cc (+13/-0)
shared/browser/oxide_web_view.h (+4/-0)
To merge this branch: bzr merge lp:~osomon/oxide/icon
Reviewer Review Type Date Requested Status
Chris Coulson Approve
Review via email: mp+203727@code.launchpad.net

Commit message

Add an 'icon' property to the QML WebView.

To post a comment you must log in.
lp:~osomon/oxide/icon updated
323. By Olivier Tilloy

Merged the latest changes from trunk and resolve conflicts.

324. By Olivier Tilloy

Merged the latest changes from trunk and resolve conflicts.

325. By Olivier Tilloy

Merged the latest changes from trunk and resolve conflicts.

326. By Olivier Tilloy

Merged the latest changes from trunk and resolve conflicts.

327. By Olivier Tilloy

Re-use empty HTML page.

328. By Olivier Tilloy

Merge the latest changes from trunk and resolve a couple of conflicts.

329. By Olivier Tilloy

Merge the latest changes from trunk and resolve a conflict.

330. By Olivier Tilloy

Updated to chromium API changes.

Revision history for this message
Olivier Tilloy (osomon) wrote :

I had a quick look into adding an icon attribute to the navigation history entries, as suggested by Chris for this branch to be feature-complete.

It turns out the navigation controller doesn’t store favicon information by default, it’s up to the application to set it. Chrome has a FaviconService class that serves this purposes, which itself talks to a HistoryService instance. Implementing something similar in oxide would involve quite some new code, and I’m not sure where it would belong.

How about doing it in two steps, this branch first (as it’s required for feature parity with QtWebKit/QtWebEngine), and favicons for navigation history later on?

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Thanks, this is fine to commit as it is then. Would you mind opening a bug report for adding an icon property to the navigation entries?

Thanks!

review: Approve
Revision history for this message
Olivier Tilloy (osomon) wrote :

Thanks. I filed bug #1324818.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qt/core/browser/oxide_qt_web_view.cc'
2--- qt/core/browser/oxide_qt_web_view.cc 2014-05-19 23:47:11 +0000
3+++ qt/core/browser/oxide_qt_web_view.cc 2014-05-28 08:47:28 +0000
4@@ -171,6 +171,10 @@
5 adapter_->TitleChanged();
6 }
7
8+void WebView::OnIconChanged(const GURL& icon) {
9+ adapter_->IconChanged(QUrl(QString::fromStdString(icon.spec())));
10+}
11+
12 void WebView::OnCommandsUpdated() {
13 adapter_->CommandsUpdated();
14 }
15
16=== modified file 'qt/core/browser/oxide_qt_web_view.h'
17--- qt/core/browser/oxide_qt_web_view.h 2014-05-19 13:28:19 +0000
18+++ qt/core/browser/oxide_qt_web_view.h 2014-05-28 08:47:28 +0000
19@@ -69,6 +69,7 @@
20
21 void OnURLChanged() FINAL;
22 void OnTitleChanged() FINAL;
23+ void OnIconChanged(const GURL& icon) FINAL;
24 void OnCommandsUpdated() FINAL;
25
26 void OnLoadProgressChanged(double progress) FINAL;
27
28=== modified file 'qt/core/glue/oxide_qt_web_view_adapter.h'
29--- qt/core/glue/oxide_qt_web_view_adapter.h 2014-05-20 15:36:50 +0000
30+++ qt/core/glue/oxide_qt_web_view_adapter.h 2014-05-28 08:47:28 +0000
31@@ -134,6 +134,7 @@
32
33 virtual void URLChanged() = 0;
34 virtual void TitleChanged() = 0;
35+ virtual void IconChanged(QUrl icon) = 0;
36 virtual void CommandsUpdated() = 0;
37
38 virtual void LoadProgressChanged(double progress) = 0;
39
40=== modified file 'qt/quick/api/oxideqquickwebview.cc'
41--- qt/quick/api/oxideqquickwebview.cc 2014-05-20 15:36:50 +0000
42+++ qt/quick/api/oxideqquickwebview.cc 2014-05-28 08:47:28 +0000
43@@ -148,6 +148,15 @@
44 emit q->titleChanged();
45 }
46
47+void OxideQQuickWebViewPrivate::IconChanged(QUrl icon) {
48+ Q_Q(OxideQQuickWebView);
49+
50+ if (icon != icon_) {
51+ icon_ = icon;
52+ emit q->iconChanged();
53+ }
54+}
55+
56 void OxideQQuickWebViewPrivate::CommandsUpdated() {
57 Q_Q(OxideQQuickWebView);
58
59@@ -496,6 +505,12 @@
60 return d->title();
61 }
62
63+QUrl OxideQQuickWebView::icon() const {
64+ Q_D(const OxideQQuickWebView);
65+
66+ return d->icon_;
67+}
68+
69 bool OxideQQuickWebView::canGoBack() const {
70 Q_D(const OxideQQuickWebView);
71
72
73=== modified file 'qt/quick/api/oxideqquickwebview_p.h'
74--- qt/quick/api/oxideqquickwebview_p.h 2014-05-20 15:36:50 +0000
75+++ qt/quick/api/oxideqquickwebview_p.h 2014-05-28 08:47:28 +0000
76@@ -66,6 +66,7 @@
77
78 Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
79 Q_PROPERTY(QString title READ title NOTIFY titleChanged)
80+ Q_PROPERTY(QUrl icon READ icon NOTIFY iconChanged)
81 Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY navigationHistoryChanged)
82 Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY navigationHistoryChanged)
83 Q_PROPERTY(bool incognito READ incognito WRITE setIncognito NOTIFY incognitoChanged)
84@@ -113,6 +114,8 @@
85
86 QString title() const;
87
88+ QUrl icon() const;
89+
90 bool canGoBack() const;
91 bool canGoForward() const;
92
93@@ -173,6 +176,7 @@
94 Q_SIGNALS:
95 void urlChanged();
96 void titleChanged();
97+ void iconChanged();
98 void navigationHistoryChanged();
99 void incognitoChanged();
100 void loadingChanged(OxideQLoadEvent* loadEvent);
101
102=== modified file 'qt/quick/api/oxideqquickwebview_p_p.h'
103--- qt/quick/api/oxideqquickwebview_p_p.h 2014-05-19 13:26:44 +0000
104+++ qt/quick/api/oxideqquickwebview_p_p.h 2014-05-28 08:47:28 +0000
105@@ -61,6 +61,7 @@
106
107 void URLChanged() Q_DECL_FINAL;
108 void TitleChanged() Q_DECL_FINAL;
109+ void IconChanged(QUrl icon) Q_DECL_FINAL;
110 void CommandsUpdated() Q_DECL_FINAL;
111
112 void LoadProgressChanged(double progress) Q_DECL_FINAL;
113@@ -116,8 +117,9 @@
114 void attachContextSignals(OxideQQuickWebContextPrivate* context);
115 void detachContextSignals(OxideQQuickWebContextPrivate* context);
116
117+ bool constructed_;
118 int load_progress_;
119- bool constructed_;
120+ QUrl icon_;
121 OxideQQuickNavigationHistory navigation_history_;
122 QQmlComponent* popup_menu_;
123 QQmlComponent* alert_dialog_;
124
125=== added file 'qt/tests/qmltests/api/tst_WebView_icon.html'
126--- qt/tests/qmltests/api/tst_WebView_icon.html 1970-01-01 00:00:00 +0000
127+++ qt/tests/qmltests/api/tst_WebView_icon.html 2014-05-28 08:47:28 +0000
128@@ -0,0 +1,5 @@
129+<html>
130+<head>
131+ <link rel="icon" href="icon.ico" />
132+</head>
133+</html>
134
135=== added file 'qt/tests/qmltests/api/tst_WebView_icon.qml'
136--- qt/tests/qmltests/api/tst_WebView_icon.qml 1970-01-01 00:00:00 +0000
137+++ qt/tests/qmltests/api/tst_WebView_icon.qml 2014-05-28 08:47:28 +0000
138@@ -0,0 +1,32 @@
139+import QtQuick 2.0
140+import QtTest 1.0
141+import com.canonical.Oxide.Testing 1.0
142+
143+TestWebView {
144+ id: webView
145+ focus: true
146+ width: 200
147+ height: 200
148+
149+ TestCase {
150+ name: "WebView_icon"
151+ when: windowShown
152+
153+ function test_WebView_icon_data() {
154+ return [
155+ { url: "", icon: "" },
156+ { url: "http://localhost:8080/empty.html", icon: "http://localhost:8080/favicon.ico" },
157+ { url: "http://localhost:8080/tst_WebView_icon.html", icon: "http://localhost:8080/icon.ico" }
158+ ];
159+ }
160+
161+ function test_WebView_icon(data) {
162+ if (data.url) {
163+ webView.url = data.url;
164+ verify(webView.waitForLoadSucceeded(),
165+ "Timed out waiting for a successful load");
166+ }
167+ compare(webView.icon.toString(), data.icon);
168+ }
169+ }
170+}
171
172=== modified file 'shared/browser/oxide_web_view.cc'
173--- shared/browser/oxide_web_view.cc 2014-05-21 16:35:27 +0000
174+++ shared/browser/oxide_web_view.cc 2014-05-28 08:47:28 +0000
175@@ -37,6 +37,7 @@
176 #include "content/public/browser/notification_types.h"
177 #include "content/public/browser/render_view_host.h"
178 #include "content/public/browser/web_contents.h"
179+#include "content/public/common/favicon_url.h"
180 #include "content/public/common/menu_item.h"
181 #include "content/public/common/url_constants.h"
182 #include "net/base/net_errors.h"
183@@ -561,8 +562,20 @@
184 }
185 }
186
187+void WebView::DidUpdateFaviconURL(
188+ const std::vector<content::FaviconURL>& candidates) {
189+ std::vector<content::FaviconURL>::const_iterator it;
190+ for (it = candidates.begin(); it != candidates.end(); ++it) {
191+ if (it->icon_type == content::FaviconURL::FAVICON) {
192+ OnIconChanged(it->icon_url);
193+ return;
194+ }
195+ }
196+}
197+
198 void WebView::OnURLChanged() {}
199 void WebView::OnTitleChanged() {}
200+void WebView::OnIconChanged(const GURL& icon) {}
201 void WebView::OnCommandsUpdated() {}
202
203 void WebView::OnLoadProgressChanged(double progress) {}
204
205=== modified file 'shared/browser/oxide_web_view.h'
206--- shared/browser/oxide_web_view.h 2014-05-20 15:36:50 +0000
207+++ shared/browser/oxide_web_view.h 2014-05-28 08:47:28 +0000
208@@ -293,8 +293,12 @@
209
210 void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) FINAL;
211
212+ void DidUpdateFaviconURL(
213+ const std::vector<content::FaviconURL>& candidates) FINAL;
214+
215 virtual void OnURLChanged();
216 virtual void OnTitleChanged();
217+ virtual void OnIconChanged(const GURL& icon);
218 virtual void OnCommandsUpdated();
219
220 virtual void OnLoadProgressChanged(double progress);

Subscribers

People subscribed via source and target branches