Merge lp:~osomon/oxide/text-selection-colors into lp:~oxide-developers/oxide/oxide.trunk

Proposed by Olivier Tilloy
Status: Rejected
Rejected by: Olivier Tilloy
Proposed branch: lp:~osomon/oxide/text-selection-colors
Merge into: lp:~oxide-developers/oxide/oxide.trunk
Diff against target: 933 lines (+557/-23)
13 files modified
qt/core/browser/oxide_qt_web_context.cc (+112/-2)
qt/core/browser/oxide_qt_web_context.h (+8/-1)
qt/core/glue/oxide_qt_web_context_proxy.h (+13/-0)
qt/qmlplugin/oxide.qmltypes (+30/-14)
qt/qmlplugin/oxide_qml_plugin.cc (+3/-1)
qt/quick/api/oxideqquickwebcontext.cc (+73/-1)
qt/quick/api/oxideqquickwebcontext.h (+23/-1)
qt/tests/qmltests/api/tst_WebContext_selectionColors.qml (+110/-0)
shared/browser/oxide_browser_context.cc (+122/-2)
shared/browser/oxide_browser_context.h (+18/-0)
shared/browser/oxide_browser_context_observer.h (+3/-1)
shared/browser/oxide_web_view_contents_helper.cc (+39/-0)
shared/browser/oxide_web_view_contents_helper.h (+3/-0)
To merge this branch: bzr merge lp:~osomon/oxide/text-selection-colors
Reviewer Review Type Date Requested Status
Olivier Tilloy (community) Disapprove
Chris Coulson Pending
Review via email: mp+278177@code.launchpad.net

Commit message

Expose the text selection colors (active/inactive background/foreground) to the embedder, through the WebContext.

To post a comment you must log in.
1282. By Olivier Tilloy

Merge the latest changes from trunk and resolve a few conflicts.

1283. By Olivier Tilloy

Bump version to 1.14 and re-generate qmltypes file.

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

Unmerged revisions

1283. By Olivier Tilloy

Bump version to 1.14 and re-generate qmltypes file.

1282. By Olivier Tilloy

Merge the latest changes from trunk and resolve a few conflicts.

1281. By Olivier Tilloy

Add unit tests for the selection colors.

1280. By Olivier Tilloy

Bump version to 1.12.

1279. By Olivier Tilloy

Expose the text selection colors (active/inactive background/foreground) to the embedder, through the WebContext.

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_context.cc'
2--- qt/core/browser/oxide_qt_web_context.cc 2016-01-13 18:16:11 +0000
3+++ qt/core/browser/oxide_qt_web_context.cc 2016-02-08 18:10:28 +0000
4@@ -43,6 +43,7 @@
5 #include "net/cookies/cookie_monster.h"
6 #include "net/http/http_response_headers.h"
7 #include "net/url_request/url_request.h"
8+#include "third_party/skia/include/core/SkColor.h"
9 #include "url/gurl.h"
10
11 #include "qt/core/api/oxideqnetworkcallbackevents_p.h"
12@@ -140,7 +141,11 @@
13 devtools_enabled(false),
14 devtools_port(-1),
15 legacy_user_agent_override_enabled(false),
16- do_not_track(false) {}
17+ do_not_track(false),
18+ active_selection_bg_color(SK_ColorTRANSPARENT),
19+ active_selection_fg_color(SK_ColorTRANSPARENT),
20+ inactive_selection_bg_color(SK_ColorTRANSPARENT),
21+ inactive_selection_fg_color(SK_ColorTRANSPARENT) {}
22
23 std::string product;
24 std::string user_agent;
25@@ -160,6 +165,10 @@
26 std::vector<UserAgentSettings::UserAgentOverride> user_agent_overrides;
27 bool legacy_user_agent_override_enabled;
28 bool do_not_track;
29+ SkColor active_selection_bg_color;
30+ SkColor active_selection_fg_color;
31+ SkColor inactive_selection_bg_color;
32+ SkColor inactive_selection_fg_color;
33 };
34
35 class SetCookiesContext : public base::RefCounted<SetCookiesContext> {
36@@ -532,6 +541,23 @@
37 context_->SetIsPopupBlockerEnabled(construct_props_->popup_blocker_enabled);
38 context_->SetDoNotTrack(construct_props_->do_not_track);
39
40+ if (construct_props_->active_selection_bg_color != SK_ColorTRANSPARENT) {
41+ context_->SetActiveSelectionBgColor(
42+ construct_props_->active_selection_bg_color);
43+ }
44+ if (construct_props_->active_selection_fg_color != SK_ColorTRANSPARENT) {
45+ context_->SetActiveSelectionFgColor(
46+ construct_props_->active_selection_fg_color);
47+ }
48+ if (construct_props_->inactive_selection_bg_color != SK_ColorTRANSPARENT) {
49+ context_->SetInactiveSelectionBgColor(
50+ construct_props_->inactive_selection_bg_color);
51+ }
52+ if (construct_props_->inactive_selection_fg_color != SK_ColorTRANSPARENT) {
53+ context_->SetInactiveSelectionFgColor(
54+ construct_props_->inactive_selection_fg_color);
55+ }
56+
57 MediaCaptureDevicesContext* dc =
58 MediaCaptureDevicesContext::Get(context_.get());
59
60@@ -1058,7 +1084,7 @@
61 }
62
63 bool WebContext::doNotTrack() const {
64- if (IsInitialized()) {
65+ if (IsInitialized()) {
66 return context_->GetDoNotTrack();
67 }
68
69@@ -1073,5 +1099,89 @@
70 }
71 }
72
73+QColor WebContext::activeSelectionBgColor() const {
74+ SkColor skcolor;
75+ if (IsInitialized()) {
76+ skcolor = context_->GetActiveSelectionBgColor();
77+ } else {
78+ skcolor = construct_props_->active_selection_bg_color;
79+ }
80+ return QColor(SkColorGetR(skcolor), SkColorGetG(skcolor),
81+ SkColorGetB(skcolor), SkColorGetA(skcolor));
82+}
83+
84+void WebContext::setActiveSelectionBgColor(const QColor& color) {
85+ SkColor skcolor(
86+ SkColorSetARGB(color.alpha(), color.red(), color.green(), color.blue()));
87+ if (IsInitialized()) {
88+ context_->SetActiveSelectionBgColor(skcolor);
89+ } else {
90+ construct_props_->active_selection_bg_color = skcolor;
91+ }
92+}
93+
94+QColor WebContext::activeSelectionFgColor() const {
95+ SkColor skcolor;
96+ if (IsInitialized()) {
97+ skcolor = context_->GetActiveSelectionFgColor();
98+ } else {
99+ skcolor = construct_props_->active_selection_fg_color;
100+ }
101+ return QColor(SkColorGetR(skcolor), SkColorGetG(skcolor),
102+ SkColorGetB(skcolor), SkColorGetA(skcolor));
103+}
104+
105+void WebContext::setActiveSelectionFgColor(const QColor& color) {
106+ SkColor skcolor(
107+ SkColorSetARGB(color.alpha(), color.red(), color.green(), color.blue()));
108+ if (IsInitialized()) {
109+ context_->SetActiveSelectionFgColor(skcolor);
110+ } else {
111+ construct_props_->active_selection_fg_color = skcolor;
112+ }
113+}
114+
115+QColor WebContext::inactiveSelectionBgColor() const {
116+ SkColor skcolor;
117+ if (IsInitialized()) {
118+ skcolor = context_->GetInactiveSelectionBgColor();
119+ } else {
120+ skcolor = construct_props_->inactive_selection_bg_color;
121+ }
122+ return QColor(SkColorGetR(skcolor), SkColorGetG(skcolor),
123+ SkColorGetB(skcolor), SkColorGetA(skcolor));
124+}
125+
126+void WebContext::setInactiveSelectionBgColor(const QColor& color) {
127+ SkColor skcolor(
128+ SkColorSetARGB(color.alpha(), color.red(), color.green(), color.blue()));
129+ if (IsInitialized()) {
130+ context_->SetInactiveSelectionBgColor(skcolor);
131+ } else {
132+ construct_props_->inactive_selection_bg_color = skcolor;
133+ }
134+}
135+
136+QColor WebContext::inactiveSelectionFgColor() const {
137+ SkColor skcolor;
138+ if (IsInitialized()) {
139+ skcolor = context_->GetInactiveSelectionFgColor();
140+ } else {
141+ skcolor = construct_props_->inactive_selection_fg_color;
142+ }
143+ return QColor(SkColorGetR(skcolor), SkColorGetG(skcolor),
144+ SkColorGetB(skcolor), SkColorGetA(skcolor));
145+}
146+
147+void WebContext::setInactiveSelectionFgColor(const QColor& color) {
148+ SkColor skcolor(
149+ SkColorSetARGB(color.alpha(), color.red(), color.green(), color.blue()));
150+ if (IsInitialized()) {
151+ context_->SetInactiveSelectionFgColor(skcolor);
152+ } else {
153+ construct_props_->inactive_selection_fg_color = skcolor;
154+ }
155+}
156+
157 } // namespace qt
158 } // namespace oxide
159
160=== modified file 'qt/core/browser/oxide_qt_web_context.h'
161--- qt/core/browser/oxide_qt_web_context.h 2016-01-04 13:40:25 +0000
162+++ qt/core/browser/oxide_qt_web_context.h 2016-02-08 18:10:28 +0000
163@@ -146,9 +146,16 @@
164 const QList<UserAgentOverride>& overrides) override;
165 void clearTemporarySavedPermissionStatuses() override;
166 void setLegacyUserAgentOverrideEnabled(bool enabled) override;
167-
168 bool doNotTrack() const override;
169 void setDoNotTrack(bool dnt) override;
170+ QColor activeSelectionBgColor() const override;
171+ void setActiveSelectionBgColor(const QColor& color) override;
172+ QColor activeSelectionFgColor() const override;
173+ void setActiveSelectionFgColor(const QColor& color) override;
174+ QColor inactiveSelectionBgColor() const override;
175+ void setInactiveSelectionBgColor(const QColor& color) override;
176+ QColor inactiveSelectionFgColor() const override;
177+ void setInactiveSelectionFgColor(const QColor& color) override;
178
179 // oxide::MediaCaptureDevicesContextClient implementation
180 void DefaultAudioDeviceChanged() override;
181
182=== modified file 'qt/core/glue/oxide_qt_web_context_proxy.h'
183--- qt/core/glue/oxide_qt_web_context_proxy.h 2015-07-03 14:22:25 +0000
184+++ qt/core/glue/oxide_qt_web_context_proxy.h 2016-02-08 18:10:28 +0000
185@@ -18,6 +18,7 @@
186 #ifndef _OXIDE_QT_CORE_GLUE_WEB_CONTEXT_PROXY_H_
187 #define _OXIDE_QT_CORE_GLUE_WEB_CONTEXT_PROXY_H_
188
189+#include <QColor>
190 #include <QPair>
191 #include <QString>
192 #include <QStringList>
193@@ -141,6 +142,18 @@
194
195 virtual bool doNotTrack() const = 0;
196 virtual void setDoNotTrack(bool dnt) = 0;
197+
198+ virtual QColor activeSelectionBgColor() const = 0;
199+ virtual void setActiveSelectionBgColor(const QColor& color) = 0;
200+
201+ virtual QColor activeSelectionFgColor() const = 0;
202+ virtual void setActiveSelectionFgColor(const QColor& color) = 0;
203+
204+ virtual QColor inactiveSelectionBgColor() const = 0;
205+ virtual void setInactiveSelectionBgColor(const QColor& color) = 0;
206+
207+ virtual QColor inactiveSelectionFgColor() const = 0;
208+ virtual void setInactiveSelectionFgColor(const QColor& color) = 0;
209 };
210
211 } // namespace qt
212
213=== modified file 'qt/qmlplugin/oxide.qmltypes'
214--- qt/qmlplugin/oxide.qmltypes 2016-01-12 11:45:54 +0000
215+++ qt/qmlplugin/oxide.qmltypes 2016-02-08 18:10:28 +0000
216@@ -4,7 +4,7 @@
217 // It is used for QML tooling purposes only.
218 //
219 // This file was auto-generated by:
220-// 'qmlplugindump -v -noinstantiate com.canonical.Oxide 1.12 com/canonical/Oxide'
221+// 'qmlplugindump -v -noinstantiate com.canonical.Oxide 1.14 com/canonical/Oxide'
222
223 Module {
224 Component {
225@@ -54,11 +54,10 @@
226 }
227 Component {
228 name: "OxideQGeolocationPermissionRequest"
229- prototype: "OxideQSimplePermissionRequest"
230+ prototype: "OxideQPermissionRequest"
231 exports: ["GeolocationPermissionRequest 1.0"]
232 isCreatable: false
233 exportMetaObjectRevisions: [0]
234- Property { name: "origin"; type: "QUrl"; isReadonly: true }
235 Method { name: "accept" }
236 }
237 Component {
238@@ -78,6 +77,15 @@
239 Method { name: "deny" }
240 }
241 Component {
242+ name: "OxideQMediaAccessPermissionRequest"
243+ prototype: "OxideQPermissionRequest"
244+ exports: ["MediaAccessPermissionRequest 1.0"]
245+ isCreatable: false
246+ exportMetaObjectRevisions: [0]
247+ Property { name: "isForAudio"; type: "bool"; isReadonly: true }
248+ Property { name: "isForVideo"; type: "bool"; isReadonly: true }
249+ }
250+ Component {
251 name: "OxideQNavigationRequest"
252 prototype: "QObject"
253 exports: ["NavigationRequest 1.0"]
254@@ -127,11 +135,16 @@
255 Component {
256 name: "OxideQPermissionRequest"
257 prototype: "QObject"
258+ exports: ["PermissionRequest 1.0"]
259+ isCreatable: false
260+ exportMetaObjectRevisions: [0]
261 Property { name: "origin"; type: "QUrl"; isReadonly: true }
262 Property { name: "embedder"; type: "QUrl"; isReadonly: true }
263 Property { name: "isCancelled"; type: "bool"; isReadonly: true }
264 Property { name: "url"; type: "QUrl"; isReadonly: true }
265 Signal { name: "cancelled" }
266+ Method { name: "allow" }
267+ Method { name: "deny" }
268 }
269 Component {
270 name: "OxideQQuickCookieManager"
271@@ -327,11 +340,12 @@
272 prototype: "QObject"
273 exports: [
274 "WebContext 1.0",
275+ "WebContext 1.14",
276 "WebContext 1.3",
277 "WebContext 1.6",
278 "WebContext 1.9"
279 ]
280- exportMetaObjectRevisions: [0, 1, 2, 3]
281+ exportMetaObjectRevisions: [0, 4, 1, 2, 3]
282 Enum {
283 name: "CookiePolicy"
284 values: {
285@@ -388,6 +402,10 @@
286 Property { name: "defaultVideoCaptureDeviceId"; revision: 3; type: "string" }
287 Property { name: "userAgentOverrides"; revision: 3; type: "QVariantList" }
288 Property { name: "doNotTrackEnabled"; revision: 3; type: "bool" }
289+ Property { name: "activeSelectionBgColor"; revision: 4; type: "QColor" }
290+ Property { name: "activeSelectionFgColor"; revision: 4; type: "QColor" }
291+ Property { name: "inactiveSelectionBgColor"; revision: 4; type: "QColor" }
292+ Property { name: "inactiveSelectionFgColor"; revision: 4; type: "QColor" }
293 Signal { name: "devtoolsBindIpChanged" }
294 Signal { name: "hostMappingRulesChanged"; revision: 1 }
295 Signal { name: "allowedExtraUrlSchemesChanged"; revision: 1 }
296@@ -396,6 +414,10 @@
297 Signal { name: "defaultVideoCaptureDeviceIdChanged"; revision: 3 }
298 Signal { name: "userAgentOverridesChanged"; revision: 3 }
299 Signal { name: "doNotTrackEnabledChanged"; revision: 3 }
300+ Signal { name: "activeSelectionBgColorChanged"; revision: 4 }
301+ Signal { name: "activeSelectionFgColorChanged"; revision: 4 }
302+ Signal { name: "inactiveSelectionBgColorChanged"; revision: 4 }
303+ Signal { name: "inactiveSelectionFgColorChanged"; revision: 4 }
304 Method {
305 name: "addUserScript"
306 Parameter { name: "user_script"; type: "OxideQQuickUserScript"; isPointer: true }
307@@ -779,7 +801,7 @@
308 }
309 }
310 Enum {
311- name: "ContentStatusFlags"
312+ name: "ContentStatus"
313 values: {
314 "ContentStatusNormal": 0,
315 "ContentStatusDisplayedInsecure": 1,
316@@ -787,7 +809,7 @@
317 }
318 }
319 Enum {
320- name: "CertStatusFlags"
321+ name: "CertStatus"
322 values: {
323 "CertStatusOk": 0,
324 "CertStatusBadIdentity": 1,
325@@ -802,17 +824,11 @@
326 }
327 }
328 Property { name: "securityLevel"; type: "SecurityLevel"; isReadonly: true }
329- Property { name: "contentStatus"; type: "ContentStatusFlags"; isReadonly: true }
330- Property { name: "certStatus"; type: "CertStatusFlags"; isReadonly: true }
331+ Property { name: "contentStatus"; type: "ContentStatus"; isReadonly: true }
332+ Property { name: "certStatus"; type: "CertStatus"; isReadonly: true }
333 Property { name: "certificate"; type: "QVariant"; isReadonly: true }
334 }
335 Component {
336- name: "OxideQSimplePermissionRequest"
337- prototype: "OxideQPermissionRequest"
338- Method { name: "allow" }
339- Method { name: "deny" }
340- }
341- Component {
342 name: "OxideQWebPreferences"
343 prototype: "QObject"
344 exports: ["WebPreferences 1.0"]
345
346=== modified file 'qt/qmlplugin/oxide_qml_plugin.cc'
347--- qt/qmlplugin/oxide_qml_plugin.cc 2016-01-13 19:05:43 +0000
348+++ qt/qmlplugin/oxide_qml_plugin.cc 2016-02-08 18:10:28 +0000
349@@ -1,5 +1,5 @@
350 // vim:expandtab:shiftwidth=2:tabstop=2:
351-// Copyright (C) 2013-2015 Canonical Ltd.
352+// Copyright (C) 2013-2016 Canonical Ltd.
353
354 // This library is free software; you can redistribute it and/or
355 // modify it under the terms of the GNU Lesser General Public
356@@ -200,6 +200,8 @@
357 "TouchSelectionController is accessed via "
358 "WebView.touchSelectionController");
359 qmlRegisterType<OxideQQuickWebView, 7>(uri, 1, 12, "WebView");
360+
361+ qmlRegisterType<OxideQQuickWebContext, 4>(uri, 1, 14, "WebContext");
362 }
363 };
364
365
366=== modified file 'qt/quick/api/oxideqquickwebcontext.cc'
367--- qt/quick/api/oxideqquickwebcontext.cc 2016-01-26 16:47:06 +0000
368+++ qt/quick/api/oxideqquickwebcontext.cc 2016-02-08 18:10:28 +0000
369@@ -1,5 +1,5 @@
370 // vim:expandtab:shiftwidth=2:tabstop=2:
371-// Copyright (C) 2013-2015 Canonical Ltd.
372+// Copyright (C) 2013-2016 Canonical Ltd.
373
374 // This library is free software; you can redistribute it and/or
375 // modify it under the terms of the GNU Lesser General Public
376@@ -1155,4 +1155,76 @@
377 emit doNotTrackEnabledChanged();
378 }
379
380+QColor OxideQQuickWebContext::activeSelectionBgColor() const {
381+ Q_D(const OxideQQuickWebContext);
382+
383+ return d->proxy()->activeSelectionBgColor();
384+}
385+
386+void OxideQQuickWebContext::setActiveSelectionBgColor(const QColor& color) {
387+ Q_D(OxideQQuickWebContext);
388+
389+ if (activeSelectionBgColor() == color) {
390+ return;
391+ }
392+
393+ d->proxy()->setActiveSelectionBgColor(color);
394+
395+ emit activeSelectionBgColorChanged();
396+}
397+
398+QColor OxideQQuickWebContext::activeSelectionFgColor() const {
399+ Q_D(const OxideQQuickWebContext);
400+
401+ return d->proxy()->activeSelectionFgColor();
402+}
403+
404+void OxideQQuickWebContext::setActiveSelectionFgColor(const QColor& color) {
405+ Q_D(OxideQQuickWebContext);
406+
407+ if (activeSelectionFgColor() == color) {
408+ return;
409+ }
410+
411+ d->proxy()->setActiveSelectionFgColor(color);
412+
413+ emit activeSelectionFgColorChanged();
414+}
415+
416+QColor OxideQQuickWebContext::inactiveSelectionBgColor() const {
417+ Q_D(const OxideQQuickWebContext);
418+
419+ return d->proxy()->inactiveSelectionBgColor();
420+}
421+
422+void OxideQQuickWebContext::setInactiveSelectionBgColor(const QColor& color) {
423+ Q_D(OxideQQuickWebContext);
424+
425+ if (inactiveSelectionBgColor() == color) {
426+ return;
427+ }
428+
429+ d->proxy()->setInactiveSelectionBgColor(color);
430+
431+ emit inactiveSelectionBgColorChanged();
432+}
433+
434+QColor OxideQQuickWebContext::inactiveSelectionFgColor() const {
435+ Q_D(const OxideQQuickWebContext);
436+
437+ return d->proxy()->inactiveSelectionFgColor();
438+}
439+
440+void OxideQQuickWebContext::setInactiveSelectionFgColor(const QColor& color) {
441+ Q_D(OxideQQuickWebContext);
442+
443+ if (inactiveSelectionFgColor() == color) {
444+ return;
445+ }
446+
447+ d->proxy()->setInactiveSelectionFgColor(color);
448+
449+ emit inactiveSelectionFgColorChanged();
450+}
451+
452 #include "moc_oxideqquickwebcontext.cpp"
453
454=== modified file 'qt/quick/api/oxideqquickwebcontext.h'
455--- qt/quick/api/oxideqquickwebcontext.h 2016-01-13 18:16:11 +0000
456+++ qt/quick/api/oxideqquickwebcontext.h 2016-02-08 18:10:28 +0000
457@@ -1,5 +1,5 @@
458 // vim:expandtab:shiftwidth=2:tabstop=2:
459-// Copyright (C) 2013-2015 Canonical Ltd.
460+// Copyright (C) 2013-2016 Canonical Ltd.
461
462 // This library is free software; you can redistribute it and/or
463 // modify it under the terms of the GNU Lesser General Public
464@@ -24,6 +24,7 @@
465 #include <QtCore/QtGlobal>
466 #include <QtCore/QUrl>
467 #include <QtCore/QVariantList>
468+#include <QtGui/QColor>
469 #include <QtQml/QQmlListProperty>
470 #include <QtQml/QQmlParserStatus>
471 #include <QtQml/QtQml>
472@@ -77,6 +78,11 @@
473
474 Q_PROPERTY(bool doNotTrackEnabled READ doNotTrack WRITE setDoNotTrack NOTIFY doNotTrackEnabledChanged REVISION 3)
475
476+ Q_PROPERTY(QColor activeSelectionBgColor READ activeSelectionBgColor WRITE setActiveSelectionBgColor NOTIFY activeSelectionBgColorChanged REVISION 4)
477+ Q_PROPERTY(QColor activeSelectionFgColor READ activeSelectionFgColor WRITE setActiveSelectionFgColor NOTIFY activeSelectionFgColorChanged REVISION 4)
478+ Q_PROPERTY(QColor inactiveSelectionBgColor READ inactiveSelectionBgColor WRITE setInactiveSelectionBgColor NOTIFY inactiveSelectionBgColorChanged REVISION 4)
479+ Q_PROPERTY(QColor inactiveSelectionFgColor READ inactiveSelectionFgColor WRITE setInactiveSelectionFgColor NOTIFY inactiveSelectionFgColorChanged REVISION 4)
480+
481 Q_ENUMS(CookiePolicy)
482 Q_ENUMS(SessionCookieMode)
483
484@@ -173,6 +179,18 @@
485 bool doNotTrack() const;
486 void setDoNotTrack(bool dnt);
487
488+ QColor activeSelectionBgColor() const;
489+ void setActiveSelectionBgColor(const QColor& color);
490+
491+ QColor activeSelectionFgColor() const;
492+ void setActiveSelectionFgColor(const QColor& color);
493+
494+ QColor inactiveSelectionBgColor() const;
495+ void setInactiveSelectionBgColor(const QColor& color);
496+
497+ QColor inactiveSelectionFgColor() const;
498+ void setInactiveSelectionFgColor(const QColor& color);
499+
500 Q_SIGNALS:
501 void productChanged();
502 void userAgentChanged();
503@@ -196,6 +214,10 @@
504 Q_REVISION(3) void defaultVideoCaptureDeviceIdChanged();
505 Q_REVISION(3) void userAgentOverridesChanged();
506 Q_REVISION(3) void doNotTrackEnabledChanged();
507+ Q_REVISION(4) void activeSelectionBgColorChanged();
508+ Q_REVISION(4) void activeSelectionFgColorChanged();
509+ Q_REVISION(4) void inactiveSelectionBgColorChanged();
510+ Q_REVISION(4) void inactiveSelectionFgColorChanged();
511
512 protected:
513 // QQmlParserStatus implementation
514
515=== added file 'qt/tests/qmltests/api/tst_WebContext_selectionColors.qml'
516--- qt/tests/qmltests/api/tst_WebContext_selectionColors.qml 1970-01-01 00:00:00 +0000
517+++ qt/tests/qmltests/api/tst_WebContext_selectionColors.qml 2016-02-08 18:10:28 +0000
518@@ -0,0 +1,110 @@
519+import QtQuick 2.0
520+import QtTest 1.0
521+import com.canonical.Oxide 1.12
522+import com.canonical.Oxide.Testing 1.0
523+
524+TestWebView {
525+ id: webView
526+
527+ focus: true
528+
529+ width: 200
530+ height: 200
531+
532+ SignalSpy {
533+ id: activeBgSpy
534+ target: webView.context
535+ signalName: "activeSelectionBgColorChanged"
536+ }
537+
538+ SignalSpy {
539+ id: activeFgSpy
540+ target: webView.context
541+ signalName: "activeSelectionFgColorChanged"
542+ }
543+
544+ SignalSpy {
545+ id: inactiveBgSpy
546+ target: webView.context
547+ signalName: "inactiveSelectionBgColorChanged"
548+ }
549+
550+ SignalSpy {
551+ id: inactiveFgSpy
552+ target: webView.context
553+ signalName: "inactiveSelectionFgColorChanged"
554+ }
555+
556+ Binding {
557+ id: colorBinding
558+ target: webView.context
559+ }
560+
561+ TestCase {
562+ id: test
563+ name: "WebContext_selectionColors"
564+ when: windowShown
565+
566+ // Default values defined in content/public/common/renderer_preferences.cc
567+ readonly property color defaultActiveBg: "#1E90FF"
568+ readonly property color defaultActiveFg: "white"
569+ readonly property color defaultInactiveBg: "#C8C8C8"
570+ readonly property color defaultInactiveFg: "#323232"
571+
572+ // Test colors
573+ readonly property color red: "red"
574+ readonly property color green: "green"
575+
576+ function init() {
577+ activeBgSpy.clear();
578+ activeFgSpy.clear();
579+ inactiveBgSpy.clear();
580+ inactiveFgSpy.clear();
581+ }
582+
583+ function test_default_values() {
584+ compare(webView.context.activeSelectionBgColor, defaultActiveBg);
585+ compare(webView.context.activeSelectionFgColor, defaultActiveFg);
586+ compare(webView.context.inactiveSelectionBgColor, defaultInactiveBg);
587+ compare(webView.context.inactiveSelectionFgColor, defaultInactiveFg);
588+ }
589+
590+ function test_set_colors() {
591+ webView.context.activeSelectionBgColor = red;
592+ compare(activeBgSpy.count, 1);
593+ compare(webView.context.activeSelectionBgColor, red);
594+ webView.context.activeSelectionBgColor = red;
595+ compare(activeBgSpy.count, 1);
596+ webView.context.activeSelectionBgColor = green;
597+ compare(activeBgSpy.count, 2);
598+ compare(webView.context.activeSelectionBgColor, green);
599+
600+ webView.context.activeSelectionFgColor = red;
601+ compare(activeFgSpy.count, 1);
602+ compare(webView.context.activeSelectionFgColor, red);
603+ webView.context.activeSelectionFgColor = red;
604+ compare(activeFgSpy.count, 1);
605+ webView.context.activeSelectionFgColor = green;
606+ compare(activeFgSpy.count, 2);
607+ compare(webView.context.activeSelectionFgColor, green);
608+
609+ webView.context.inactiveSelectionBgColor = red;
610+ compare(inactiveBgSpy.count, 1);
611+ compare(webView.context.inactiveSelectionBgColor, red);
612+ webView.context.inactiveSelectionBgColor = red;
613+ compare(inactiveBgSpy.count, 1);
614+ webView.context.inactiveSelectionBgColor = green;
615+ compare(inactiveBgSpy.count, 2);
616+ compare(webView.context.inactiveSelectionBgColor, green);
617+
618+ webView.context.inactiveSelectionFgColor = red;
619+ compare(inactiveFgSpy.count, 1);
620+ compare(webView.context.inactiveSelectionFgColor, red);
621+ webView.context.inactiveSelectionFgColor = red;
622+ compare(inactiveFgSpy.count, 1);
623+ webView.context.inactiveSelectionFgColor = green;
624+ compare(inactiveFgSpy.count, 2);
625+ compare(webView.context.inactiveSelectionFgColor, green);
626+ }
627+ }
628+}
629
630=== modified file 'shared/browser/oxide_browser_context.cc'
631--- shared/browser/oxide_browser_context.cc 2016-01-04 13:40:25 +0000
632+++ shared/browser/oxide_browser_context.cc 2016-02-08 18:10:28 +0000
633@@ -193,7 +193,11 @@
634 popup_blocker_enabled(true),
635 host_mapping_rules(params.host_mapping_rules),
636 user_agent_settings(new UserAgentSettingsIOData(context)),
637- do_not_track(false) {}
638+ do_not_track(false),
639+ active_selection_bg_color(SK_ColorTRANSPARENT),
640+ active_selection_fg_color(SK_ColorTRANSPARENT),
641+ inactive_selection_bg_color(SK_ColorTRANSPARENT),
642+ inactive_selection_fg_color(SK_ColorTRANSPARENT) {}
643
644 mutable base::Lock lock;
645
646@@ -211,6 +215,11 @@
647
648 bool do_not_track;
649
650+ SkColor active_selection_bg_color;
651+ SkColor active_selection_fg_color;
652+ SkColor inactive_selection_bg_color;
653+ SkColor inactive_selection_fg_color;
654+
655 scoped_refptr<BrowserContextDelegate> delegate;
656 };
657
658@@ -353,6 +362,30 @@
659 return data.do_not_track;
660 }
661
662+SkColor BrowserContextIOData::GetActiveSelectionBgColor() const {
663+ const BrowserContextSharedIOData& data = GetSharedData();
664+ base::AutoLock lock(data.lock);
665+ return data.active_selection_bg_color;
666+}
667+
668+SkColor BrowserContextIOData::GetActiveSelectionFgColor() const {
669+ const BrowserContextSharedIOData& data = GetSharedData();
670+ base::AutoLock lock(data.lock);
671+ return data.active_selection_fg_color;
672+}
673+
674+SkColor BrowserContextIOData::GetInactiveSelectionBgColor() const {
675+ const BrowserContextSharedIOData& data = GetSharedData();
676+ base::AutoLock lock(data.lock);
677+ return data.inactive_selection_bg_color;
678+}
679+
680+SkColor BrowserContextIOData::GetInactiveSelectionFgColor() const {
681+ const BrowserContextSharedIOData& data = GetSharedData();
682+ base::AutoLock lock(data.lock);
683+ return data.inactive_selection_fg_color;
684+}
685+
686 URLRequestContext* BrowserContextIOData::CreateMainRequestContext(
687 content::ProtocolHandlerMap& protocol_handlers,
688 content::URLRequestInterceptorScopedVector request_interceptors) {
689@@ -886,7 +919,6 @@
690 return io_data()->cookie_store_;
691 }
692
693-
694 TemporarySavedPermissionContext*
695 BrowserContext::GetTemporarySavedPermissionContext() const {
696 DCHECK(CalledOnValidThread());
697@@ -915,4 +947,92 @@
698 }
699 }
700
701+SkColor BrowserContext::GetActiveSelectionBgColor() const {
702+ DCHECK(CalledOnValidThread());
703+ return io_data()->GetSharedData().active_selection_bg_color;
704+}
705+
706+void BrowserContext::SetActiveSelectionBgColor(SkColor color) {
707+ DCHECK(CalledOnValidThread());
708+
709+ BrowserContextSharedIOData& data = io_data()->GetSharedData();
710+ base::AutoLock lock(data.lock);
711+ data.active_selection_bg_color = color;
712+
713+ FOR_EACH_OBSERVER(BrowserContextObserver,
714+ GetOriginalContext()->observers_,
715+ NotifySelectionColorsChanged());
716+ if (HasOffTheRecordContext()) {
717+ FOR_EACH_OBSERVER(BrowserContextObserver,
718+ GetOffTheRecordContext()->observers_,
719+ NotifySelectionColorsChanged());
720+ }
721+}
722+
723+SkColor BrowserContext::GetActiveSelectionFgColor() const {
724+ DCHECK(CalledOnValidThread());
725+ return io_data()->GetSharedData().active_selection_fg_color;
726+}
727+
728+void BrowserContext::SetActiveSelectionFgColor(SkColor color) {
729+ DCHECK(CalledOnValidThread());
730+
731+ BrowserContextSharedIOData& data = io_data()->GetSharedData();
732+ base::AutoLock lock(data.lock);
733+ data.active_selection_fg_color = color;
734+
735+ FOR_EACH_OBSERVER(BrowserContextObserver,
736+ GetOriginalContext()->observers_,
737+ NotifySelectionColorsChanged());
738+ if (HasOffTheRecordContext()) {
739+ FOR_EACH_OBSERVER(BrowserContextObserver,
740+ GetOffTheRecordContext()->observers_,
741+ NotifySelectionColorsChanged());
742+ }
743+}
744+
745+SkColor BrowserContext::GetInactiveSelectionBgColor() const {
746+ DCHECK(CalledOnValidThread());
747+ return io_data()->GetSharedData().inactive_selection_bg_color;
748+}
749+
750+void BrowserContext::SetInactiveSelectionBgColor(SkColor color) {
751+ DCHECK(CalledOnValidThread());
752+
753+ BrowserContextSharedIOData& data = io_data()->GetSharedData();
754+ base::AutoLock lock(data.lock);
755+ data.inactive_selection_bg_color = color;
756+
757+ FOR_EACH_OBSERVER(BrowserContextObserver,
758+ GetOriginalContext()->observers_,
759+ NotifySelectionColorsChanged());
760+ if (HasOffTheRecordContext()) {
761+ FOR_EACH_OBSERVER(BrowserContextObserver,
762+ GetOffTheRecordContext()->observers_,
763+ NotifySelectionColorsChanged());
764+ }
765+}
766+
767+SkColor BrowserContext::GetInactiveSelectionFgColor() const {
768+ DCHECK(CalledOnValidThread());
769+ return io_data()->GetSharedData().inactive_selection_fg_color;
770+}
771+
772+void BrowserContext::SetInactiveSelectionFgColor(SkColor color) {
773+ DCHECK(CalledOnValidThread());
774+
775+ BrowserContextSharedIOData& data = io_data()->GetSharedData();
776+ base::AutoLock lock(data.lock);
777+ data.inactive_selection_fg_color = color;
778+
779+ FOR_EACH_OBSERVER(BrowserContextObserver,
780+ GetOriginalContext()->observers_,
781+ NotifySelectionColorsChanged());
782+ if (HasOffTheRecordContext()) {
783+ FOR_EACH_OBSERVER(BrowserContextObserver,
784+ GetOffTheRecordContext()->observers_,
785+ NotifySelectionColorsChanged());
786+ }
787+}
788+
789 } // namespace oxide
790
791=== modified file 'shared/browser/oxide_browser_context.h'
792--- shared/browser/oxide_browser_context.h 2016-01-04 13:40:25 +0000
793+++ shared/browser/oxide_browser_context.h 2016-02-08 18:10:28 +0000
794@@ -31,6 +31,7 @@
795 #include "content/public/browser/content_browser_client.h"
796 #include "content/public/browser/cookie_store_factory.h"
797 #include "net/base/static_cookie_policy.h"
798+#include "third_party/skia/include/core/SkColor.h"
799
800 namespace content {
801 class ResourceContext;
802@@ -89,6 +90,11 @@
803
804 bool GetDoNotTrack() const;
805
806+ SkColor GetActiveSelectionBgColor() const;
807+ SkColor GetActiveSelectionFgColor() const;
808+ SkColor GetInactiveSelectionBgColor() const;
809+ SkColor GetInactiveSelectionFgColor() const;
810+
811 virtual bool IsOffTheRecord() const = 0;
812
813 URLRequestContext* CreateMainRequestContext(
814@@ -220,6 +226,18 @@
815 bool GetDoNotTrack() const;
816 void SetDoNotTrack(bool dnt);
817
818+ SkColor GetActiveSelectionBgColor() const;
819+ void SetActiveSelectionBgColor(SkColor color);
820+
821+ SkColor GetActiveSelectionFgColor() const;
822+ void SetActiveSelectionFgColor(SkColor color);
823+
824+ SkColor GetInactiveSelectionBgColor() const;
825+ void SetInactiveSelectionBgColor(SkColor color);
826+
827+ SkColor GetInactiveSelectionFgColor() const;
828+ void SetInactiveSelectionFgColor(SkColor color);
829+
830 // from content::BrowserContext
831 content::ResourceContext* GetResourceContext() override;
832
833
834=== modified file 'shared/browser/oxide_browser_context_observer.h'
835--- shared/browser/oxide_browser_context_observer.h 2015-06-11 17:39:35 +0000
836+++ shared/browser/oxide_browser_context_observer.h 2016-02-08 18:10:28 +0000
837@@ -1,5 +1,5 @@
838 // vim:expandtab:shiftwidth=2:tabstop=2:
839-// Copyright (C) 2013 Canonical Ltd.
840+// Copyright (C) 2013-2015 Canonical Ltd.
841
842 // This library is free software; you can redistribute it and/or
843 // modify it under the terms of the GNU Lesser General Public
844@@ -32,6 +32,8 @@
845
846 virtual void NotifyDoNotTrackChanged() {}
847
848+ virtual void NotifySelectionColorsChanged() {}
849+
850 protected:
851 BrowserContextObserver();
852 BrowserContextObserver(BrowserContext* context);
853
854=== modified file 'shared/browser/oxide_web_view_contents_helper.cc'
855--- shared/browser/oxide_web_view_contents_helper.cc 2015-10-15 08:32:01 +0000
856+++ shared/browser/oxide_web_view_contents_helper.cc 2016-02-08 18:10:28 +0000
857@@ -21,6 +21,7 @@
858 #include "content/public/browser/render_view_host.h"
859 #include "content/public/browser/web_contents.h"
860 #include "content/public/common/renderer_preferences.h"
861+#include "third_party/skia/include/core/SkColor.h"
862
863 #include "shared/common/oxide_content_client.h"
864
865@@ -72,6 +73,42 @@
866 rvh->SyncRendererPrefs();
867 }
868
869+void WebViewContentsHelper::NotifySelectionColorsChanged() {
870+ UpdateSelectionColors();
871+
872+ // Send the new selection colors to the renderer.
873+ content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
874+ if (!rvh) {
875+ return;
876+ }
877+ rvh->SyncRendererPrefs();
878+}
879+
880+void WebViewContentsHelper::UpdateSelectionColors() const {
881+ content::RendererPreferences* renderer_prefs =
882+ web_contents_->GetMutableRendererPrefs();
883+
884+ SkColor active_selection_bg_color = context_->GetActiveSelectionBgColor();
885+ if (active_selection_bg_color != SK_ColorTRANSPARENT) {
886+ renderer_prefs->active_selection_bg_color = active_selection_bg_color;
887+ }
888+
889+ SkColor active_selection_fg_color = context_->GetActiveSelectionFgColor();
890+ if (active_selection_fg_color != SK_ColorTRANSPARENT) {
891+ renderer_prefs->active_selection_fg_color = active_selection_fg_color;
892+ }
893+
894+ SkColor inactive_selection_bg_color = context_->GetInactiveSelectionBgColor();
895+ if (inactive_selection_bg_color != SK_ColorTRANSPARENT) {
896+ renderer_prefs->inactive_selection_bg_color = inactive_selection_bg_color;
897+ }
898+
899+ SkColor inactive_selection_fg_color = context_->GetInactiveSelectionFgColor();
900+ if (inactive_selection_fg_color != SK_ColorTRANSPARENT) {
901+ renderer_prefs->inactive_selection_fg_color = inactive_selection_fg_color;
902+ }
903+}
904+
905 WebViewContentsHelper::WebViewContentsHelper(content::WebContents* contents,
906 content::WebContents* opener)
907 : BrowserContextObserver(
908@@ -87,6 +124,8 @@
909 web_contents_->GetMutableRendererPrefs();
910 renderer_prefs->enable_do_not_track = context_->GetDoNotTrack();
911
912+ UpdateSelectionColors();
913+
914 content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
915 if (rvh) {
916 rvh->SyncRendererPrefs();
917
918=== modified file 'shared/browser/oxide_web_view_contents_helper.h'
919--- shared/browser/oxide_web_view_contents_helper.h 2015-06-11 17:39:35 +0000
920+++ shared/browser/oxide_web_view_contents_helper.h 2016-02-08 18:10:28 +0000
921@@ -63,10 +63,13 @@
922 // BrowserContextObserver implementation
923 void NotifyPopupBlockerEnabledChanged() final;
924 void NotifyDoNotTrackChanged() final;
925+ void NotifySelectionColorsChanged() final;
926
927 // WebPreferencesObserver implementation
928 void WebPreferencesValueChanged() final;
929
930+ void UpdateSelectionColors() const;
931+
932 scoped_refptr<BrowserContext> context_;
933 content::WebContents* web_contents_;
934

Subscribers

People subscribed via source and target branches