Merge lp:~uriboni/oxide/basic-authentication into lp:~oxide-developers/oxide/oxide.trunk
- basic-authentication
- Merge into oxide.trunk
Status: | Merged |
---|---|
Merged at revision: | 1152 |
Proposed branch: | lp:~uriboni/oxide/basic-authentication |
Merge into: | lp:~oxide-developers/oxide/oxide.trunk |
Diff against target: |
1029 lines (+714/-5) 23 files modified
qt/core/api/oxideqhttpauthenticationrequest.cc (+103/-0) qt/core/api/oxideqhttpauthenticationrequest.h (+64/-0) qt/core/api/oxideqhttpauthenticationrequest_p.h (+47/-0) qt/core/browser/oxide_qt_web_view.cc (+8/-0) qt/core/browser/oxide_qt_web_view.h (+3/-0) qt/core/core.gyp (+9/-0) qt/core/glue/oxide_qt_web_view_proxy_client.h (+4/-0) qt/qmlplugin/oxide_qml_plugin.cc (+5/-0) qt/quick/api/oxideqquickwebview.cc (+26/-0) qt/quick/api/oxideqquickwebview_p.h (+1/-0) qt/quick/api/oxideqquickwebview_p_p.h (+2/-0) qt/tests/qmltests/TestWebView.qml (+1/-1) qt/tests/qmltests/api/tst_httpAuthentication.py (+31/-0) qt/tests/qmltests/api/tst_httpAuthentication.qml (+142/-0) shared/browser/oxide_resource_dispatcher_host_delegate.cc (+14/-3) shared/browser/oxide_resource_dispatcher_host_delegate.h (+8/-0) shared/browser/oxide_resource_dispatcher_host_login_delegate.cc (+162/-0) shared/browser/oxide_resource_dispatcher_host_login_delegate.h (+65/-0) shared/browser/oxide_web_view.cc (+6/-1) shared/browser/oxide_web_view.h (+4/-0) shared/browser/oxide_web_view_client.cc (+3/-0) shared/browser/oxide_web_view_client.h (+4/-0) shared/shared.gyp (+2/-0) |
To merge this branch: | bzr merge lp:~uriboni/oxide/basic-authentication |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Coulson | Needs Fixing | ||
Olivier Tilloy (community) | Needs Fixing | ||
Review via email: mp+260922@code.launchpad.net |
Commit message
Implements basic authentication support
Description of the change
Implements basic authentication support.
- 1084. By Ugo Riboni
-
Fix the oxide version used in unit tests
- 1085. By Ugo Riboni
-
Simplify and fix unit tests
Olivier Tilloy (osomon) wrote : | # |
I’m seeing this really weird warning when running unit tests locally:
1: QWARN : qml-api-
I don’t see how WebView_
Olivier Tilloy (osomon) wrote : | # |
In qt/core/core.gyp, file paths should be kept sorted alphabetically.
Chris Coulson (chrisccoulson) wrote : | # |
Thanks for this - I've left some comments inline.
One general point - there's a mixture of 2-space and 4-space indentation. Please stick to 2-space (using 4-space only for wrapped lines). We try to adhere to the Chromium style guide on this - see http://
Also, what happens if the application doesn't connect a handler, or does connect one but allows the request object to be garbage collected before responding to it? Oxide should take the default action - ie, deny - but it doesn't look like that will happen here. Please take a look at how this is handled for permission requests, and there should also be a test case for this as well.
Chris Coulson (chrisccoulson) wrote : | # |
I've just added a couple more comments for things I missed
- 1086. By Ugo Riboni
-
Reorder alphabetically the gyp file
- 1087. By Ugo Riboni
-
Merge upstream changes
- 1088. By Ugo Riboni
-
Fix indentation
- 1089. By Ugo Riboni
-
Remove check on login_delegate as it can not be null
- 1090. By Ugo Riboni
-
Remove the cancellation callback when the QT class is destroyed, for safety
- 1091. By Ugo Riboni
-
Remove some useless code
- 1092. By Ugo Riboni
-
Rename *basicAuthentic
ation* to *httpAuthentica tion* since we are also handling digest auth - 1093. By Ugo Riboni
-
Mark some properties as constant since we only assign them at construction
- 1094. By Ugo Riboni
-
Make private and hidden the constructor of OxideQHttpAuthe
nticationReques t since it can only be created from within the webview - 1095. By Ugo Riboni
-
Invalidate the pointer to the delegate when the request is cancelled, as it will be deleted by chromium immediately after. Check that we have a valid pointer before calling through it elsewhere.
- 1096. By Ugo Riboni
-
Fix some indentation
- 1097. By Ugo Riboni
-
Rename tests
- 1098. By Ugo Riboni
-
Remove non-useful null pointer check
- 1099. By Ugo Riboni
-
More properly ensure that data is accessed from the right thread
- 1100. By Ugo Riboni
-
Clear the callback in the right destructor
- 1101. By Ugo Riboni
-
Move ResourceDispatc
herHostLoginDel egate to is own source files, and remove another case of accessing the UrlRequest outside of the IO thread. - 1102. By Ugo Riboni
-
Remove Qt code that for some bizarre reason ended up in oxide and still compiles
- 1103. By Ugo Riboni
-
Simplify the code to access the WebView
- 1104. By Ugo Riboni
-
Deny the authentication if the request object is ignored and gets destroyed. Add test for this case.
Chris Coulson (chrisccoulson) wrote : | # |
I've added some more comments inline
Olivier Tilloy (osomon) wrote : | # |
Preview Diff
1 | === added file 'qt/core/api/oxideqhttpauthenticationrequest.cc' |
2 | --- qt/core/api/oxideqhttpauthenticationrequest.cc 1970-01-01 00:00:00 +0000 |
3 | +++ qt/core/api/oxideqhttpauthenticationrequest.cc 2015-06-18 16:37:15 +0000 |
4 | @@ -0,0 +1,103 @@ |
5 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
6 | +// Copyright (C) 2015 Canonical Ltd. |
7 | + |
8 | +// This library is free software; you can redistribute it and/or |
9 | +// modify it under the terms of the GNU Lesser General Public |
10 | +// License as published by the Free Software Foundation; either |
11 | +// version 2.1 of the License, or (at your option) any later version. |
12 | + |
13 | +// This library is distributed in the hope that it will be useful, |
14 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | +// Lesser General Public License for more details. |
17 | + |
18 | +// You should have received a copy of the GNU Lesser General Public |
19 | +// License along with this library; if not, write to the Free Software |
20 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 | + |
22 | +#include "base/bind.h" |
23 | +#include "base/callback.h" |
24 | + |
25 | +#include "shared/browser/oxide_resource_dispatcher_host_login_delegate.h" |
26 | +#include "qt/core/browser/oxide_qt_web_view.h" |
27 | + |
28 | +#include "oxideqhttpauthenticationrequest.h" |
29 | +#include "oxideqhttpauthenticationrequest_p.h" |
30 | + |
31 | +OxideQHttpAuthenticationRequestPrivate::OxideQHttpAuthenticationRequestPrivate( |
32 | + oxide::ResourceDispatcherHostLoginDelegate* login_delegate) |
33 | + : q_ptr(nullptr), |
34 | + login_delegate_(login_delegate) { |
35 | + // Use of base::Unretained is safe here because we clear the callback |
36 | + // in the destructor, so that it can not called back on a deleted object |
37 | + login_delegate->SetCancelledCallback( |
38 | + base::Bind(&OxideQHttpAuthenticationRequestPrivate::RequestCancelled, |
39 | + base::Unretained(this))); |
40 | +} |
41 | + |
42 | +OxideQHttpAuthenticationRequestPrivate::~OxideQHttpAuthenticationRequestPrivate() { |
43 | + if (login_delegate_) { |
44 | + login_delegate_->SetCancelledCallback(base::Closure()); |
45 | + |
46 | + // Always deny the request when we are being destroyed, as it should be the |
47 | + // default action in case the client ignores this request and it gets |
48 | + // garbage collected. |
49 | + // In case an action has already been taken, this is a essentially a no-op. |
50 | + login_delegate_->Deny(); |
51 | + } |
52 | +} |
53 | + |
54 | +void OxideQHttpAuthenticationRequestPrivate::RequestCancelled() { |
55 | + Q_Q(OxideQHttpAuthenticationRequest); |
56 | + |
57 | + login_delegate_ = nullptr; |
58 | + q->cancelled(); |
59 | +} |
60 | + |
61 | +OxideQHttpAuthenticationRequest::OxideQHttpAuthenticationRequest( |
62 | + oxide::ResourceDispatcherHostLoginDelegate* login_delegate) |
63 | + : d_ptr(new OxideQHttpAuthenticationRequestPrivate(login_delegate)) { |
64 | + Q_D(OxideQHttpAuthenticationRequest); |
65 | + d->q_ptr = this; |
66 | +} |
67 | + |
68 | +OxideQHttpAuthenticationRequest::~OxideQHttpAuthenticationRequest() {} |
69 | + |
70 | +QString OxideQHttpAuthenticationRequest::host() const { |
71 | + Q_D(const OxideQHttpAuthenticationRequest); |
72 | + |
73 | + if (d->login_delegate_) { |
74 | + return QString::fromStdString(d->login_delegate_->Host()); |
75 | + } else { |
76 | + return QString(); |
77 | + } |
78 | +} |
79 | + |
80 | +QString OxideQHttpAuthenticationRequest::realm() const { |
81 | + Q_D(const OxideQHttpAuthenticationRequest); |
82 | + |
83 | + if (d->login_delegate_) { |
84 | + return QString::fromStdString(d->login_delegate_->Realm()); |
85 | + } else { |
86 | + return QString(); |
87 | + } |
88 | +} |
89 | + |
90 | +void OxideQHttpAuthenticationRequest::deny() { |
91 | + Q_D(OxideQHttpAuthenticationRequest); |
92 | + |
93 | + if (d->login_delegate_) { |
94 | + d->login_delegate_->Deny(); |
95 | + d->login_delegate_ = nullptr; |
96 | + } |
97 | +} |
98 | + |
99 | +void OxideQHttpAuthenticationRequest::allow(const QString &username, |
100 | + const QString &password) { |
101 | + Q_D(OxideQHttpAuthenticationRequest); |
102 | + |
103 | + if (d->login_delegate_) { |
104 | + d->login_delegate_->Allow(username.toStdString(), password.toStdString()); |
105 | + d->login_delegate_ = nullptr; |
106 | + } |
107 | +} |
108 | |
109 | === added file 'qt/core/api/oxideqhttpauthenticationrequest.h' |
110 | --- qt/core/api/oxideqhttpauthenticationrequest.h 1970-01-01 00:00:00 +0000 |
111 | +++ qt/core/api/oxideqhttpauthenticationrequest.h 2015-06-18 16:37:15 +0000 |
112 | @@ -0,0 +1,64 @@ |
113 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
114 | +// Copyright (C) 2015 Canonical Ltd. |
115 | + |
116 | +// This library is free software; you can redistribute it and/or |
117 | +// modify it under the terms of the GNU Lesser General Public |
118 | +// License as published by the Free Software Foundation; either |
119 | +// version 2.1 of the License, or (at your option) any later version. |
120 | + |
121 | +// This library is distributed in the hope that it will be useful, |
122 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
123 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
124 | +// Lesser General Public License for more details. |
125 | + |
126 | +// You should have received a copy of the GNU Lesser General Public |
127 | +// License along with this library; if not, write to the Free Software |
128 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
129 | + |
130 | +#ifndef OXIDE_Q_HTTP_AUTHENTICATION_REQUEST |
131 | +#define OXIDE_Q_HTTP_AUTHENTICATION_REQUEST |
132 | + |
133 | +#include <QObject> |
134 | +#include <QScopedPointer> |
135 | +#include <QString> |
136 | +#include <QtGlobal> |
137 | + |
138 | +class OxideQHttpAuthenticationRequestPrivate; |
139 | + |
140 | +namespace oxide { |
141 | + namespace qt { |
142 | + class WebView; |
143 | + } |
144 | + class ResourceDispatcherHostLoginDelegate; |
145 | +} |
146 | + |
147 | +class Q_DECL_EXPORT OxideQHttpAuthenticationRequest : public QObject { |
148 | + Q_OBJECT |
149 | + Q_PROPERTY(QString host READ host CONSTANT) |
150 | + Q_PROPERTY(QString realm READ realm CONSTANT) |
151 | + |
152 | + Q_DECLARE_PRIVATE(OxideQHttpAuthenticationRequest) |
153 | + Q_DISABLE_COPY(OxideQHttpAuthenticationRequest) |
154 | + |
155 | + public: |
156 | + ~OxideQHttpAuthenticationRequest(); |
157 | + |
158 | + QString host() const; |
159 | + QString realm() const; |
160 | + |
161 | + Q_INVOKABLE void allow(const QString& username, const QString& password); |
162 | + Q_INVOKABLE void deny(); |
163 | + |
164 | + Q_SIGNALS: |
165 | + void cancelled() const; |
166 | + |
167 | + private: |
168 | + Q_DECL_HIDDEN OxideQHttpAuthenticationRequest( |
169 | + oxide::ResourceDispatcherHostLoginDelegate* login_delegate); |
170 | + |
171 | + QScopedPointer<OxideQHttpAuthenticationRequestPrivate> d_ptr; |
172 | + |
173 | + friend class oxide::qt::WebView; |
174 | +}; |
175 | + |
176 | +#endif // OXIDE_Q_HTTP_AUTHENTICATION_REQUEST |
177 | |
178 | === added file 'qt/core/api/oxideqhttpauthenticationrequest_p.h' |
179 | --- qt/core/api/oxideqhttpauthenticationrequest_p.h 1970-01-01 00:00:00 +0000 |
180 | +++ qt/core/api/oxideqhttpauthenticationrequest_p.h 2015-06-18 16:37:15 +0000 |
181 | @@ -0,0 +1,47 @@ |
182 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
183 | +// Copyright (C) 2015 Canonical Ltd. |
184 | + |
185 | +// This library is free software; you can redistribute it and/or |
186 | +// modify it under the terms of the GNU Lesser General Public |
187 | +// License as published by the Free Software Foundation; either |
188 | +// version 2.1 of the License, or (at your option) any later version. |
189 | + |
190 | +// This library is distributed in the hope that it will be useful, |
191 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
192 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
193 | +// Lesser General Public License for more details. |
194 | + |
195 | +// You should have received a copy of the GNU Lesser General Public |
196 | +// License along with this library; if not, write to the Free Software |
197 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
198 | + |
199 | +#ifndef _OXIDE_QT_CORE_API_HTTP_AUTHENTICATION_REQUEST_P_H_ |
200 | +#define _OXIDE_QT_CORE_API_HTTP_AUTHENTICATION_REQUEST_P_H_ |
201 | + |
202 | +#include <QtGlobal> |
203 | +#include <QString> |
204 | + |
205 | +namespace oxide { |
206 | + class ResourceDispatcherHostLoginDelegate; |
207 | +} |
208 | + |
209 | +class OxideQHttpAuthenticationRequest; |
210 | + |
211 | +class OxideQHttpAuthenticationRequestPrivate { |
212 | + Q_DECLARE_PUBLIC(OxideQHttpAuthenticationRequest) |
213 | + |
214 | + public: |
215 | + virtual ~OxideQHttpAuthenticationRequestPrivate(); |
216 | + |
217 | + private: |
218 | + OxideQHttpAuthenticationRequestPrivate( |
219 | + oxide::ResourceDispatcherHostLoginDelegate* login_delegate); |
220 | + void RequestCancelled(); |
221 | + |
222 | + OxideQHttpAuthenticationRequest* q_ptr; |
223 | + QString realm_; |
224 | + oxide::ResourceDispatcherHostLoginDelegate* login_delegate_; |
225 | +}; |
226 | + |
227 | +#endif // _OXIDE_QT_CORE_API_HTTP_AUTHENTICATION_REQUEST_P_H_ |
228 | + |
229 | |
230 | === modified file 'qt/core/browser/oxide_qt_web_view.cc' |
231 | --- qt/core/browser/oxide_qt_web_view.cc 2015-06-04 17:11:01 +0000 |
232 | +++ qt/core/browser/oxide_qt_web_view.cc 2015-06-18 16:37:15 +0000 |
233 | @@ -58,6 +58,7 @@ |
234 | |
235 | #include "qt/core/api/oxideqdownloadrequest.h" |
236 | #include "qt/core/api/oxideqloadevent.h" |
237 | +#include "qt/core/api/oxideqhttpauthenticationrequest.h" |
238 | #include "qt/core/api/oxideqnavigationrequest.h" |
239 | #include "qt/core/api/oxideqnewviewrequest.h" |
240 | #include "qt/core/api/oxideqnewviewrequest_p.h" |
241 | @@ -744,6 +745,13 @@ |
242 | client_->DownloadRequested(&download_request); |
243 | } |
244 | |
245 | +void WebView::HttpAuthenticationRequested( |
246 | + oxide::ResourceDispatcherHostLoginDelegate* login_delegate) { |
247 | + // The client takes ownership of the request |
248 | + client_->HttpAuthenticationRequested( |
249 | + new OxideQHttpAuthenticationRequest(login_delegate)); |
250 | +} |
251 | + |
252 | bool WebView::ShouldHandleNavigation(const GURL& url, |
253 | WindowOpenDisposition disposition, |
254 | bool user_gesture) { |
255 | |
256 | === modified file 'qt/core/browser/oxide_qt_web_view.h' |
257 | --- qt/core/browser/oxide_qt_web_view.h 2015-06-04 13:21:49 +0000 |
258 | +++ qt/core/browser/oxide_qt_web_view.h 2015-06-18 16:37:15 +0000 |
259 | @@ -141,6 +141,9 @@ |
260 | const std::string& cookies, |
261 | const std::string& referrer, |
262 | const std::string& user_agent) override; |
263 | + void HttpAuthenticationRequested( |
264 | + ResourceDispatcherHostLoginDelegate* login_delegate) override; |
265 | + |
266 | bool ShouldHandleNavigation(const GURL& url, |
267 | WindowOpenDisposition disposition, |
268 | bool user_gesture) override; |
269 | |
270 | === modified file 'qt/core/core.gyp' |
271 | --- qt/core/core.gyp 2015-06-07 20:27:38 +0000 |
272 | +++ qt/core/core.gyp 2015-06-18 16:37:15 +0000 |
273 | @@ -208,6 +208,7 @@ |
274 | 'sources': [ |
275 | '<(INTERMEDIATE_DIR)/moc_oxideqcertificateerror.cc', |
276 | '<(INTERMEDIATE_DIR)/moc_oxideqdownloadrequest.cc', |
277 | + '<(INTERMEDIATE_DIR)/moc_oxideqhttpauthenticationrequest.cc', |
278 | '<(INTERMEDIATE_DIR)/moc_oxideqloadevent.cc', |
279 | '<(INTERMEDIATE_DIR)/moc_oxideqmediacapturedevices.cc', |
280 | '<(INTERMEDIATE_DIR)/moc_oxideqnetworkcallbackevents.cc', |
281 | @@ -227,6 +228,9 @@ |
282 | 'api/oxideqdownloadrequest_p.h', |
283 | 'api/oxideqglobal.cc', |
284 | 'api/oxideqglobal.h', |
285 | + 'api/oxideqhttpauthenticationrequest.cc', |
286 | + 'api/oxideqhttpauthenticationrequest.h', |
287 | + 'api/oxideqhttpauthenticationrequest_p.h', |
288 | 'api/oxideqloadevent.cc', |
289 | 'api/oxideqloadevent.h', |
290 | 'api/oxideqloadevent_p.h', |
291 | @@ -272,6 +276,11 @@ |
292 | 'includes': [ 'moc.gypi' ] |
293 | }, |
294 | { |
295 | + 'action_name': 'moc_oxideqhttpauthenticationrequest.cc', |
296 | + 'moc_input': 'api/oxideqhttpauthenticationrequest.h', |
297 | + 'includes': [ 'moc.gypi' ] |
298 | + }, |
299 | + { |
300 | 'action_name': 'moc_oxideqloadevent.cc', |
301 | 'moc_input': 'api/oxideqloadevent.h', |
302 | 'includes': [ 'moc.gypi' ] |
303 | |
304 | === modified file 'qt/core/glue/oxide_qt_web_view_proxy_client.h' |
305 | --- qt/core/glue/oxide_qt_web_view_proxy_client.h 2015-05-27 20:56:59 +0000 |
306 | +++ qt/core/glue/oxide_qt_web_view_proxy_client.h 2015-06-18 16:37:15 +0000 |
307 | @@ -32,6 +32,7 @@ |
308 | class OxideQMediaAccessPermissionRequest; |
309 | class OxideQNavigationRequest; |
310 | class OxideQNewViewRequest; |
311 | +class OxideQHttpAuthenticationRequest; |
312 | |
313 | QT_BEGIN_NAMESPACE |
314 | class QCursor; |
315 | @@ -139,6 +140,9 @@ |
316 | |
317 | virtual void DownloadRequested(OxideQDownloadRequest* download_request) = 0; |
318 | |
319 | + virtual void HttpAuthenticationRequested( |
320 | + OxideQHttpAuthenticationRequest* authentication_request) = 0; |
321 | + |
322 | virtual void CertificateError(OxideQCertificateError* cert_error) = 0; |
323 | |
324 | virtual void ContentBlocked() = 0; // XXX(chrisccoulson): Rename to BlockedContentChanged throughout Oxide |
325 | |
326 | === modified file 'qt/qmlplugin/oxide_qml_plugin.cc' |
327 | --- qt/qmlplugin/oxide_qml_plugin.cc 2015-06-05 18:43:21 +0000 |
328 | +++ qt/qmlplugin/oxide_qml_plugin.cc 2015-06-18 16:37:15 +0000 |
329 | @@ -25,6 +25,7 @@ |
330 | #include "qt/core/api/oxideqcertificateerror.h" |
331 | #include "qt/core/api/oxideqdownloadrequest.h" |
332 | #include "qt/core/api/oxideqfindcontroller.h" |
333 | +#include "qt/core/api/oxideqhttpauthenticationrequest.h" |
334 | #include "qt/core/api/oxideqloadevent.h" |
335 | #include "qt/core/api/oxideqnavigationrequest.h" |
336 | #include "qt/core/api/oxideqnewviewrequest.h" |
337 | @@ -136,6 +137,10 @@ |
338 | qmlRegisterType<OxideQQuickWebView, 4>(uri, 1, 8, "WebView"); |
339 | |
340 | qmlRegisterType<OxideQQuickWebContext, 3>(uri, 1, 9, "WebContext"); |
341 | + |
342 | + qmlRegisterUncreatableType<OxideQHttpAuthenticationRequest>(uri, 1, 9, "HttpAuthenticationRequest", |
343 | + "HttpAuthenticationRequest is delivered by WebView.httpAuthenticationRequested"); |
344 | + qmlRegisterType<OxideQQuickWebView, 5>(uri, 1, 9, "WebView"); |
345 | } |
346 | }; |
347 | |
348 | |
349 | === modified file 'qt/quick/api/oxideqquickwebview.cc' |
350 | --- qt/quick/api/oxideqquickwebview.cc 2015-05-28 23:51:39 +0000 |
351 | +++ qt/quick/api/oxideqquickwebview.cc 2015-06-18 16:37:15 +0000 |
352 | @@ -43,6 +43,7 @@ |
353 | #include "qt/core/api/oxideqcertificateerror.h" |
354 | #include "qt/core/api/oxideqfindcontroller.h" |
355 | #include "qt/core/api/oxideqglobal.h" |
356 | +#include "qt/core/api/oxideqhttpauthenticationrequest.h" |
357 | #include "qt/core/api/oxideqloadevent.h" |
358 | #include "qt/core/api/oxideqnewviewrequest.h" |
359 | #include "qt/core/api/oxideqpermissionrequest.h" |
360 | @@ -461,6 +462,31 @@ |
361 | |
362 | } |
363 | |
364 | +void OxideQQuickWebViewPrivate::HttpAuthenticationRequested( |
365 | + OxideQHttpAuthenticationRequest* authentication_request) { |
366 | + Q_Q(OxideQQuickWebView); |
367 | + |
368 | + // See the comment in RequestGeolocationPermission |
369 | + |
370 | + QQmlEngine* engine = qmlEngine(q); |
371 | + if (!engine) { |
372 | + delete authentication_request; |
373 | + return; |
374 | + } |
375 | + |
376 | + { |
377 | + QJSValue val = engine->newQObject(authentication_request); |
378 | + if (!val.isQObject()) { |
379 | + delete authentication_request; |
380 | + return; |
381 | + } |
382 | + |
383 | + emit q->httpAuthenticationRequested(val); |
384 | + } |
385 | + |
386 | + engine->collectGarbage(); |
387 | +} |
388 | + |
389 | void OxideQQuickWebViewPrivate::HandleUnhandledKeyboardEvent( |
390 | QKeyEvent* event) { |
391 | Q_Q(OxideQQuickWebView); |
392 | |
393 | === modified file 'qt/quick/api/oxideqquickwebview_p.h' |
394 | --- qt/quick/api/oxideqquickwebview_p.h 2015-05-28 23:51:39 +0000 |
395 | +++ qt/quick/api/oxideqquickwebview_p.h 2015-06-18 16:37:15 +0000 |
396 | @@ -356,6 +356,7 @@ |
397 | Q_REVISION(2) void prepareToCloseResponse(bool proceed); |
398 | Q_REVISION(2) void closeRequested(); |
399 | Q_REVISION(4) void webProcessStatusChanged(); |
400 | + Q_REVISION(5) void httpAuthenticationRequested(const QJSValue& request); |
401 | |
402 | // Deprecated since 1.3 |
403 | void loadingChanged(OxideQLoadEvent* loadEvent); |
404 | |
405 | === modified file 'qt/quick/api/oxideqquickwebview_p_p.h' |
406 | --- qt/quick/api/oxideqquickwebview_p_p.h 2015-05-28 23:51:39 +0000 |
407 | +++ qt/quick/api/oxideqquickwebview_p_p.h 2015-06-18 16:37:15 +0000 |
408 | @@ -135,6 +135,8 @@ |
409 | void EvictCurrentFrame() override; |
410 | void SetInputMethodEnabled(bool enabled) override; |
411 | void DownloadRequested(OxideQDownloadRequest* download_request) override; |
412 | + void HttpAuthenticationRequested( |
413 | + OxideQHttpAuthenticationRequest* authentication_request) override; |
414 | void CertificateError(OxideQCertificateError* cert_error) override; |
415 | void ContentBlocked() override; |
416 | void PrepareToCloseResponse(bool proceed) override; |
417 | |
418 | === modified file 'qt/tests/qmltests/TestWebView.qml' |
419 | --- qt/tests/qmltests/TestWebView.qml 2015-05-15 15:03:10 +0000 |
420 | +++ qt/tests/qmltests/TestWebView.qml 2015-06-18 16:37:15 +0000 |
421 | @@ -1,6 +1,6 @@ |
422 | import QtQuick 2.0 |
423 | import QtTest 1.0 |
424 | -import com.canonical.Oxide 1.8 |
425 | +import com.canonical.Oxide 1.9 |
426 | import com.canonical.Oxide.Testing 1.0 as Testing |
427 | import "TestUtils.js" as TestUtils |
428 | |
429 | |
430 | === added file 'qt/tests/qmltests/api/tst_httpAuthentication.py' |
431 | --- qt/tests/qmltests/api/tst_httpAuthentication.py 1970-01-01 00:00:00 +0000 |
432 | +++ qt/tests/qmltests/api/tst_httpAuthentication.py 2015-06-18 16:37:15 +0000 |
433 | @@ -0,0 +1,31 @@ |
434 | +from cStringIO import StringIO |
435 | +import base64 |
436 | + |
437 | +def handler(request): |
438 | + html = StringIO() |
439 | + |
440 | + def send_401(): |
441 | + request.send_response(401) |
442 | + request.send_header("WWW-Authenticate", "Basic realm=\"Fake Realm\"") |
443 | + request.send_header("Cache-Control", "no-store") |
444 | + request.send_header("Content-Length", html.tell()) |
445 | + request.end_headers() |
446 | + |
447 | + if "Authorization" in request.headers: |
448 | + user, password = request.path.split("?")[1].split("_") |
449 | + header = request.headers["Authorization"] |
450 | + credentials = base64.b64decode(header[len("Basic "):]).split(":") |
451 | + if credentials[0] == user and credentials[1] == password: |
452 | + html.write("Authentication success") |
453 | + request.send_response(200) |
454 | + request.send_header("Cache-Control", "no-store") |
455 | + request.send_header("Content-Length", html.tell()) |
456 | + request.end_headers() |
457 | + else: |
458 | + html.write("Wrong credentials") |
459 | + send_401() |
460 | + else: |
461 | + html.write("Requested credentials") |
462 | + send_401() |
463 | + |
464 | + request.wfile.write(html.getvalue()) |
465 | |
466 | === added file 'qt/tests/qmltests/api/tst_httpAuthentication.qml' |
467 | --- qt/tests/qmltests/api/tst_httpAuthentication.qml 1970-01-01 00:00:00 +0000 |
468 | +++ qt/tests/qmltests/api/tst_httpAuthentication.qml 2015-06-18 16:37:15 +0000 |
469 | @@ -0,0 +1,142 @@ |
470 | +import QtQuick 2.0 |
471 | +import QtTest 1.0 |
472 | +import com.canonical.Oxide 1.9 |
473 | +import com.canonical.Oxide.Testing 1.0 |
474 | + |
475 | +TestWebView { |
476 | + id: webView |
477 | + width: 200 |
478 | + height: 200 |
479 | + |
480 | + property var lastRequest |
481 | + property int lastStatusCode: -1 |
482 | + property int totalRequests: 0 |
483 | + property int expectedRequests: 0 |
484 | + property int totalCancellations: 0 |
485 | + property int expectedCancellations: 0 |
486 | + property bool ignoreRequests: false |
487 | + |
488 | + // Since the browser caches credentials after the first successful |
489 | + // authentication, we make sure to use a different username for every test |
490 | + property string baseUrl: "http://testsuite/tst_httpAuthentication.py" |
491 | + property int userNameSuffix: 0 |
492 | + property string currentUser: "user" + userNameSuffix |
493 | + property string credentialsUrl: baseUrl + "?" + currentUser + "_pass" |
494 | + |
495 | + onHttpAuthenticationRequested: { |
496 | + if (!ignoreRequests) { |
497 | + lastRequest = request |
498 | + lastRequest.cancelled.connect(updateCancellations) |
499 | + } |
500 | + totalRequests++ |
501 | + } |
502 | + |
503 | + onLoadEvent: lastStatusCode = event.httpStatusCode |
504 | + |
505 | + function updateCancellations() { totalCancellations++ } |
506 | + |
507 | + TestCase { |
508 | + id: test |
509 | + name: "httpAuthentication" |
510 | + when: windowShown |
511 | + |
512 | + function init() { |
513 | + ignoreRequests = false |
514 | + if (lastRequest) { |
515 | + lastRequest.cancelled.disconnect(updateCancellations) |
516 | + lastRequest = null |
517 | + } |
518 | + webView.url = "about:blank"; |
519 | + verify(webView.waitForLoadSucceeded()); |
520 | + totalRequests = 0 |
521 | + expectedRequests = 0 |
522 | + totalCancellations = 0 |
523 | + expectedCancellations = 0 |
524 | + lastStatusCode = -1 |
525 | + userNameSuffix++ |
526 | + } |
527 | + |
528 | + function receivedRequest() { |
529 | + return totalRequests == expectedRequests |
530 | + } |
531 | + |
532 | + function receivedCancellation() { |
533 | + return totalCancellations == expectedCancellations |
534 | + } |
535 | + |
536 | + function test_requestMembers() { |
537 | + expectedRequests++ |
538 | + webView.url = credentialsUrl |
539 | + verify(waitFor(receivedRequest), "No authentication request") |
540 | + compare(lastRequest.realm, "Fake Realm") |
541 | + compare(lastRequest.host, "testsuite:80") |
542 | + } |
543 | + |
544 | + function test_wrong_password() { |
545 | + expectedRequests++ |
546 | + webView.url = credentialsUrl |
547 | + verify(waitFor(receivedRequest), "No authentication request") |
548 | + expectedRequests++ |
549 | + lastRequest.allow(currentUser, "wrong") |
550 | + verify(waitFor(receivedRequest), "No authentication request") |
551 | + } |
552 | + |
553 | + function test_wrong_username() { |
554 | + expectedRequests++ |
555 | + webView.url = credentialsUrl |
556 | + verify(waitFor(receivedRequest), "No authentication request") |
557 | + expectedRequests++ |
558 | + lastRequest.allow(currentUser + "_wrong", "pass") |
559 | + verify(waitFor(receivedRequest), "No authentication request") |
560 | + } |
561 | + |
562 | + function test_right_credentials() { |
563 | + expectedRequests++ |
564 | + webView.url = credentialsUrl |
565 | + verify(waitFor(receivedRequest), "No authentication request") |
566 | + lastRequest.allow(currentUser, "pass") |
567 | + webView.waitForLoadSucceeded() |
568 | + compare(lastStatusCode, 200) |
569 | + compare(expectedRequests, totalRequests) |
570 | + } |
571 | + |
572 | + function test_explicit_cancellation() { |
573 | + webView.url = credentialsUrl |
574 | + expectedRequests++ |
575 | + verify(waitFor(receivedRequest), "No authentication request") |
576 | + |
577 | + lastRequest.deny() |
578 | + webView.waitForLoadSucceeded() |
579 | + compare(lastStatusCode, 401) |
580 | + // when cancelling explicity we should not receive cancellation signals |
581 | + compare(totalCancellations, 0) |
582 | + } |
583 | + |
584 | + function test_cancel_by_navigation() { |
585 | + webView.url = credentialsUrl |
586 | + expectedRequests++ |
587 | + verify(waitFor(receivedRequest), "No authentication request") |
588 | + |
589 | + expectedCancellations++ |
590 | + webView.url = "about:blank" |
591 | + verify(waitFor(receivedCancellation), "Authentication not cancelled") |
592 | + |
593 | + webView.waitForLoadSucceeded() |
594 | + compare(expectedRequests, totalRequests) |
595 | + } |
596 | + |
597 | + function test_ignored_request_cancelled() { |
598 | + ignoreRequests = true |
599 | + webView.url = credentialsUrl |
600 | + expectedRequests++ |
601 | + verify(waitFor(receivedRequest), "No authentication request") |
602 | + |
603 | + // force garbage collection so the request object will be destroyed |
604 | + // as we did not keep any reference to it. |
605 | + // the request destructor will call request.deny() |
606 | + gc() |
607 | + webView.waitForLoadSucceeded() |
608 | + compare(lastStatusCode, 401) |
609 | + } |
610 | + } |
611 | +} |
612 | |
613 | === modified file 'shared/browser/oxide_resource_dispatcher_host_delegate.cc' |
614 | --- shared/browser/oxide_resource_dispatcher_host_delegate.cc 2015-06-06 10:38:48 +0000 |
615 | +++ shared/browser/oxide_resource_dispatcher_host_delegate.cc 2015-06-18 16:37:15 +0000 |
616 | @@ -18,12 +18,14 @@ |
617 | #include "oxide_resource_dispatcher_host_delegate.h" |
618 | |
619 | #include "base/bind.h" |
620 | -#include "base/callback.h" |
621 | #include "base/logging.h" |
622 | #include "base/strings/utf_string_conversions.h" |
623 | #include "content/public/browser/browser_thread.h" |
624 | +#include "content/public/browser/render_frame_host.h" |
625 | #include "content/public/browser/render_view_host.h" |
626 | +#include "content/public/browser/resource_dispatcher_host.h" |
627 | #include "content/public/browser/resource_context.h" |
628 | +#include "content/public/browser/resource_request_info.h" |
629 | #include "content/public/common/referrer.h" |
630 | #include "net/base/mime_util.h" |
631 | #include "net/cookies/cookie_monster.h" |
632 | @@ -37,6 +39,7 @@ |
633 | #include "oxide_browser_context_delegate.h" |
634 | #include "oxide_browser_platform_integration.h" |
635 | #include "oxide_redirection_intercept_throttle.h" |
636 | +#include "oxide_resource_dispatcher_host_login_delegate.h" |
637 | #include "oxide_web_view.h" |
638 | |
639 | namespace oxide { |
640 | @@ -193,8 +196,8 @@ |
641 | params.render_process_id, params.render_view_id); |
642 | if (!rvh) { |
643 | LOG(ERROR) << "Invalid or non-existent render_process_id & render_view_id:" |
644 | - << params.render_process_id << ", " << params.render_view_id |
645 | - << "during download url delegate dispatch"; |
646 | + << params.render_process_id << ", " << params.render_view_id |
647 | + << "during download url delegate dispatch"; |
648 | return; |
649 | } |
650 | |
651 | @@ -239,6 +242,14 @@ |
652 | return BrowserPlatformIntegration::GetInstance()->LaunchURLExternally(url); |
653 | } |
654 | |
655 | +content::ResourceDispatcherHostLoginDelegate* |
656 | + ResourceDispatcherHostDelegate::CreateLoginDelegate( |
657 | + net::AuthChallengeInfo* auth_info, |
658 | + net::URLRequest* request) { |
659 | + // Chromium will own the delegate |
660 | + return new ResourceDispatcherHostLoginDelegate(auth_info, request); |
661 | +} |
662 | + |
663 | ResourceDispatcherHostDelegate::ResourceDispatcherHostDelegate() {} |
664 | |
665 | ResourceDispatcherHostDelegate::~ResourceDispatcherHostDelegate() {} |
666 | |
667 | === modified file 'shared/browser/oxide_resource_dispatcher_host_delegate.h' |
668 | --- shared/browser/oxide_resource_dispatcher_host_delegate.h 2015-06-02 15:31:02 +0000 |
669 | +++ shared/browser/oxide_resource_dispatcher_host_delegate.h 2015-06-18 16:37:15 +0000 |
670 | @@ -18,6 +18,7 @@ |
671 | #ifndef _OXIDE_SHARED_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ |
672 | #define _OXIDE_SHARED_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_ |
673 | |
674 | +#include "base/callback.h" |
675 | #include "base/macros.h" |
676 | #include "base/strings/string16.h" |
677 | #include "content/public/browser/resource_dispatcher_host_delegate.h" |
678 | @@ -35,6 +36,8 @@ |
679 | |
680 | namespace oxide { |
681 | |
682 | +class ResourceDispatcherHostLoginDelegate; |
683 | + |
684 | class ResourceDispatcherHostDelegate |
685 | : public content::ResourceDispatcherHostDelegate { |
686 | public: |
687 | @@ -89,6 +92,11 @@ |
688 | ui::PageTransition page_transition, |
689 | bool has_user_gesture) override; |
690 | |
691 | + content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( |
692 | + net::AuthChallengeInfo* auth_info, |
693 | + net::URLRequest* request) override; |
694 | + |
695 | +private: |
696 | DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostDelegate); |
697 | }; |
698 | |
699 | |
700 | === added file 'shared/browser/oxide_resource_dispatcher_host_login_delegate.cc' |
701 | --- shared/browser/oxide_resource_dispatcher_host_login_delegate.cc 1970-01-01 00:00:00 +0000 |
702 | +++ shared/browser/oxide_resource_dispatcher_host_login_delegate.cc 2015-06-18 16:37:15 +0000 |
703 | @@ -0,0 +1,162 @@ |
704 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
705 | +// Copyright (C) 2014-2015 Canonical Ltd. |
706 | + |
707 | +// This library is free software; you can redistribute it and/or |
708 | +// modify it under the terms of the GNU Lesser General Public |
709 | +// License as published by the Free Software Foundation; either |
710 | +// version 2.1 of the License, or (at your option) any later version. |
711 | + |
712 | +// This library is distributed in the hope that it will be useful, |
713 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
714 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
715 | +// Lesser General Public License for more details. |
716 | + |
717 | +// You should have received a copy of the GNU Lesser General Public |
718 | +// License along with this library; if not, write to the Free Software |
719 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
720 | + |
721 | +#include "oxide_resource_dispatcher_host_login_delegate.h" |
722 | + |
723 | +#include "base/bind.h" |
724 | +#include "base/logging.h" |
725 | +#include "base/strings/utf_string_conversions.h" |
726 | +#include "content/public/browser/browser_thread.h" |
727 | +#include "content/public/browser/render_frame_host.h" |
728 | +#include "content/public/browser/resource_dispatcher_host.h" |
729 | +#include "content/public/browser/resource_context.h" |
730 | +#include "content/public/browser/resource_request_info.h" |
731 | +#include "net/base/auth.h" |
732 | +#include "net/url_request/url_request.h" |
733 | + |
734 | +#include "oxide_web_view.h" |
735 | + |
736 | +namespace oxide { |
737 | + |
738 | +ResourceDispatcherHostLoginDelegate::ResourceDispatcherHostLoginDelegate( |
739 | + net::AuthChallengeInfo* auth_info, |
740 | + net::URLRequest* request) |
741 | + : request_(request) { |
742 | + DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
743 | + |
744 | + host_ = auth_info->challenger.ToString(); |
745 | + realm_ = auth_info->realm; |
746 | + |
747 | + WebView* webview = GetWebView(request_); |
748 | + if (!webview) { |
749 | + // Deny the request if we can not get access to the webview, as there is |
750 | + // no other sensible thing to do. |
751 | + Deny(); |
752 | + return; |
753 | + } |
754 | + |
755 | + content::BrowserThread::PostTask( |
756 | + content::BrowserThread::UI, |
757 | + FROM_HERE, |
758 | + base::Bind(&ResourceDispatcherHostLoginDelegate::DispatchRequest, |
759 | + this, webview)); |
760 | +} |
761 | + |
762 | +ResourceDispatcherHostLoginDelegate::~ResourceDispatcherHostLoginDelegate() {} |
763 | + |
764 | +void ResourceDispatcherHostLoginDelegate::SetCancelledCallback( |
765 | + const base::Closure& cancelled_callback) { |
766 | + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
767 | + |
768 | + cancelled_callback_ = cancelled_callback; |
769 | +} |
770 | + |
771 | +void ResourceDispatcherHostLoginDelegate::OnRequestCancelled() { |
772 | + DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
773 | + |
774 | + request_ = nullptr; |
775 | + |
776 | + content::BrowserThread::PostTask( |
777 | + content::BrowserThread::UI, |
778 | + FROM_HERE, |
779 | + base::Bind(&ResourceDispatcherHostLoginDelegate::DispatchCancelledCallback, |
780 | + this)); |
781 | +} |
782 | + |
783 | +void ResourceDispatcherHostLoginDelegate::DispatchCancelledCallback() { |
784 | + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
785 | + |
786 | + if (!cancelled_callback_.is_null()) { |
787 | + content::BrowserThread::PostTask( |
788 | + content::BrowserThread::UI, |
789 | + FROM_HERE, |
790 | + cancelled_callback_); |
791 | + } |
792 | +} |
793 | + |
794 | +void ResourceDispatcherHostLoginDelegate::Deny() { |
795 | + if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { |
796 | + content::BrowserThread::PostTask( |
797 | + content::BrowserThread::IO, |
798 | + FROM_HERE, |
799 | + base::Bind(&ResourceDispatcherHostLoginDelegate::Deny, this)); |
800 | + return; |
801 | + } |
802 | + |
803 | + if (!request_) { |
804 | + return; |
805 | + } |
806 | + |
807 | + request_->CancelAuth(); |
808 | + content::ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest( |
809 | + request_); |
810 | + request_ = nullptr; |
811 | +} |
812 | + |
813 | +void ResourceDispatcherHostLoginDelegate::Allow(const std::string &username, |
814 | + const std::string &password) |
815 | +{ |
816 | + if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { |
817 | + content::BrowserThread::PostTask( |
818 | + content::BrowserThread::IO, |
819 | + FROM_HERE, |
820 | + base::Bind(&ResourceDispatcherHostLoginDelegate::Allow, this, |
821 | + username, password)); |
822 | + return; |
823 | + } |
824 | + |
825 | + if (!request_) { |
826 | + return; |
827 | + } |
828 | + |
829 | + request_->SetAuth(net::AuthCredentials(base::UTF8ToUTF16(username), |
830 | + base::UTF8ToUTF16(password))); |
831 | + content::ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest( |
832 | + request_); |
833 | + request_ = nullptr; |
834 | +} |
835 | + |
836 | +WebView* ResourceDispatcherHostLoginDelegate::GetWebView( |
837 | + net::URLRequest* request) { |
838 | + int processId; |
839 | + int frameId; |
840 | + content::ResourceRequestInfo::GetRenderFrameForRequest(request, &processId, |
841 | + &frameId); |
842 | + content::RenderFrameHost* rfh = content::RenderFrameHost::FromID(processId, |
843 | + frameId); |
844 | + if (!rfh) { |
845 | + return nullptr; |
846 | + } |
847 | + |
848 | + return WebView::FromRenderFrameHost(rfh); |
849 | +} |
850 | + |
851 | +void ResourceDispatcherHostLoginDelegate::DispatchRequest(WebView* webview) { |
852 | + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
853 | + |
854 | + webview->HttpAuthenticationRequested(this); |
855 | +} |
856 | + |
857 | +std::string ResourceDispatcherHostLoginDelegate::Host() const { |
858 | + return host_; |
859 | +} |
860 | + |
861 | +std::string ResourceDispatcherHostLoginDelegate::Realm() const { |
862 | + return realm_; |
863 | +} |
864 | + |
865 | +} // namespace oxide |
866 | |
867 | === added file 'shared/browser/oxide_resource_dispatcher_host_login_delegate.h' |
868 | --- shared/browser/oxide_resource_dispatcher_host_login_delegate.h 1970-01-01 00:00:00 +0000 |
869 | +++ shared/browser/oxide_resource_dispatcher_host_login_delegate.h 2015-06-18 16:37:15 +0000 |
870 | @@ -0,0 +1,65 @@ |
871 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
872 | +// Copyright (C) 2014-2015 Canonical Ltd. |
873 | + |
874 | +// This library is free software; you can redistribute it and/or |
875 | +// modify it under the terms of the GNU Lesser General Public |
876 | +// License as published by the Free Software Foundation; either |
877 | +// version 2.1 of the License, or (at your option) any later version. |
878 | + |
879 | +// This library is distributed in the hope that it will be useful, |
880 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
881 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
882 | +// Lesser General Public License for more details. |
883 | + |
884 | +// You should have received a copy of the GNU Lesser General Public |
885 | +// License along with this library; if not, write to the Free Software |
886 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
887 | + |
888 | +#ifndef _OXIDE_SHARED_BROWSER_RESOURCE_DISPATCHER_HOST_LOGIN_DELEGATE_H_ |
889 | +#define _OXIDE_SHARED_BROWSER_RESOURCE_DISPATCHER_HOST_LOGIN_DELEGATE_H_ |
890 | + |
891 | +#include "base/callback.h" |
892 | +#include "content/public/browser/resource_dispatcher_host_login_delegate.h" |
893 | + |
894 | +namespace net { |
895 | +class URLRequest; |
896 | +class AuthChallengeInfo; |
897 | +} |
898 | + |
899 | +namespace oxide { |
900 | + |
901 | +class ResourceDispatcherHostDelegate; |
902 | +class WebView; |
903 | + |
904 | +class ResourceDispatcherHostLoginDelegate |
905 | + : public content::ResourceDispatcherHostLoginDelegate { |
906 | + public: |
907 | + ResourceDispatcherHostLoginDelegate(net::AuthChallengeInfo* auth_info, |
908 | + net::URLRequest* request); |
909 | + ~ResourceDispatcherHostLoginDelegate() override; |
910 | + void OnRequestCancelled() override; |
911 | + |
912 | + void Deny(); |
913 | + void Allow(const std::string& username, const std::string& password); |
914 | + |
915 | + void SetCancelledCallback(const base::Closure& cancelled_callback); |
916 | + |
917 | + std::string Host() const; |
918 | + std::string Realm() const; |
919 | + |
920 | +private: |
921 | + friend class ResourceDispatcherHostDelegate; |
922 | + void DispatchRequest(WebView* webview); |
923 | + void DispatchCancelledCallback(); |
924 | + WebView* GetWebView(net::URLRequest* request); |
925 | + |
926 | + net::URLRequest* request_; |
927 | + std::string host_; |
928 | + std::string realm_; |
929 | + base::Closure cancelled_callback_; |
930 | +}; |
931 | + |
932 | +} // namespace oxide |
933 | + |
934 | +#endif // OXIDE_SHARED_BROWSER_RESOURCE_DISPATCHER_HOST_LOGIN_DELEGATE |
935 | + |
936 | |
937 | === modified file 'shared/browser/oxide_web_view.cc' |
938 | --- shared/browser/oxide_web_view.cc 2015-06-17 21:04:11 +0000 |
939 | +++ shared/browser/oxide_web_view.cc 2015-06-18 16:37:15 +0000 |
940 | @@ -1269,7 +1269,7 @@ |
941 | DCHECK(root_frame_.get()); |
942 | |
943 | if (params->context && init_data_->load_params) { |
944 | - web_contents_->GetController().LoadURLWithParams(*init_data_->load_params); |
945 | + web_contents_->GetController().LoadURLWithParams(*init_data_->load_params); |
946 | } |
947 | |
948 | web_contents_->GetController().LoadIfNecessary(); |
949 | @@ -2100,6 +2100,11 @@ |
950 | user_agent); |
951 | } |
952 | |
953 | +void WebView::HttpAuthenticationRequested( |
954 | + ResourceDispatcherHostLoginDelegate* login_delegate) { |
955 | + client_->HttpAuthenticationRequested(login_delegate); |
956 | +} |
957 | + |
958 | CompositorFrameHandle* WebView::GetCompositorFrameHandle() const { |
959 | return current_compositor_frame_.get(); |
960 | } |
961 | |
962 | === modified file 'shared/browser/oxide_web_view.h' |
963 | --- shared/browser/oxide_web_view.h 2015-06-11 13:06:02 +0000 |
964 | +++ shared/browser/oxide_web_view.h 2015-06-18 16:37:15 +0000 |
965 | @@ -98,6 +98,7 @@ |
966 | class CompositorFrameHandle; |
967 | class FilePicker; |
968 | class JavaScriptDialog; |
969 | +class ResourceDispatcherHostLoginDelegate; |
970 | class RenderWidgetHostView; |
971 | class WebContextMenu; |
972 | class WebFrame; |
973 | @@ -310,6 +311,9 @@ |
974 | const std::string& referrer, |
975 | const std::string& user_agent); |
976 | |
977 | + void HttpAuthenticationRequested( |
978 | + ResourceDispatcherHostLoginDelegate* login_delegate); |
979 | + |
980 | CompositorFrameHandle* GetCompositorFrameHandle() const; |
981 | void DidCommitCompositorFrame(); |
982 | |
983 | |
984 | === modified file 'shared/browser/oxide_web_view_client.cc' |
985 | --- shared/browser/oxide_web_view_client.cc 2015-06-04 13:21:49 +0000 |
986 | +++ shared/browser/oxide_web_view_client.cc 2015-06-18 16:37:15 +0000 |
987 | @@ -168,4 +168,7 @@ |
988 | |
989 | void WebViewClient::FindInPageCountChanged() {} |
990 | |
991 | +void WebViewClient::HttpAuthenticationRequested( |
992 | + ResourceDispatcherHostLoginDelegate* login_delegate) {} |
993 | + |
994 | } // namespace oxide |
995 | |
996 | === modified file 'shared/browser/oxide_web_view_client.h' |
997 | --- shared/browser/oxide_web_view_client.h 2015-06-04 13:21:49 +0000 |
998 | +++ shared/browser/oxide_web_view_client.h 2015-06-18 16:37:15 +0000 |
999 | @@ -48,6 +48,7 @@ |
1000 | class CertificateError; |
1001 | class FilePicker; |
1002 | class JavaScriptDialog; |
1003 | +class ResourceDispatcherHostLoginDelegate; |
1004 | class SecurityStatus; |
1005 | class WebContextMenu; |
1006 | class WebFrame; |
1007 | @@ -206,6 +207,9 @@ |
1008 | |
1009 | virtual void FindInPageCurrentChanged(); |
1010 | virtual void FindInPageCountChanged(); |
1011 | + |
1012 | + virtual void HttpAuthenticationRequested( |
1013 | + ResourceDispatcherHostLoginDelegate* login_delegate); |
1014 | }; |
1015 | |
1016 | } // namespace oxide |
1017 | |
1018 | === modified file 'shared/shared.gyp' |
1019 | --- shared/shared.gyp 2015-06-10 13:10:39 +0000 |
1020 | +++ shared/shared.gyp 2015-06-18 16:37:15 +0000 |
1021 | @@ -370,6 +370,8 @@ |
1022 | 'browser/oxide_render_widget_host_view_delegate.h', |
1023 | 'browser/oxide_resource_dispatcher_host_delegate.cc', |
1024 | 'browser/oxide_resource_dispatcher_host_delegate.h', |
1025 | + 'browser/oxide_resource_dispatcher_host_login_delegate.cc', |
1026 | + 'browser/oxide_resource_dispatcher_host_login_delegate.h', |
1027 | 'browser/oxide_script_message_dispatcher_browser.cc', |
1028 | 'browser/oxide_script_message_dispatcher_browser.h', |
1029 | 'browser/oxide_script_message_impl_browser.cc', |
I’m getting the following error when running the unit tests on a local build:
1: QWARN : qml-api- test::UnknownTe stFunc( ) file:// /home/osomon/ dev/phablet/ oxide/trunk/ qt/tests/ qmltests/ api/tst_ WebView_ basicAuthentica tion.qml: 25:3: "TestWebView. onBasicAuthenti cationRequested " is not available due to component versioning. cationRequested : { test::tst_ WebView_ basicAuthentica tion::compile( ) dev/phablet/ oxide/trunk/ qt/tests/ qmltests/ api/tst_ WebView_ basicAuthentica tion.qml produced 1 error(s): dev/phablet/ oxide/trunk/ qt/tests/ qmltests/ api/tst_ WebView_ basicAuthentica tion.qml: 25,3: "TestWebView. onBasicAuthenti cationRequested " is not available due to component versioning. dev/phablet/ oxide/trunk/ objdir- x64-release/ qt/tests/ qmltests osomon/ dev/phablet/ oxide/trunk/ objdir- x64-release/ out/bin' osomon/ dev/phablet/ oxide/trunk/ objdir- x64-release/ out/imports' x86_64- linux-gnu/ qt5/qml' test::tst_ WebView_ basicAuthentica tion::compile( ) "TestWebView. onBasicAuthenti cationRequested " is not available due to component versioning. osomon/ dev/phablet/ oxide/trunk/ qt/tests/ qmltests/ api/tst_ WebView_ basicAuthentica tion.qml( 25)]
1: onBasicAuthenti
1: ^
1: QWARN : qml-api-
1: /home/osomon/
1: /home/osomon/
1: Working directory: /home/osomon/
1: View: QQuickView, import paths:
1: '/home/
1: '/home/
1: '/usr/lib/
1: Plugin paths:
1: '.'
1:
1: FAIL! : qml-api-
1: Loc: [/home/
You will need to import com.canonical.Oxide 1.9 in your tests.