Merge lp:~abreu-alexandre/oxide/donottrack into lp:~oxide-developers/oxide/oxide.trunk
- donottrack
- Merge into oxide.trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 1159 | ||||
Proposed branch: | lp:~abreu-alexandre/oxide/donottrack | ||||
Merge into: | lp:~oxide-developers/oxide/oxide.trunk | ||||
Diff against target: |
438 lines (+212/-1) (has conflicts) 13 files modified
qt/core/browser/oxide_qt_web_context.cc (+24/-0) qt/core/browser/oxide_qt_web_context.h (+3/-0) qt/core/glue/oxide_qt_web_context_proxy.h (+3/-0) qt/quick/api/oxideqquickwebcontext.cc (+19/-0) qt/quick/api/oxideqquickwebcontext_p.h (+6/-0) qt/tests/qmltests/api/tst_WebContext_doNotTrack.py (+18/-0) qt/tests/qmltests/api/tst_WebContext_doNotTrack.qml (+74/-0) shared/browser/oxide_browser_context.cc (+33/-1) shared/browser/oxide_browser_context.h (+5/-0) shared/browser/oxide_browser_context_observer.h (+2/-0) shared/browser/oxide_network_delegate.cc (+10/-0) shared/browser/oxide_web_view_contents_helper.cc (+14/-0) shared/browser/oxide_web_view_contents_helper.h (+1/-0) Text conflict in qt/core/browser/oxide_qt_web_context.cc |
||||
To merge this branch: | bzr merge lp:~abreu-alexandre/oxide/donottrack | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Coulson | Approve | ||
Review via email: mp+261766@code.launchpad.net |
Commit message
Handle do not track
Description of the change
Handle do not track
- 1126. By Chris Coulson
-
Bump Chromium rev to 45.0.2427.7
- 1127. By Chris Coulson
-
Persist media device permissions for the life of WebContext
- 1128. By Chris Coulson
-
Make ContentBrowserC
lient / ContentRenderer Client memebers of ContentMainDelegate like ContentClient already is - 1129. By Chris Coulson
-
Pass the application locale to ui::ResourceBun
dle::InitShared InstanceWithLoc ale. Because we don't build with glib support, it's unable to detect the system locale and depends on a preferred one being passed - 1130. By Chris Coulson
-
Convert UserScriptMaster in to a KeyedService
- 1131. By Chris Coulson
-
Create a single TestWebContext in tst_WebView_
save_restore_ state.qml - 1132. By Chris Coulson
-
Don't allow QObjects to be passed to WebContextDeleg
ateWorker - 1133. By Chris Coulson
-
Add justifications around less-obvious uses of base::Unretained
- 1134. By Olivier Tilloy
-
Fix save/restore unit tests.
- 1135. By Chris Coulson
-
Bump Chromium rev to 45.0.2431.0
- 1136. By Chris Coulson
-
Fix an intermittent test failure
- 1137. By Chris Coulson
-
Ensure we have a WebScopedMicrot
askSuppression instance on the stack when we call in to V8 - 1138. By Chris Coulson
-
Add a basic editorconfig file - you can get editorconfig plugins for various editors from http://
editorconfig. org/. This avoids having to turn on support for modelines, which is disabled in some editors (eg, vim) for security reasons
- 1139. By Chris Coulson
-
Some updates for the content script messaging:
- The payload is no longer converted to a string for the wire - instead, we use base::Value directly.
- As a consequence, on the renderer side, we now use content::V8ValueConvert er to convert the payload from v8::Value to base::Value. This means we can get rid of the hacky script we compile for each script context, just to call JSON.stringify.
- On the browser-side, we now convert from base::Value directly to QVariant using a custom converter. There is no longer a dependency on QJsonDocument.
- As a hardening measure, our converter on the browser side protects against excessive recursion that would otherwise exhaust stack space.
- The "args" parameter for script messages is deprecated - use "payload" instead. "args" never really made sense as it implies it's always a list, and is there as a consequence of this API being put together in haste to get unit tests working.
- Message payloads no longer have to be JSON arrays or objects - they can be any primitive that can be represented in JSON.
- The script message dispatcher on the browser side is no longer a BrowserMessageFilter running on the IO thread, but instead a WebContentsObse rver. We can do that now since it has an API to expose the source RenderFrameHost. - 1140. By Chris Coulson
-
Use the preferred allow() method for the geolocation permission tests (we still retain one test for the deprecated accept() method though)
- 1141. By Chris Coulson
-
Store TestApiHost in TestWebView, keyed by WebFrame
- 1142. By Chris Coulson
-
Add TestUtils.waitFor, so that we can stop duplicating the same function for tests that don't use TestWebView
- 1143. By Chris Coulson
-
Bump depot_tools to c1ae89ecd635abf
ea2d94e5b49c7d9 2f49f28f22 - 1144. By Chris Coulson
-
Improve script messaging tests
- 1145. By Chris Coulson
-
LP: #1466208
- 1146. By Chris Coulson
-
Remove a spurious console.log
- 1147. By Chris Coulson
-
Correctly detect when we are running on Mir/Mesa
- 1148. By Chris Coulson
-
Assume that the display is already initialized
- 1149. By Chris Coulson
-
Bump Chromium rev to 45.0.2438.3
- 1150. By Chris Coulson
-
Add WebContext.
userAgentOverri des API, which is a replacement for WebContext. userAgentOverri deDelegate. The new API allows applications to provide a list of regular expressions and user agent overrides as opposed to providing a JS worker that we call in to to ask for a user agent string. This allows us to stop relying on synchronous IPC to the browser - 1151. By Chris Coulson
-
We can actually lazyily create UserAgentSettings. RenderProcessIn
itializer will create it when the first render process starts anyway - 1152. By Alexandre Abreu
-
Fixes
Alexandre Abreu (abreu-alexandre) wrote : | # |
All comments have been addressed
Chris Coulson (chrisccoulson) : | # |
Preview Diff
1 | === modified file 'qt/core/browser/oxide_qt_web_context.cc' | |||
2 | --- qt/core/browser/oxide_qt_web_context.cc 2015-07-01 09:56:23 +0000 | |||
3 | +++ qt/core/browser/oxide_qt_web_context.cc 2015-07-02 14:03:46 +0000 | |||
4 | @@ -144,9 +144,15 @@ | |||
5 | 144 | session_cookie_mode(content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES), | 144 | session_cookie_mode(content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES), |
6 | 145 | popup_blocker_enabled(true), | 145 | popup_blocker_enabled(true), |
7 | 146 | devtools_enabled(false), | 146 | devtools_enabled(false), |
8 | 147 | <<<<<<< TREE | ||
9 | 147 | devtools_port(-1), | 148 | devtools_port(-1), |
10 | 148 | legacy_user_agent_override_enabled(false) {} | 149 | legacy_user_agent_override_enabled(false) {} |
11 | 149 | 150 | ||
12 | 151 | ======= | ||
13 | 152 | devtools_port(kDefaultDevtoolsPort), | ||
14 | 153 | legacy_user_agent_override_enabled(false), | ||
15 | 154 | do_not_track(false) {} | ||
16 | 155 | >>>>>>> MERGE-SOURCE | ||
17 | 150 | std::string product; | 156 | std::string product; |
18 | 151 | std::string user_agent; | 157 | std::string user_agent; |
19 | 152 | base::FilePath data_path; | 158 | base::FilePath data_path; |
20 | @@ -164,6 +170,7 @@ | |||
21 | 164 | std::string default_video_capture_device_id; | 170 | std::string default_video_capture_device_id; |
22 | 165 | std::vector<UserAgentSettings::UserAgentOverride> user_agent_overrides; | 171 | std::vector<UserAgentSettings::UserAgentOverride> user_agent_overrides; |
23 | 166 | bool legacy_user_agent_override_enabled; | 172 | bool legacy_user_agent_override_enabled; |
24 | 173 | bool do_not_track; | ||
25 | 167 | }; | 174 | }; |
26 | 168 | 175 | ||
27 | 169 | class SetCookiesContext : public base::RefCounted<SetCookiesContext> { | 176 | class SetCookiesContext : public base::RefCounted<SetCookiesContext> { |
28 | @@ -550,6 +557,7 @@ | |||
29 | 550 | 557 | ||
30 | 551 | context_->SetCookiePolicy(construct_props_->cookie_policy); | 558 | context_->SetCookiePolicy(construct_props_->cookie_policy); |
31 | 552 | context_->SetIsPopupBlockerEnabled(construct_props_->popup_blocker_enabled); | 559 | context_->SetIsPopupBlockerEnabled(construct_props_->popup_blocker_enabled); |
32 | 560 | context_->SetDoNotTrack(construct_props_->do_not_track); | ||
33 | 553 | 561 | ||
34 | 554 | MediaCaptureDevicesContext* dc = | 562 | MediaCaptureDevicesContext* dc = |
35 | 555 | MediaCaptureDevicesContext::Get(context_.get()); | 563 | MediaCaptureDevicesContext::Get(context_.get()); |
36 | @@ -1074,5 +1082,21 @@ | |||
37 | 1074 | client_->DefaultVideoCaptureDeviceChanged(); | 1082 | client_->DefaultVideoCaptureDeviceChanged(); |
38 | 1075 | } | 1083 | } |
39 | 1076 | 1084 | ||
40 | 1085 | bool WebContext::doNotTrack() const { | ||
41 | 1086 | if (IsInitialized()) { | ||
42 | 1087 | return context_->GetDoNotTrack(); | ||
43 | 1088 | } | ||
44 | 1089 | |||
45 | 1090 | return construct_props_->do_not_track; | ||
46 | 1091 | } | ||
47 | 1092 | |||
48 | 1093 | void WebContext::setDoNotTrack(bool dnt) { | ||
49 | 1094 | if (IsInitialized()) { | ||
50 | 1095 | context_->SetDoNotTrack(dnt); | ||
51 | 1096 | } else { | ||
52 | 1097 | construct_props_->do_not_track = dnt; | ||
53 | 1098 | } | ||
54 | 1099 | } | ||
55 | 1100 | |||
56 | 1077 | } // namespace qt | 1101 | } // namespace qt |
57 | 1078 | } // namespace oxide | 1102 | } // namespace oxide |
58 | 1079 | 1103 | ||
59 | === modified file 'qt/core/browser/oxide_qt_web_context.h' | |||
60 | --- qt/core/browser/oxide_qt_web_context.h 2015-06-29 17:52:40 +0000 | |||
61 | +++ qt/core/browser/oxide_qt_web_context.h 2015-07-02 14:03:46 +0000 | |||
62 | @@ -148,6 +148,9 @@ | |||
63 | 148 | void clearTemporarySavedPermissionStatuses() override; | 148 | void clearTemporarySavedPermissionStatuses() override; |
64 | 149 | void setLegacyUserAgentOverrideEnabled(bool enabled) override; | 149 | void setLegacyUserAgentOverrideEnabled(bool enabled) override; |
65 | 150 | 150 | ||
66 | 151 | bool doNotTrack() const override; | ||
67 | 152 | void setDoNotTrack(bool dnt) override; | ||
68 | 153 | |||
69 | 151 | // oxide::MediaCaptureDevicesContextClient implementation | 154 | // oxide::MediaCaptureDevicesContextClient implementation |
70 | 152 | void DefaultAudioDeviceChanged() override; | 155 | void DefaultAudioDeviceChanged() override; |
71 | 153 | void DefaultVideoDeviceChanged() override; | 156 | void DefaultVideoDeviceChanged() override; |
72 | 154 | 157 | ||
73 | === modified file 'qt/core/glue/oxide_qt_web_context_proxy.h' | |||
74 | --- qt/core/glue/oxide_qt_web_context_proxy.h 2015-07-01 09:56:23 +0000 | |||
75 | +++ qt/core/glue/oxide_qt_web_context_proxy.h 2015-07-02 14:03:46 +0000 | |||
76 | @@ -138,6 +138,9 @@ | |||
77 | 138 | virtual void clearTemporarySavedPermissionStatuses() = 0; | 138 | virtual void clearTemporarySavedPermissionStatuses() = 0; |
78 | 139 | 139 | ||
79 | 140 | virtual void setLegacyUserAgentOverrideEnabled(bool enabled) = 0; | 140 | virtual void setLegacyUserAgentOverrideEnabled(bool enabled) = 0; |
80 | 141 | |||
81 | 142 | virtual bool doNotTrack() const = 0; | ||
82 | 143 | virtual void setDoNotTrack(bool dnt) = 0; | ||
83 | 141 | }; | 144 | }; |
84 | 142 | 145 | ||
85 | 143 | } // namespace qt | 146 | } // namespace qt |
86 | 144 | 147 | ||
87 | === modified file 'qt/quick/api/oxideqquickwebcontext.cc' | |||
88 | --- qt/quick/api/oxideqquickwebcontext.cc 2015-07-01 09:56:23 +0000 | |||
89 | +++ qt/quick/api/oxideqquickwebcontext.cc 2015-07-02 14:03:46 +0000 | |||
90 | @@ -1119,6 +1119,7 @@ | |||
91 | 1119 | // if the actual device is removed | 1119 | // if the actual device is removed |
92 | 1120 | } | 1120 | } |
93 | 1121 | 1121 | ||
94 | 1122 | |||
95 | 1122 | QVariantList OxideQQuickWebContext::userAgentOverrides() const { | 1123 | QVariantList OxideQQuickWebContext::userAgentOverrides() const { |
96 | 1123 | Q_D(const OxideQQuickWebContext); | 1124 | Q_D(const OxideQQuickWebContext); |
97 | 1124 | 1125 | ||
98 | @@ -1133,6 +1134,12 @@ | |||
99 | 1133 | return rv; | 1134 | return rv; |
100 | 1134 | } | 1135 | } |
101 | 1135 | 1136 | ||
102 | 1137 | bool OxideQQuickWebContext::doNotTrack() const { | ||
103 | 1138 | Q_D(const OxideQQuickWebContext); | ||
104 | 1139 | |||
105 | 1140 | return d->proxy()->doNotTrack(); | ||
106 | 1141 | } | ||
107 | 1142 | |||
108 | 1136 | void OxideQQuickWebContext::setUserAgentOverrides( | 1143 | void OxideQQuickWebContext::setUserAgentOverrides( |
109 | 1137 | const QVariantList& overrides) { | 1144 | const QVariantList& overrides) { |
110 | 1138 | Q_D(OxideQQuickWebContext); | 1145 | Q_D(OxideQQuickWebContext); |
111 | @@ -1160,4 +1167,16 @@ | |||
112 | 1160 | emit userAgentOverridesChanged(); | 1167 | emit userAgentOverridesChanged(); |
113 | 1161 | } | 1168 | } |
114 | 1162 | 1169 | ||
115 | 1170 | void OxideQQuickWebContext::setDoNotTrack(bool dnt) { | ||
116 | 1171 | Q_D(OxideQQuickWebContext); | ||
117 | 1172 | |||
118 | 1173 | if (doNotTrack() == dnt) { | ||
119 | 1174 | return; | ||
120 | 1175 | } | ||
121 | 1176 | |||
122 | 1177 | d->proxy()->setDoNotTrack(dnt); | ||
123 | 1178 | |||
124 | 1179 | emit doNotTrackEnabledChanged(); | ||
125 | 1180 | } | ||
126 | 1181 | |||
127 | 1163 | #include "moc_oxideqquickwebcontext_p.cpp" | 1182 | #include "moc_oxideqquickwebcontext_p.cpp" |
128 | 1164 | 1183 | ||
129 | === modified file 'qt/quick/api/oxideqquickwebcontext_p.h' | |||
130 | --- qt/quick/api/oxideqquickwebcontext_p.h 2015-06-29 16:47:46 +0000 | |||
131 | +++ qt/quick/api/oxideqquickwebcontext_p.h 2015-07-02 14:03:46 +0000 | |||
132 | @@ -73,6 +73,8 @@ | |||
133 | 73 | 73 | ||
134 | 74 | Q_PROPERTY(QVariantList userAgentOverrides READ userAgentOverrides WRITE setUserAgentOverrides NOTIFY userAgentOverridesChanged REVISION 3) | 74 | Q_PROPERTY(QVariantList userAgentOverrides READ userAgentOverrides WRITE setUserAgentOverrides NOTIFY userAgentOverridesChanged REVISION 3) |
135 | 75 | 75 | ||
136 | 76 | Q_PROPERTY(bool doNotTrackEnabled READ doNotTrack WRITE setDoNotTrack NOTIFY doNotTrackEnabledChanged REVISION 3) | ||
137 | 77 | |||
138 | 76 | Q_ENUMS(CookiePolicy) | 78 | Q_ENUMS(CookiePolicy) |
139 | 77 | Q_ENUMS(SessionCookieMode) | 79 | Q_ENUMS(SessionCookieMode) |
140 | 78 | 80 | ||
141 | @@ -169,6 +171,9 @@ | |||
142 | 169 | QVariantList userAgentOverrides() const; | 171 | QVariantList userAgentOverrides() const; |
143 | 170 | void setUserAgentOverrides(const QVariantList& overrides); | 172 | void setUserAgentOverrides(const QVariantList& overrides); |
144 | 171 | 173 | ||
145 | 174 | bool doNotTrack() const; | ||
146 | 175 | void setDoNotTrack(bool dnt); | ||
147 | 176 | |||
148 | 172 | Q_SIGNALS: | 177 | Q_SIGNALS: |
149 | 173 | void productChanged(); | 178 | void productChanged(); |
150 | 174 | void userAgentChanged(); | 179 | void userAgentChanged(); |
151 | @@ -191,6 +196,7 @@ | |||
152 | 191 | Q_REVISION(3) void defaultAudioCaptureDeviceIdChanged(); | 196 | Q_REVISION(3) void defaultAudioCaptureDeviceIdChanged(); |
153 | 192 | Q_REVISION(3) void defaultVideoCaptureDeviceIdChanged(); | 197 | Q_REVISION(3) void defaultVideoCaptureDeviceIdChanged(); |
154 | 193 | Q_REVISION(3) void userAgentOverridesChanged(); | 198 | Q_REVISION(3) void userAgentOverridesChanged(); |
155 | 199 | Q_REVISION(3) void doNotTrackEnabledChanged(); | ||
156 | 194 | 200 | ||
157 | 195 | private: | 201 | private: |
158 | 196 | Q_PRIVATE_SLOT(d_func(), void userScriptUpdated()); | 202 | Q_PRIVATE_SLOT(d_func(), void userScriptUpdated()); |
159 | 197 | 203 | ||
160 | === added file 'qt/tests/qmltests/api/tst_WebContext_doNotTrack.py' | |||
161 | --- qt/tests/qmltests/api/tst_WebContext_doNotTrack.py 1970-01-01 00:00:00 +0000 | |||
162 | +++ qt/tests/qmltests/api/tst_WebContext_doNotTrack.py 2015-07-02 14:03:46 +0000 | |||
163 | @@ -0,0 +1,18 @@ | |||
164 | 1 | from cStringIO import StringIO | ||
165 | 2 | |||
166 | 3 | def handler(request): | ||
167 | 4 | request.send_response(200) | ||
168 | 5 | request.send_header("Content-type", "text/html") | ||
169 | 6 | |||
170 | 7 | html = StringIO() | ||
171 | 8 | for header in request.headers: | ||
172 | 9 | print header | ||
173 | 10 | html.write( | ||
174 | 11 | "<html><body><div id='dnt'>{}</div></body></html>".format( | ||
175 | 12 | "1" if 'DNT' in request.headers and request.headers['DNT'] == '1' else "0")) | ||
176 | 13 | |||
177 | 14 | request.send_header("Content-Length", html.tell()) | ||
178 | 15 | request.send_header("Cache-Control", "no-cache") | ||
179 | 16 | request.end_headers() | ||
180 | 17 | |||
181 | 18 | request.wfile.write(html.getvalue()) | ||
182 | 0 | 19 | ||
183 | === added file 'qt/tests/qmltests/api/tst_WebContext_doNotTrack.qml' | |||
184 | --- qt/tests/qmltests/api/tst_WebContext_doNotTrack.qml 1970-01-01 00:00:00 +0000 | |||
185 | +++ qt/tests/qmltests/api/tst_WebContext_doNotTrack.qml 2015-07-02 14:03:46 +0000 | |||
186 | @@ -0,0 +1,74 @@ | |||
187 | 1 | import QtQuick 2.0 | ||
188 | 2 | import QtTest 1.0 | ||
189 | 3 | import com.canonical.Oxide 1.9 | ||
190 | 4 | import com.canonical.Oxide.Testing 1.0 | ||
191 | 5 | |||
192 | 6 | TestWebView { | ||
193 | 7 | id: webView | ||
194 | 8 | |||
195 | 9 | focus: true | ||
196 | 10 | |||
197 | 11 | width: 200 | ||
198 | 12 | height: 200 | ||
199 | 13 | |||
200 | 14 | SignalSpy { | ||
201 | 15 | id: dntSignalSpy | ||
202 | 16 | target: webView.context | ||
203 | 17 | signalName: "doNotTrackEnabledChanged" | ||
204 | 18 | } | ||
205 | 19 | |||
206 | 20 | TestCase { | ||
207 | 21 | id: test | ||
208 | 22 | name: "WebContext_doNotTrack" | ||
209 | 23 | when: windowShown | ||
210 | 24 | |||
211 | 25 | function init() { | ||
212 | 26 | dntSignalSpy.clear(); | ||
213 | 27 | } | ||
214 | 28 | |||
215 | 29 | function test_dnt_data() { | ||
216 | 30 | return [ | ||
217 | 31 | {expectedHeaderDnt: "0", expectedNavigatorDnt: "0"}, /* default */ | ||
218 | 32 | {expectedHeaderDnt: "0", expectedNavigatorDnt: "0", dnt: false}, | ||
219 | 33 | {expectedHeaderDnt: "1", expectedNavigatorDnt: "1", dnt: true} | ||
220 | 34 | ] | ||
221 | 35 | } | ||
222 | 36 | |||
223 | 37 | function test_dnt(data) { | ||
224 | 38 | if (data.dnt != null) { | ||
225 | 39 | webView.context.doNotTrackEnabled = data.dnt | ||
226 | 40 | } | ||
227 | 41 | |||
228 | 42 | webView.url = "http://testsuite/tst_WebContext_doNotTrack.py"; | ||
229 | 43 | verify(webView.waitForLoadSucceeded(), | ||
230 | 44 | "Timed out waiting for successful load"); | ||
231 | 45 | |||
232 | 46 | compare(webView.getTestApi().evaluateCode( | ||
233 | 47 | "document.querySelector(\"#dnt\").innerHTML"), | ||
234 | 48 | data.expectedHeaderDnt); | ||
235 | 49 | compare(webView.getTestApi().evaluateCode( | ||
236 | 50 | "window.navigator.doNotTrack && window.navigator.doNotTrack === '1' ? '1' : '0'"), | ||
237 | 51 | data.expectedNavigatorDnt); | ||
238 | 52 | } | ||
239 | 53 | |||
240 | 54 | function test_dntNavigatorUpdate(data) { | ||
241 | 55 | webView.context.doNotTrackEnabled = false | ||
242 | 56 | |||
243 | 57 | webView.url = "http://testsuite/tst_WebContext_doNotTrack.py"; | ||
244 | 58 | verify(webView.waitForLoadSucceeded(), | ||
245 | 59 | "Timed out waiting for successful load"); | ||
246 | 60 | |||
247 | 61 | compare(webView.getTestApi().evaluateCode( | ||
248 | 62 | "window.navigator.doNotTrack && window.navigator.doNotTrack === '1' ? '1' : '0'"), | ||
249 | 63 | "0"); | ||
250 | 64 | |||
251 | 65 | webView.context.doNotTrackEnabled = true; | ||
252 | 66 | |||
253 | 67 | compare(webView.getTestApi().evaluateCode( | ||
254 | 68 | "window.navigator.doNotTrack && window.navigator.doNotTrack === '1' ? '1' : '0'"), | ||
255 | 69 | "1"); | ||
256 | 70 | |||
257 | 71 | compare(dntSignalSpy.count, 2, "Should have had 1 doNotTrackEnabledChanged signal"); | ||
258 | 72 | } | ||
259 | 73 | } | ||
260 | 74 | } | ||
261 | 0 | 75 | ||
262 | === modified file 'shared/browser/oxide_browser_context.cc' | |||
263 | --- shared/browser/oxide_browser_context.cc 2015-07-01 12:25:41 +0000 | |||
264 | +++ shared/browser/oxide_browser_context.cc 2015-07-02 14:03:46 +0000 | |||
265 | @@ -191,7 +191,8 @@ | |||
266 | 191 | session_cookie_mode(params.session_cookie_mode), | 191 | session_cookie_mode(params.session_cookie_mode), |
267 | 192 | popup_blocker_enabled(true), | 192 | popup_blocker_enabled(true), |
268 | 193 | host_mapping_rules(params.host_mapping_rules), | 193 | host_mapping_rules(params.host_mapping_rules), |
270 | 194 | user_agent_settings(new UserAgentSettingsIOData(context)) {} | 194 | user_agent_settings(new UserAgentSettingsIOData(context)), |
271 | 195 | do_not_track(false) {} | ||
272 | 195 | 196 | ||
273 | 196 | mutable base::Lock lock; | 197 | mutable base::Lock lock; |
274 | 197 | 198 | ||
275 | @@ -207,6 +208,8 @@ | |||
276 | 207 | 208 | ||
277 | 208 | scoped_ptr<UserAgentSettingsIOData> user_agent_settings; | 209 | scoped_ptr<UserAgentSettingsIOData> user_agent_settings; |
278 | 209 | 210 | ||
279 | 211 | bool do_not_track; | ||
280 | 212 | |||
281 | 210 | scoped_refptr<BrowserContextDelegate> delegate; | 213 | scoped_refptr<BrowserContextDelegate> delegate; |
282 | 211 | }; | 214 | }; |
283 | 212 | 215 | ||
284 | @@ -343,6 +346,12 @@ | |||
285 | 343 | return max_cache_size_hint; | 346 | return max_cache_size_hint; |
286 | 344 | } | 347 | } |
287 | 345 | 348 | ||
288 | 349 | bool BrowserContextIOData::GetDoNotTrack() const { | ||
289 | 350 | const BrowserContextSharedIOData& data = GetSharedData(); | ||
290 | 351 | base::AutoLock lock(data.lock); | ||
291 | 352 | return data.do_not_track; | ||
292 | 353 | } | ||
293 | 354 | |||
294 | 346 | URLRequestContext* BrowserContextIOData::CreateMainRequestContext( | 355 | URLRequestContext* BrowserContextIOData::CreateMainRequestContext( |
295 | 347 | content::ProtocolHandlerMap& protocol_handlers, | 356 | content::ProtocolHandlerMap& protocol_handlers, |
296 | 348 | content::URLRequestInterceptorScopedVector request_interceptors) { | 357 | content::URLRequestInterceptorScopedVector request_interceptors) { |
297 | @@ -869,10 +878,33 @@ | |||
298 | 869 | return io_data()->cookie_store_; | 878 | return io_data()->cookie_store_; |
299 | 870 | } | 879 | } |
300 | 871 | 880 | ||
301 | 881 | |||
302 | 872 | TemporarySavedPermissionContext* | 882 | TemporarySavedPermissionContext* |
303 | 873 | BrowserContext::GetTemporarySavedPermissionContext() const { | 883 | BrowserContext::GetTemporarySavedPermissionContext() const { |
304 | 874 | DCHECK(CalledOnValidThread()); | 884 | DCHECK(CalledOnValidThread()); |
305 | 875 | return io_data()->GetTemporarySavedPermissionContext(); | 885 | return io_data()->GetTemporarySavedPermissionContext(); |
306 | 876 | } | 886 | } |
307 | 877 | 887 | ||
308 | 888 | bool BrowserContext::GetDoNotTrack() const { | ||
309 | 889 | DCHECK(CalledOnValidThread()); | ||
310 | 890 | return io_data()->GetSharedData().do_not_track; | ||
311 | 891 | } | ||
312 | 892 | |||
313 | 893 | void BrowserContext::SetDoNotTrack(bool dnt) { | ||
314 | 894 | DCHECK(CalledOnValidThread()); | ||
315 | 895 | |||
316 | 896 | BrowserContextSharedIOData& data = io_data()->GetSharedData(); | ||
317 | 897 | base::AutoLock lock(data.lock); | ||
318 | 898 | data.do_not_track = dnt; | ||
319 | 899 | |||
320 | 900 | FOR_EACH_OBSERVER(BrowserContextObserver, | ||
321 | 901 | GetOriginalContext()->observers_, | ||
322 | 902 | NotifyDoNotTrackChanged()); | ||
323 | 903 | if (HasOffTheRecordContext()) { | ||
324 | 904 | FOR_EACH_OBSERVER(BrowserContextObserver, | ||
325 | 905 | GetOffTheRecordContext()->observers_, | ||
326 | 906 | NotifyDoNotTrackChanged()); | ||
327 | 907 | } | ||
328 | 908 | } | ||
329 | 909 | |||
330 | 878 | } // namespace oxide | 910 | } // namespace oxide |
331 | 879 | 911 | ||
332 | === modified file 'shared/browser/oxide_browser_context.h' | |||
333 | --- shared/browser/oxide_browser_context.h 2015-07-01 09:56:23 +0000 | |||
334 | +++ shared/browser/oxide_browser_context.h 2015-07-02 14:03:46 +0000 | |||
335 | @@ -84,6 +84,8 @@ | |||
336 | 84 | base::FilePath GetCachePath() const; | 84 | base::FilePath GetCachePath() const; |
337 | 85 | int GetMaxCacheSizeHint() const; | 85 | int GetMaxCacheSizeHint() const; |
338 | 86 | 86 | ||
339 | 87 | bool GetDoNotTrack() const; | ||
340 | 88 | |||
341 | 87 | virtual bool IsOffTheRecord() const = 0; | 89 | virtual bool IsOffTheRecord() const = 0; |
342 | 88 | 90 | ||
343 | 89 | URLRequestContext* CreateMainRequestContext( | 91 | URLRequestContext* CreateMainRequestContext( |
344 | @@ -208,6 +210,9 @@ | |||
345 | 208 | 210 | ||
346 | 209 | const std::vector<std::string>& GetHostMappingRules() const; | 211 | const std::vector<std::string>& GetHostMappingRules() const; |
347 | 210 | 212 | ||
348 | 213 | bool GetDoNotTrack() const; | ||
349 | 214 | void SetDoNotTrack(bool dnt); | ||
350 | 215 | |||
351 | 211 | // from content::BrowserContext | 216 | // from content::BrowserContext |
352 | 212 | content::ResourceContext* GetResourceContext() override; | 217 | content::ResourceContext* GetResourceContext() override; |
353 | 213 | 218 | ||
354 | 214 | 219 | ||
355 | === modified file 'shared/browser/oxide_browser_context_observer.h' | |||
356 | --- shared/browser/oxide_browser_context_observer.h 2014-06-02 15:06:30 +0000 | |||
357 | +++ shared/browser/oxide_browser_context_observer.h 2015-07-02 14:03:46 +0000 | |||
358 | @@ -30,6 +30,8 @@ | |||
359 | 30 | 30 | ||
360 | 31 | virtual void NotifyPopupBlockerEnabledChanged() {} | 31 | virtual void NotifyPopupBlockerEnabledChanged() {} |
361 | 32 | 32 | ||
362 | 33 | virtual void NotifyDoNotTrackChanged() {} | ||
363 | 34 | |||
364 | 33 | protected: | 35 | protected: |
365 | 34 | BrowserContextObserver(); | 36 | BrowserContextObserver(); |
366 | 35 | BrowserContextObserver(BrowserContext* context); | 37 | BrowserContextObserver(BrowserContext* context); |
367 | 36 | 38 | ||
368 | === modified file 'shared/browser/oxide_network_delegate.cc' | |||
369 | --- shared/browser/oxide_network_delegate.cc 2015-06-29 17:14:55 +0000 | |||
370 | +++ shared/browser/oxide_network_delegate.cc 2015-07-02 14:03:46 +0000 | |||
371 | @@ -26,6 +26,10 @@ | |||
372 | 26 | 26 | ||
373 | 27 | namespace oxide { | 27 | namespace oxide { |
374 | 28 | 28 | ||
375 | 29 | namespace { | ||
376 | 30 | const char kDoNotTrackHeaderName[] = "DNT"; | ||
377 | 31 | } | ||
378 | 32 | |||
379 | 29 | int NetworkDelegate::OnBeforeURLRequest( | 33 | int NetworkDelegate::OnBeforeURLRequest( |
380 | 30 | net::URLRequest* request, | 34 | net::URLRequest* request, |
381 | 31 | const net::CompletionCallback& callback, | 35 | const net::CompletionCallback& callback, |
382 | @@ -35,6 +39,12 @@ | |||
383 | 35 | return net::OK; | 39 | return net::OK; |
384 | 36 | } | 40 | } |
385 | 37 | 41 | ||
386 | 42 | bool do_not_track = context_->GetDoNotTrack(); | ||
387 | 43 | if (do_not_track) { | ||
388 | 44 | request->SetExtraRequestHeaderByName( | ||
389 | 45 | kDoNotTrackHeaderName, "1", true); | ||
390 | 46 | } | ||
391 | 47 | |||
392 | 38 | return delegate->OnBeforeURLRequest(request, callback, new_url); | 48 | return delegate->OnBeforeURLRequest(request, callback, new_url); |
393 | 39 | } | 49 | } |
394 | 40 | 50 | ||
395 | 41 | 51 | ||
396 | === modified file 'shared/browser/oxide_web_view_contents_helper.cc' | |||
397 | --- shared/browser/oxide_web_view_contents_helper.cc 2015-06-03 09:51:37 +0000 | |||
398 | +++ shared/browser/oxide_web_view_contents_helper.cc 2015-07-02 14:03:46 +0000 | |||
399 | @@ -59,6 +59,19 @@ | |||
400 | 59 | UpdateWebPreferences(); | 59 | UpdateWebPreferences(); |
401 | 60 | } | 60 | } |
402 | 61 | 61 | ||
403 | 62 | void WebViewContentsHelper::NotifyDoNotTrackChanged() { | ||
404 | 63 | content::RendererPreferences* renderer_prefs = | ||
405 | 64 | web_contents_->GetMutableRendererPrefs(); | ||
406 | 65 | renderer_prefs->enable_do_not_track = context_->GetDoNotTrack(); | ||
407 | 66 | |||
408 | 67 | // Send the new override string to the renderer. | ||
409 | 68 | content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | ||
410 | 69 | if (!rvh) { | ||
411 | 70 | return; | ||
412 | 71 | } | ||
413 | 72 | rvh->SyncRendererPrefs(); | ||
414 | 73 | } | ||
415 | 74 | |||
416 | 62 | WebViewContentsHelper::WebViewContentsHelper(content::WebContents* contents, | 75 | WebViewContentsHelper::WebViewContentsHelper(content::WebContents* contents, |
417 | 63 | content::WebContents* opener) | 76 | content::WebContents* opener) |
418 | 64 | : BrowserContextObserver( | 77 | : BrowserContextObserver( |
419 | @@ -73,6 +86,7 @@ | |||
420 | 73 | content::RendererPreferences* renderer_prefs = | 86 | content::RendererPreferences* renderer_prefs = |
421 | 74 | web_contents_->GetMutableRendererPrefs(); | 87 | web_contents_->GetMutableRendererPrefs(); |
422 | 75 | renderer_prefs->browser_handles_non_local_top_level_requests = true; | 88 | renderer_prefs->browser_handles_non_local_top_level_requests = true; |
423 | 89 | renderer_prefs->enable_do_not_track = context_->GetDoNotTrack(); | ||
424 | 76 | 90 | ||
425 | 77 | content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 91 | content::RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
426 | 78 | if (rvh) { | 92 | if (rvh) { |
427 | 79 | 93 | ||
428 | === modified file 'shared/browser/oxide_web_view_contents_helper.h' | |||
429 | --- shared/browser/oxide_web_view_contents_helper.h 2015-06-03 09:51:37 +0000 | |||
430 | +++ shared/browser/oxide_web_view_contents_helper.h 2015-07-02 14:03:46 +0000 | |||
431 | @@ -62,6 +62,7 @@ | |||
432 | 62 | 62 | ||
433 | 63 | // BrowserContextObserver implementation | 63 | // BrowserContextObserver implementation |
434 | 64 | void NotifyPopupBlockerEnabledChanged() final; | 64 | void NotifyPopupBlockerEnabledChanged() final; |
435 | 65 | void NotifyDoNotTrackChanged() final; | ||
436 | 65 | 66 | ||
437 | 66 | // WebPreferencesObserver implementation | 67 | // WebPreferencesObserver implementation |
438 | 67 | void WebPreferencesValueChanged() final; | 68 | void WebPreferencesValueChanged() final; |
Thanks, I've left some comments inline.
Also, the test is missing a few bits:
- It should verify that the default is off. navigator. doNotTrack if you change the setting without reloading the page? Does it update automatically? If it does, then that should be tested.
- It should check that the notify signal is emitted when you toggle it.
- What happens to window.