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
=== modified file 'qt/core/browser/oxide_qt_web_view.cc'
--- qt/core/browser/oxide_qt_web_view.cc 2014-05-19 23:47:11 +0000
+++ qt/core/browser/oxide_qt_web_view.cc 2014-05-28 08:47:28 +0000
@@ -171,6 +171,10 @@
171 adapter_->TitleChanged();171 adapter_->TitleChanged();
172}172}
173173
174void WebView::OnIconChanged(const GURL& icon) {
175 adapter_->IconChanged(QUrl(QString::fromStdString(icon.spec())));
176}
177
174void WebView::OnCommandsUpdated() {178void WebView::OnCommandsUpdated() {
175 adapter_->CommandsUpdated();179 adapter_->CommandsUpdated();
176}180}
177181
=== modified file 'qt/core/browser/oxide_qt_web_view.h'
--- qt/core/browser/oxide_qt_web_view.h 2014-05-19 13:28:19 +0000
+++ qt/core/browser/oxide_qt_web_view.h 2014-05-28 08:47:28 +0000
@@ -69,6 +69,7 @@
6969
70 void OnURLChanged() FINAL;70 void OnURLChanged() FINAL;
71 void OnTitleChanged() FINAL;71 void OnTitleChanged() FINAL;
72 void OnIconChanged(const GURL& icon) FINAL;
72 void OnCommandsUpdated() FINAL;73 void OnCommandsUpdated() FINAL;
7374
74 void OnLoadProgressChanged(double progress) FINAL;75 void OnLoadProgressChanged(double progress) FINAL;
7576
=== modified file 'qt/core/glue/oxide_qt_web_view_adapter.h'
--- qt/core/glue/oxide_qt_web_view_adapter.h 2014-05-20 15:36:50 +0000
+++ qt/core/glue/oxide_qt_web_view_adapter.h 2014-05-28 08:47:28 +0000
@@ -134,6 +134,7 @@
134134
135 virtual void URLChanged() = 0;135 virtual void URLChanged() = 0;
136 virtual void TitleChanged() = 0;136 virtual void TitleChanged() = 0;
137 virtual void IconChanged(QUrl icon) = 0;
137 virtual void CommandsUpdated() = 0;138 virtual void CommandsUpdated() = 0;
138139
139 virtual void LoadProgressChanged(double progress) = 0;140 virtual void LoadProgressChanged(double progress) = 0;
140141
=== modified file 'qt/quick/api/oxideqquickwebview.cc'
--- qt/quick/api/oxideqquickwebview.cc 2014-05-20 15:36:50 +0000
+++ qt/quick/api/oxideqquickwebview.cc 2014-05-28 08:47:28 +0000
@@ -148,6 +148,15 @@
148 emit q->titleChanged();148 emit q->titleChanged();
149}149}
150150
151void OxideQQuickWebViewPrivate::IconChanged(QUrl icon) {
152 Q_Q(OxideQQuickWebView);
153
154 if (icon != icon_) {
155 icon_ = icon;
156 emit q->iconChanged();
157 }
158}
159
151void OxideQQuickWebViewPrivate::CommandsUpdated() {160void OxideQQuickWebViewPrivate::CommandsUpdated() {
152 Q_Q(OxideQQuickWebView);161 Q_Q(OxideQQuickWebView);
153162
@@ -496,6 +505,12 @@
496 return d->title();505 return d->title();
497}506}
498507
508QUrl OxideQQuickWebView::icon() const {
509 Q_D(const OxideQQuickWebView);
510
511 return d->icon_;
512}
513
499bool OxideQQuickWebView::canGoBack() const {514bool OxideQQuickWebView::canGoBack() const {
500 Q_D(const OxideQQuickWebView);515 Q_D(const OxideQQuickWebView);
501516
502517
=== modified file 'qt/quick/api/oxideqquickwebview_p.h'
--- qt/quick/api/oxideqquickwebview_p.h 2014-05-20 15:36:50 +0000
+++ qt/quick/api/oxideqquickwebview_p.h 2014-05-28 08:47:28 +0000
@@ -66,6 +66,7 @@
6666
67 Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)67 Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
68 Q_PROPERTY(QString title READ title NOTIFY titleChanged)68 Q_PROPERTY(QString title READ title NOTIFY titleChanged)
69 Q_PROPERTY(QUrl icon READ icon NOTIFY iconChanged)
69 Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY navigationHistoryChanged)70 Q_PROPERTY(bool canGoBack READ canGoBack NOTIFY navigationHistoryChanged)
70 Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY navigationHistoryChanged)71 Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY navigationHistoryChanged)
71 Q_PROPERTY(bool incognito READ incognito WRITE setIncognito NOTIFY incognitoChanged)72 Q_PROPERTY(bool incognito READ incognito WRITE setIncognito NOTIFY incognitoChanged)
@@ -113,6 +114,8 @@
113114
114 QString title() const;115 QString title() const;
115116
117 QUrl icon() const;
118
116 bool canGoBack() const;119 bool canGoBack() const;
117 bool canGoForward() const;120 bool canGoForward() const;
118121
@@ -173,6 +176,7 @@
173 Q_SIGNALS:176 Q_SIGNALS:
174 void urlChanged();177 void urlChanged();
175 void titleChanged();178 void titleChanged();
179 void iconChanged();
176 void navigationHistoryChanged();180 void navigationHistoryChanged();
177 void incognitoChanged();181 void incognitoChanged();
178 void loadingChanged(OxideQLoadEvent* loadEvent);182 void loadingChanged(OxideQLoadEvent* loadEvent);
179183
=== modified file 'qt/quick/api/oxideqquickwebview_p_p.h'
--- qt/quick/api/oxideqquickwebview_p_p.h 2014-05-19 13:26:44 +0000
+++ qt/quick/api/oxideqquickwebview_p_p.h 2014-05-28 08:47:28 +0000
@@ -61,6 +61,7 @@
6161
62 void URLChanged() Q_DECL_FINAL;62 void URLChanged() Q_DECL_FINAL;
63 void TitleChanged() Q_DECL_FINAL;63 void TitleChanged() Q_DECL_FINAL;
64 void IconChanged(QUrl icon) Q_DECL_FINAL;
64 void CommandsUpdated() Q_DECL_FINAL;65 void CommandsUpdated() Q_DECL_FINAL;
6566
66 void LoadProgressChanged(double progress) Q_DECL_FINAL;67 void LoadProgressChanged(double progress) Q_DECL_FINAL;
@@ -116,8 +117,9 @@
116 void attachContextSignals(OxideQQuickWebContextPrivate* context);117 void attachContextSignals(OxideQQuickWebContextPrivate* context);
117 void detachContextSignals(OxideQQuickWebContextPrivate* context);118 void detachContextSignals(OxideQQuickWebContextPrivate* context);
118119
120 bool constructed_;
119 int load_progress_;121 int load_progress_;
120 bool constructed_;122 QUrl icon_;
121 OxideQQuickNavigationHistory navigation_history_;123 OxideQQuickNavigationHistory navigation_history_;
122 QQmlComponent* popup_menu_;124 QQmlComponent* popup_menu_;
123 QQmlComponent* alert_dialog_;125 QQmlComponent* alert_dialog_;
124126
=== added file 'qt/tests/qmltests/api/tst_WebView_icon.html'
--- qt/tests/qmltests/api/tst_WebView_icon.html 1970-01-01 00:00:00 +0000
+++ qt/tests/qmltests/api/tst_WebView_icon.html 2014-05-28 08:47:28 +0000
@@ -0,0 +1,5 @@
1<html>
2<head>
3 <link rel="icon" href="icon.ico" />
4</head>
5</html>
06
=== added file 'qt/tests/qmltests/api/tst_WebView_icon.qml'
--- qt/tests/qmltests/api/tst_WebView_icon.qml 1970-01-01 00:00:00 +0000
+++ qt/tests/qmltests/api/tst_WebView_icon.qml 2014-05-28 08:47:28 +0000
@@ -0,0 +1,32 @@
1import QtQuick 2.0
2import QtTest 1.0
3import com.canonical.Oxide.Testing 1.0
4
5TestWebView {
6 id: webView
7 focus: true
8 width: 200
9 height: 200
10
11 TestCase {
12 name: "WebView_icon"
13 when: windowShown
14
15 function test_WebView_icon_data() {
16 return [
17 { url: "", icon: "" },
18 { url: "http://localhost:8080/empty.html", icon: "http://localhost:8080/favicon.ico" },
19 { url: "http://localhost:8080/tst_WebView_icon.html", icon: "http://localhost:8080/icon.ico" }
20 ];
21 }
22
23 function test_WebView_icon(data) {
24 if (data.url) {
25 webView.url = data.url;
26 verify(webView.waitForLoadSucceeded(),
27 "Timed out waiting for a successful load");
28 }
29 compare(webView.icon.toString(), data.icon);
30 }
31 }
32}
033
=== modified file 'shared/browser/oxide_web_view.cc'
--- shared/browser/oxide_web_view.cc 2014-05-21 16:35:27 +0000
+++ shared/browser/oxide_web_view.cc 2014-05-28 08:47:28 +0000
@@ -37,6 +37,7 @@
37#include "content/public/browser/notification_types.h"37#include "content/public/browser/notification_types.h"
38#include "content/public/browser/render_view_host.h"38#include "content/public/browser/render_view_host.h"
39#include "content/public/browser/web_contents.h"39#include "content/public/browser/web_contents.h"
40#include "content/public/common/favicon_url.h"
40#include "content/public/common/menu_item.h"41#include "content/public/common/menu_item.h"
41#include "content/public/common/url_constants.h"42#include "content/public/common/url_constants.h"
42#include "net/base/net_errors.h"43#include "net/base/net_errors.h"
@@ -561,8 +562,20 @@
561 }562 }
562}563}
563564
565void WebView::DidUpdateFaviconURL(
566 const std::vector<content::FaviconURL>& candidates) {
567 std::vector<content::FaviconURL>::const_iterator it;
568 for (it = candidates.begin(); it != candidates.end(); ++it) {
569 if (it->icon_type == content::FaviconURL::FAVICON) {
570 OnIconChanged(it->icon_url);
571 return;
572 }
573 }
574}
575
564void WebView::OnURLChanged() {}576void WebView::OnURLChanged() {}
565void WebView::OnTitleChanged() {}577void WebView::OnTitleChanged() {}
578void WebView::OnIconChanged(const GURL& icon) {}
566void WebView::OnCommandsUpdated() {}579void WebView::OnCommandsUpdated() {}
567580
568void WebView::OnLoadProgressChanged(double progress) {}581void WebView::OnLoadProgressChanged(double progress) {}
569582
=== modified file 'shared/browser/oxide_web_view.h'
--- shared/browser/oxide_web_view.h 2014-05-20 15:36:50 +0000
+++ shared/browser/oxide_web_view.h 2014-05-28 08:47:28 +0000
@@ -293,8 +293,12 @@
293293
294 void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) FINAL;294 void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) FINAL;
295295
296 void DidUpdateFaviconURL(
297 const std::vector<content::FaviconURL>& candidates) FINAL;
298
296 virtual void OnURLChanged();299 virtual void OnURLChanged();
297 virtual void OnTitleChanged();300 virtual void OnTitleChanged();
301 virtual void OnIconChanged(const GURL& icon);
298 virtual void OnCommandsUpdated();302 virtual void OnCommandsUpdated();
299303
300 virtual void OnLoadProgressChanged(double progress);304 virtual void OnLoadProgressChanged(double progress);

Subscribers

People subscribed via source and target branches