Merge lp:~uriboni/oxide/basic-authentication into lp:~oxide-developers/oxide/oxide.trunk

Proposed by Ugo Riboni
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
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.

To post a comment you must log in.
Revision history for this message
Olivier Tilloy (osomon) wrote :

I’m getting the following error when running the unit tests on a local build:

1: QWARN : qml-api-test::UnknownTestFunc() file:///home/osomon/dev/phablet/oxide/trunk/qt/tests/qmltests/api/tst_WebView_basicAuthentication.qml:25:3: "TestWebView.onBasicAuthenticationRequested" is not available due to component versioning.
1: onBasicAuthenticationRequested: {
1: ^
1: QWARN : qml-api-test::tst_WebView_basicAuthentication::compile()
1: /home/osomon/dev/phablet/oxide/trunk/qt/tests/qmltests/api/tst_WebView_basicAuthentication.qml produced 1 error(s):
1: /home/osomon/dev/phablet/oxide/trunk/qt/tests/qmltests/api/tst_WebView_basicAuthentication.qml:25,3: "TestWebView.onBasicAuthenticationRequested" is not available due to component versioning.
1: Working directory: /home/osomon/dev/phablet/oxide/trunk/objdir-x64-release/qt/tests/qmltests
1: View: QQuickView, import paths:
1: '/home/osomon/dev/phablet/oxide/trunk/objdir-x64-release/out/bin'
1: '/home/osomon/dev/phablet/oxide/trunk/objdir-x64-release/out/imports'
1: '/usr/lib/x86_64-linux-gnu/qt5/qml'
1: Plugin paths:
1: '.'
1:
1: FAIL! : qml-api-test::tst_WebView_basicAuthentication::compile() "TestWebView.onBasicAuthenticationRequested" is not available due to component versioning.
1: Loc: [/home/osomon/dev/phablet/oxide/trunk/qt/tests/qmltests/api/tst_WebView_basicAuthentication.qml(25)]

You will need to import com.canonical.Oxide 1.9 in your tests.

review: Needs Fixing
1084. By Ugo Riboni

Fix the oxide version used in unit tests

1085. By Ugo Riboni

Simplify and fix unit tests

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

I’m seeing this really weird warning when running unit tests locally:

1: QWARN : qml-api-test::WebView_beforeUnloadDialog::test_customDialogComponent(row 0) file:///home/osomon/dev/phablet/oxide/trunk/qt/tests/qmltests/api/tst_WebView_basicAuthentication.qml:33: TypeError: Cannot read property of null

I don’t see how WebView_beforeUnloadDialog could possibly be loading tst_WebView_basicAuthentication.qml. Maybe a bug in our custom QML test runner? In any case, worth investigating, given that it showed up in this branch.

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

In qt/core/core.gyp, file paths should be kept sorted alphabetically.

Revision history for this message
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://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Spaces_vs._Tabs.

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.

review: Needs Fixing
Revision history for this message
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 *basicAuthentication* to *httpAuthentication* 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 OxideQHttpAuthenticationRequest 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 ResourceDispatcherHostLoginDelegate 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.

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

I've added some more comments inline

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'qt/core/api/oxideqhttpauthenticationrequest.cc'
--- qt/core/api/oxideqhttpauthenticationrequest.cc 1970-01-01 00:00:00 +0000
+++ qt/core/api/oxideqhttpauthenticationrequest.cc 2015-06-18 16:37:15 +0000
@@ -0,0 +1,103 @@
1// vim:expandtab:shiftwidth=2:tabstop=2:
2// Copyright (C) 2015 Canonical Ltd.
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18#include "base/bind.h"
19#include "base/callback.h"
20
21#include "shared/browser/oxide_resource_dispatcher_host_login_delegate.h"
22#include "qt/core/browser/oxide_qt_web_view.h"
23
24#include "oxideqhttpauthenticationrequest.h"
25#include "oxideqhttpauthenticationrequest_p.h"
26
27OxideQHttpAuthenticationRequestPrivate::OxideQHttpAuthenticationRequestPrivate(
28 oxide::ResourceDispatcherHostLoginDelegate* login_delegate)
29 : q_ptr(nullptr),
30 login_delegate_(login_delegate) {
31 // Use of base::Unretained is safe here because we clear the callback
32 // in the destructor, so that it can not called back on a deleted object
33 login_delegate->SetCancelledCallback(
34 base::Bind(&OxideQHttpAuthenticationRequestPrivate::RequestCancelled,
35 base::Unretained(this)));
36}
37
38OxideQHttpAuthenticationRequestPrivate::~OxideQHttpAuthenticationRequestPrivate() {
39 if (login_delegate_) {
40 login_delegate_->SetCancelledCallback(base::Closure());
41
42 // Always deny the request when we are being destroyed, as it should be the
43 // default action in case the client ignores this request and it gets
44 // garbage collected.
45 // In case an action has already been taken, this is a essentially a no-op.
46 login_delegate_->Deny();
47 }
48}
49
50void OxideQHttpAuthenticationRequestPrivate::RequestCancelled() {
51 Q_Q(OxideQHttpAuthenticationRequest);
52
53 login_delegate_ = nullptr;
54 q->cancelled();
55}
56
57OxideQHttpAuthenticationRequest::OxideQHttpAuthenticationRequest(
58 oxide::ResourceDispatcherHostLoginDelegate* login_delegate)
59 : d_ptr(new OxideQHttpAuthenticationRequestPrivate(login_delegate)) {
60 Q_D(OxideQHttpAuthenticationRequest);
61 d->q_ptr = this;
62}
63
64OxideQHttpAuthenticationRequest::~OxideQHttpAuthenticationRequest() {}
65
66QString OxideQHttpAuthenticationRequest::host() const {
67 Q_D(const OxideQHttpAuthenticationRequest);
68
69 if (d->login_delegate_) {
70 return QString::fromStdString(d->login_delegate_->Host());
71 } else {
72 return QString();
73 }
74}
75
76QString OxideQHttpAuthenticationRequest::realm() const {
77 Q_D(const OxideQHttpAuthenticationRequest);
78
79 if (d->login_delegate_) {
80 return QString::fromStdString(d->login_delegate_->Realm());
81 } else {
82 return QString();
83 }
84}
85
86void OxideQHttpAuthenticationRequest::deny() {
87 Q_D(OxideQHttpAuthenticationRequest);
88
89 if (d->login_delegate_) {
90 d->login_delegate_->Deny();
91 d->login_delegate_ = nullptr;
92 }
93}
94
95void OxideQHttpAuthenticationRequest::allow(const QString &username,
96 const QString &password) {
97 Q_D(OxideQHttpAuthenticationRequest);
98
99 if (d->login_delegate_) {
100 d->login_delegate_->Allow(username.toStdString(), password.toStdString());
101 d->login_delegate_ = nullptr;
102 }
103}
0104
=== added file 'qt/core/api/oxideqhttpauthenticationrequest.h'
--- qt/core/api/oxideqhttpauthenticationrequest.h 1970-01-01 00:00:00 +0000
+++ qt/core/api/oxideqhttpauthenticationrequest.h 2015-06-18 16:37:15 +0000
@@ -0,0 +1,64 @@
1// vim:expandtab:shiftwidth=2:tabstop=2:
2// Copyright (C) 2015 Canonical Ltd.
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18#ifndef OXIDE_Q_HTTP_AUTHENTICATION_REQUEST
19#define OXIDE_Q_HTTP_AUTHENTICATION_REQUEST
20
21#include <QObject>
22#include <QScopedPointer>
23#include <QString>
24#include <QtGlobal>
25
26class OxideQHttpAuthenticationRequestPrivate;
27
28namespace oxide {
29 namespace qt {
30 class WebView;
31 }
32 class ResourceDispatcherHostLoginDelegate;
33}
34
35class Q_DECL_EXPORT OxideQHttpAuthenticationRequest : public QObject {
36 Q_OBJECT
37 Q_PROPERTY(QString host READ host CONSTANT)
38 Q_PROPERTY(QString realm READ realm CONSTANT)
39
40 Q_DECLARE_PRIVATE(OxideQHttpAuthenticationRequest)
41 Q_DISABLE_COPY(OxideQHttpAuthenticationRequest)
42
43 public:
44 ~OxideQHttpAuthenticationRequest();
45
46 QString host() const;
47 QString realm() const;
48
49 Q_INVOKABLE void allow(const QString& username, const QString& password);
50 Q_INVOKABLE void deny();
51
52 Q_SIGNALS:
53 void cancelled() const;
54
55 private:
56 Q_DECL_HIDDEN OxideQHttpAuthenticationRequest(
57 oxide::ResourceDispatcherHostLoginDelegate* login_delegate);
58
59 QScopedPointer<OxideQHttpAuthenticationRequestPrivate> d_ptr;
60
61 friend class oxide::qt::WebView;
62};
63
64#endif // OXIDE_Q_HTTP_AUTHENTICATION_REQUEST
065
=== added file 'qt/core/api/oxideqhttpauthenticationrequest_p.h'
--- qt/core/api/oxideqhttpauthenticationrequest_p.h 1970-01-01 00:00:00 +0000
+++ qt/core/api/oxideqhttpauthenticationrequest_p.h 2015-06-18 16:37:15 +0000
@@ -0,0 +1,47 @@
1// vim:expandtab:shiftwidth=2:tabstop=2:
2// Copyright (C) 2015 Canonical Ltd.
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18#ifndef _OXIDE_QT_CORE_API_HTTP_AUTHENTICATION_REQUEST_P_H_
19#define _OXIDE_QT_CORE_API_HTTP_AUTHENTICATION_REQUEST_P_H_
20
21#include <QtGlobal>
22#include <QString>
23
24namespace oxide {
25 class ResourceDispatcherHostLoginDelegate;
26}
27
28class OxideQHttpAuthenticationRequest;
29
30class OxideQHttpAuthenticationRequestPrivate {
31 Q_DECLARE_PUBLIC(OxideQHttpAuthenticationRequest)
32
33 public:
34 virtual ~OxideQHttpAuthenticationRequestPrivate();
35
36 private:
37 OxideQHttpAuthenticationRequestPrivate(
38 oxide::ResourceDispatcherHostLoginDelegate* login_delegate);
39 void RequestCancelled();
40
41 OxideQHttpAuthenticationRequest* q_ptr;
42 QString realm_;
43 oxide::ResourceDispatcherHostLoginDelegate* login_delegate_;
44};
45
46#endif // _OXIDE_QT_CORE_API_HTTP_AUTHENTICATION_REQUEST_P_H_
47
048
=== modified file 'qt/core/browser/oxide_qt_web_view.cc'
--- qt/core/browser/oxide_qt_web_view.cc 2015-06-04 17:11:01 +0000
+++ qt/core/browser/oxide_qt_web_view.cc 2015-06-18 16:37:15 +0000
@@ -58,6 +58,7 @@
5858
59#include "qt/core/api/oxideqdownloadrequest.h"59#include "qt/core/api/oxideqdownloadrequest.h"
60#include "qt/core/api/oxideqloadevent.h"60#include "qt/core/api/oxideqloadevent.h"
61#include "qt/core/api/oxideqhttpauthenticationrequest.h"
61#include "qt/core/api/oxideqnavigationrequest.h"62#include "qt/core/api/oxideqnavigationrequest.h"
62#include "qt/core/api/oxideqnewviewrequest.h"63#include "qt/core/api/oxideqnewviewrequest.h"
63#include "qt/core/api/oxideqnewviewrequest_p.h"64#include "qt/core/api/oxideqnewviewrequest_p.h"
@@ -744,6 +745,13 @@
744 client_->DownloadRequested(&download_request);745 client_->DownloadRequested(&download_request);
745}746}
746747
748void WebView::HttpAuthenticationRequested(
749 oxide::ResourceDispatcherHostLoginDelegate* login_delegate) {
750 // The client takes ownership of the request
751 client_->HttpAuthenticationRequested(
752 new OxideQHttpAuthenticationRequest(login_delegate));
753}
754
747bool WebView::ShouldHandleNavigation(const GURL& url,755bool WebView::ShouldHandleNavigation(const GURL& url,
748 WindowOpenDisposition disposition,756 WindowOpenDisposition disposition,
749 bool user_gesture) {757 bool user_gesture) {
750758
=== modified file 'qt/core/browser/oxide_qt_web_view.h'
--- qt/core/browser/oxide_qt_web_view.h 2015-06-04 13:21:49 +0000
+++ qt/core/browser/oxide_qt_web_view.h 2015-06-18 16:37:15 +0000
@@ -141,6 +141,9 @@
141 const std::string& cookies,141 const std::string& cookies,
142 const std::string& referrer,142 const std::string& referrer,
143 const std::string& user_agent) override;143 const std::string& user_agent) override;
144 void HttpAuthenticationRequested(
145 ResourceDispatcherHostLoginDelegate* login_delegate) override;
146
144 bool ShouldHandleNavigation(const GURL& url,147 bool ShouldHandleNavigation(const GURL& url,
145 WindowOpenDisposition disposition,148 WindowOpenDisposition disposition,
146 bool user_gesture) override;149 bool user_gesture) override;
147150
=== modified file 'qt/core/core.gyp'
--- qt/core/core.gyp 2015-06-07 20:27:38 +0000
+++ qt/core/core.gyp 2015-06-18 16:37:15 +0000
@@ -208,6 +208,7 @@
208 'sources': [208 'sources': [
209 '<(INTERMEDIATE_DIR)/moc_oxideqcertificateerror.cc',209 '<(INTERMEDIATE_DIR)/moc_oxideqcertificateerror.cc',
210 '<(INTERMEDIATE_DIR)/moc_oxideqdownloadrequest.cc',210 '<(INTERMEDIATE_DIR)/moc_oxideqdownloadrequest.cc',
211 '<(INTERMEDIATE_DIR)/moc_oxideqhttpauthenticationrequest.cc',
211 '<(INTERMEDIATE_DIR)/moc_oxideqloadevent.cc',212 '<(INTERMEDIATE_DIR)/moc_oxideqloadevent.cc',
212 '<(INTERMEDIATE_DIR)/moc_oxideqmediacapturedevices.cc',213 '<(INTERMEDIATE_DIR)/moc_oxideqmediacapturedevices.cc',
213 '<(INTERMEDIATE_DIR)/moc_oxideqnetworkcallbackevents.cc',214 '<(INTERMEDIATE_DIR)/moc_oxideqnetworkcallbackevents.cc',
@@ -227,6 +228,9 @@
227 'api/oxideqdownloadrequest_p.h',228 'api/oxideqdownloadrequest_p.h',
228 'api/oxideqglobal.cc',229 'api/oxideqglobal.cc',
229 'api/oxideqglobal.h',230 'api/oxideqglobal.h',
231 'api/oxideqhttpauthenticationrequest.cc',
232 'api/oxideqhttpauthenticationrequest.h',
233 'api/oxideqhttpauthenticationrequest_p.h',
230 'api/oxideqloadevent.cc',234 'api/oxideqloadevent.cc',
231 'api/oxideqloadevent.h',235 'api/oxideqloadevent.h',
232 'api/oxideqloadevent_p.h',236 'api/oxideqloadevent_p.h',
@@ -272,6 +276,11 @@
272 'includes': [ 'moc.gypi' ]276 'includes': [ 'moc.gypi' ]
273 },277 },
274 {278 {
279 'action_name': 'moc_oxideqhttpauthenticationrequest.cc',
280 'moc_input': 'api/oxideqhttpauthenticationrequest.h',
281 'includes': [ 'moc.gypi' ]
282 },
283 {
275 'action_name': 'moc_oxideqloadevent.cc',284 'action_name': 'moc_oxideqloadevent.cc',
276 'moc_input': 'api/oxideqloadevent.h',285 'moc_input': 'api/oxideqloadevent.h',
277 'includes': [ 'moc.gypi' ]286 'includes': [ 'moc.gypi' ]
278287
=== modified file 'qt/core/glue/oxide_qt_web_view_proxy_client.h'
--- qt/core/glue/oxide_qt_web_view_proxy_client.h 2015-05-27 20:56:59 +0000
+++ qt/core/glue/oxide_qt_web_view_proxy_client.h 2015-06-18 16:37:15 +0000
@@ -32,6 +32,7 @@
32class OxideQMediaAccessPermissionRequest;32class OxideQMediaAccessPermissionRequest;
33class OxideQNavigationRequest;33class OxideQNavigationRequest;
34class OxideQNewViewRequest;34class OxideQNewViewRequest;
35class OxideQHttpAuthenticationRequest;
3536
36QT_BEGIN_NAMESPACE37QT_BEGIN_NAMESPACE
37class QCursor;38class QCursor;
@@ -139,6 +140,9 @@
139140
140 virtual void DownloadRequested(OxideQDownloadRequest* download_request) = 0;141 virtual void DownloadRequested(OxideQDownloadRequest* download_request) = 0;
141142
143 virtual void HttpAuthenticationRequested(
144 OxideQHttpAuthenticationRequest* authentication_request) = 0;
145
142 virtual void CertificateError(OxideQCertificateError* cert_error) = 0;146 virtual void CertificateError(OxideQCertificateError* cert_error) = 0;
143147
144 virtual void ContentBlocked() = 0; // XXX(chrisccoulson): Rename to BlockedContentChanged throughout Oxide148 virtual void ContentBlocked() = 0; // XXX(chrisccoulson): Rename to BlockedContentChanged throughout Oxide
145149
=== modified file 'qt/qmlplugin/oxide_qml_plugin.cc'
--- qt/qmlplugin/oxide_qml_plugin.cc 2015-06-05 18:43:21 +0000
+++ qt/qmlplugin/oxide_qml_plugin.cc 2015-06-18 16:37:15 +0000
@@ -25,6 +25,7 @@
25#include "qt/core/api/oxideqcertificateerror.h"25#include "qt/core/api/oxideqcertificateerror.h"
26#include "qt/core/api/oxideqdownloadrequest.h"26#include "qt/core/api/oxideqdownloadrequest.h"
27#include "qt/core/api/oxideqfindcontroller.h"27#include "qt/core/api/oxideqfindcontroller.h"
28#include "qt/core/api/oxideqhttpauthenticationrequest.h"
28#include "qt/core/api/oxideqloadevent.h"29#include "qt/core/api/oxideqloadevent.h"
29#include "qt/core/api/oxideqnavigationrequest.h"30#include "qt/core/api/oxideqnavigationrequest.h"
30#include "qt/core/api/oxideqnewviewrequest.h"31#include "qt/core/api/oxideqnewviewrequest.h"
@@ -136,6 +137,10 @@
136 qmlRegisterType<OxideQQuickWebView, 4>(uri, 1, 8, "WebView");137 qmlRegisterType<OxideQQuickWebView, 4>(uri, 1, 8, "WebView");
137138
138 qmlRegisterType<OxideQQuickWebContext, 3>(uri, 1, 9, "WebContext");139 qmlRegisterType<OxideQQuickWebContext, 3>(uri, 1, 9, "WebContext");
140
141 qmlRegisterUncreatableType<OxideQHttpAuthenticationRequest>(uri, 1, 9, "HttpAuthenticationRequest",
142 "HttpAuthenticationRequest is delivered by WebView.httpAuthenticationRequested");
143 qmlRegisterType<OxideQQuickWebView, 5>(uri, 1, 9, "WebView");
139 }144 }
140};145};
141146
142147
=== modified file 'qt/quick/api/oxideqquickwebview.cc'
--- qt/quick/api/oxideqquickwebview.cc 2015-05-28 23:51:39 +0000
+++ qt/quick/api/oxideqquickwebview.cc 2015-06-18 16:37:15 +0000
@@ -43,6 +43,7 @@
43#include "qt/core/api/oxideqcertificateerror.h"43#include "qt/core/api/oxideqcertificateerror.h"
44#include "qt/core/api/oxideqfindcontroller.h"44#include "qt/core/api/oxideqfindcontroller.h"
45#include "qt/core/api/oxideqglobal.h"45#include "qt/core/api/oxideqglobal.h"
46#include "qt/core/api/oxideqhttpauthenticationrequest.h"
46#include "qt/core/api/oxideqloadevent.h"47#include "qt/core/api/oxideqloadevent.h"
47#include "qt/core/api/oxideqnewviewrequest.h"48#include "qt/core/api/oxideqnewviewrequest.h"
48#include "qt/core/api/oxideqpermissionrequest.h"49#include "qt/core/api/oxideqpermissionrequest.h"
@@ -461,6 +462,31 @@
461462
462}463}
463464
465void OxideQQuickWebViewPrivate::HttpAuthenticationRequested(
466 OxideQHttpAuthenticationRequest* authentication_request) {
467 Q_Q(OxideQQuickWebView);
468
469 // See the comment in RequestGeolocationPermission
470
471 QQmlEngine* engine = qmlEngine(q);
472 if (!engine) {
473 delete authentication_request;
474 return;
475 }
476
477 {
478 QJSValue val = engine->newQObject(authentication_request);
479 if (!val.isQObject()) {
480 delete authentication_request;
481 return;
482 }
483
484 emit q->httpAuthenticationRequested(val);
485 }
486
487 engine->collectGarbage();
488}
489
464void OxideQQuickWebViewPrivate::HandleUnhandledKeyboardEvent(490void OxideQQuickWebViewPrivate::HandleUnhandledKeyboardEvent(
465 QKeyEvent* event) {491 QKeyEvent* event) {
466 Q_Q(OxideQQuickWebView);492 Q_Q(OxideQQuickWebView);
467493
=== modified file 'qt/quick/api/oxideqquickwebview_p.h'
--- qt/quick/api/oxideqquickwebview_p.h 2015-05-28 23:51:39 +0000
+++ qt/quick/api/oxideqquickwebview_p.h 2015-06-18 16:37:15 +0000
@@ -356,6 +356,7 @@
356 Q_REVISION(2) void prepareToCloseResponse(bool proceed);356 Q_REVISION(2) void prepareToCloseResponse(bool proceed);
357 Q_REVISION(2) void closeRequested();357 Q_REVISION(2) void closeRequested();
358 Q_REVISION(4) void webProcessStatusChanged();358 Q_REVISION(4) void webProcessStatusChanged();
359 Q_REVISION(5) void httpAuthenticationRequested(const QJSValue& request);
359360
360 // Deprecated since 1.3361 // Deprecated since 1.3
361 void loadingChanged(OxideQLoadEvent* loadEvent);362 void loadingChanged(OxideQLoadEvent* loadEvent);
362363
=== modified file 'qt/quick/api/oxideqquickwebview_p_p.h'
--- qt/quick/api/oxideqquickwebview_p_p.h 2015-05-28 23:51:39 +0000
+++ qt/quick/api/oxideqquickwebview_p_p.h 2015-06-18 16:37:15 +0000
@@ -135,6 +135,8 @@
135 void EvictCurrentFrame() override;135 void EvictCurrentFrame() override;
136 void SetInputMethodEnabled(bool enabled) override;136 void SetInputMethodEnabled(bool enabled) override;
137 void DownloadRequested(OxideQDownloadRequest* download_request) override;137 void DownloadRequested(OxideQDownloadRequest* download_request) override;
138 void HttpAuthenticationRequested(
139 OxideQHttpAuthenticationRequest* authentication_request) override;
138 void CertificateError(OxideQCertificateError* cert_error) override;140 void CertificateError(OxideQCertificateError* cert_error) override;
139 void ContentBlocked() override;141 void ContentBlocked() override;
140 void PrepareToCloseResponse(bool proceed) override;142 void PrepareToCloseResponse(bool proceed) override;
141143
=== modified file 'qt/tests/qmltests/TestWebView.qml'
--- qt/tests/qmltests/TestWebView.qml 2015-05-15 15:03:10 +0000
+++ qt/tests/qmltests/TestWebView.qml 2015-06-18 16:37:15 +0000
@@ -1,6 +1,6 @@
1import QtQuick 2.01import QtQuick 2.0
2import QtTest 1.02import QtTest 1.0
3import com.canonical.Oxide 1.83import com.canonical.Oxide 1.9
4import com.canonical.Oxide.Testing 1.0 as Testing4import com.canonical.Oxide.Testing 1.0 as Testing
5import "TestUtils.js" as TestUtils5import "TestUtils.js" as TestUtils
66
77
=== added file 'qt/tests/qmltests/api/tst_httpAuthentication.py'
--- qt/tests/qmltests/api/tst_httpAuthentication.py 1970-01-01 00:00:00 +0000
+++ qt/tests/qmltests/api/tst_httpAuthentication.py 2015-06-18 16:37:15 +0000
@@ -0,0 +1,31 @@
1from cStringIO import StringIO
2import base64
3
4def handler(request):
5 html = StringIO()
6
7 def send_401():
8 request.send_response(401)
9 request.send_header("WWW-Authenticate", "Basic realm=\"Fake Realm\"")
10 request.send_header("Cache-Control", "no-store")
11 request.send_header("Content-Length", html.tell())
12 request.end_headers()
13
14 if "Authorization" in request.headers:
15 user, password = request.path.split("?")[1].split("_")
16 header = request.headers["Authorization"]
17 credentials = base64.b64decode(header[len("Basic "):]).split(":")
18 if credentials[0] == user and credentials[1] == password:
19 html.write("Authentication success")
20 request.send_response(200)
21 request.send_header("Cache-Control", "no-store")
22 request.send_header("Content-Length", html.tell())
23 request.end_headers()
24 else:
25 html.write("Wrong credentials")
26 send_401()
27 else:
28 html.write("Requested credentials")
29 send_401()
30
31 request.wfile.write(html.getvalue())
032
=== added file 'qt/tests/qmltests/api/tst_httpAuthentication.qml'
--- qt/tests/qmltests/api/tst_httpAuthentication.qml 1970-01-01 00:00:00 +0000
+++ qt/tests/qmltests/api/tst_httpAuthentication.qml 2015-06-18 16:37:15 +0000
@@ -0,0 +1,142 @@
1import QtQuick 2.0
2import QtTest 1.0
3import com.canonical.Oxide 1.9
4import com.canonical.Oxide.Testing 1.0
5
6TestWebView {
7 id: webView
8 width: 200
9 height: 200
10
11 property var lastRequest
12 property int lastStatusCode: -1
13 property int totalRequests: 0
14 property int expectedRequests: 0
15 property int totalCancellations: 0
16 property int expectedCancellations: 0
17 property bool ignoreRequests: false
18
19 // Since the browser caches credentials after the first successful
20 // authentication, we make sure to use a different username for every test
21 property string baseUrl: "http://testsuite/tst_httpAuthentication.py"
22 property int userNameSuffix: 0
23 property string currentUser: "user" + userNameSuffix
24 property string credentialsUrl: baseUrl + "?" + currentUser + "_pass"
25
26 onHttpAuthenticationRequested: {
27 if (!ignoreRequests) {
28 lastRequest = request
29 lastRequest.cancelled.connect(updateCancellations)
30 }
31 totalRequests++
32 }
33
34 onLoadEvent: lastStatusCode = event.httpStatusCode
35
36 function updateCancellations() { totalCancellations++ }
37
38 TestCase {
39 id: test
40 name: "httpAuthentication"
41 when: windowShown
42
43 function init() {
44 ignoreRequests = false
45 if (lastRequest) {
46 lastRequest.cancelled.disconnect(updateCancellations)
47 lastRequest = null
48 }
49 webView.url = "about:blank";
50 verify(webView.waitForLoadSucceeded());
51 totalRequests = 0
52 expectedRequests = 0
53 totalCancellations = 0
54 expectedCancellations = 0
55 lastStatusCode = -1
56 userNameSuffix++
57 }
58
59 function receivedRequest() {
60 return totalRequests == expectedRequests
61 }
62
63 function receivedCancellation() {
64 return totalCancellations == expectedCancellations
65 }
66
67 function test_requestMembers() {
68 expectedRequests++
69 webView.url = credentialsUrl
70 verify(waitFor(receivedRequest), "No authentication request")
71 compare(lastRequest.realm, "Fake Realm")
72 compare(lastRequest.host, "testsuite:80")
73 }
74
75 function test_wrong_password() {
76 expectedRequests++
77 webView.url = credentialsUrl
78 verify(waitFor(receivedRequest), "No authentication request")
79 expectedRequests++
80 lastRequest.allow(currentUser, "wrong")
81 verify(waitFor(receivedRequest), "No authentication request")
82 }
83
84 function test_wrong_username() {
85 expectedRequests++
86 webView.url = credentialsUrl
87 verify(waitFor(receivedRequest), "No authentication request")
88 expectedRequests++
89 lastRequest.allow(currentUser + "_wrong", "pass")
90 verify(waitFor(receivedRequest), "No authentication request")
91 }
92
93 function test_right_credentials() {
94 expectedRequests++
95 webView.url = credentialsUrl
96 verify(waitFor(receivedRequest), "No authentication request")
97 lastRequest.allow(currentUser, "pass")
98 webView.waitForLoadSucceeded()
99 compare(lastStatusCode, 200)
100 compare(expectedRequests, totalRequests)
101 }
102
103 function test_explicit_cancellation() {
104 webView.url = credentialsUrl
105 expectedRequests++
106 verify(waitFor(receivedRequest), "No authentication request")
107
108 lastRequest.deny()
109 webView.waitForLoadSucceeded()
110 compare(lastStatusCode, 401)
111 // when cancelling explicity we should not receive cancellation signals
112 compare(totalCancellations, 0)
113 }
114
115 function test_cancel_by_navigation() {
116 webView.url = credentialsUrl
117 expectedRequests++
118 verify(waitFor(receivedRequest), "No authentication request")
119
120 expectedCancellations++
121 webView.url = "about:blank"
122 verify(waitFor(receivedCancellation), "Authentication not cancelled")
123
124 webView.waitForLoadSucceeded()
125 compare(expectedRequests, totalRequests)
126 }
127
128 function test_ignored_request_cancelled() {
129 ignoreRequests = true
130 webView.url = credentialsUrl
131 expectedRequests++
132 verify(waitFor(receivedRequest), "No authentication request")
133
134 // force garbage collection so the request object will be destroyed
135 // as we did not keep any reference to it.
136 // the request destructor will call request.deny()
137 gc()
138 webView.waitForLoadSucceeded()
139 compare(lastStatusCode, 401)
140 }
141 }
142}
0143
=== modified file 'shared/browser/oxide_resource_dispatcher_host_delegate.cc'
--- shared/browser/oxide_resource_dispatcher_host_delegate.cc 2015-06-06 10:38:48 +0000
+++ shared/browser/oxide_resource_dispatcher_host_delegate.cc 2015-06-18 16:37:15 +0000
@@ -18,12 +18,14 @@
18#include "oxide_resource_dispatcher_host_delegate.h"18#include "oxide_resource_dispatcher_host_delegate.h"
1919
20#include "base/bind.h"20#include "base/bind.h"
21#include "base/callback.h"
22#include "base/logging.h"21#include "base/logging.h"
23#include "base/strings/utf_string_conversions.h"22#include "base/strings/utf_string_conversions.h"
24#include "content/public/browser/browser_thread.h"23#include "content/public/browser/browser_thread.h"
24#include "content/public/browser/render_frame_host.h"
25#include "content/public/browser/render_view_host.h"25#include "content/public/browser/render_view_host.h"
26#include "content/public/browser/resource_dispatcher_host.h"
26#include "content/public/browser/resource_context.h"27#include "content/public/browser/resource_context.h"
28#include "content/public/browser/resource_request_info.h"
27#include "content/public/common/referrer.h"29#include "content/public/common/referrer.h"
28#include "net/base/mime_util.h"30#include "net/base/mime_util.h"
29#include "net/cookies/cookie_monster.h"31#include "net/cookies/cookie_monster.h"
@@ -37,6 +39,7 @@
37#include "oxide_browser_context_delegate.h"39#include "oxide_browser_context_delegate.h"
38#include "oxide_browser_platform_integration.h"40#include "oxide_browser_platform_integration.h"
39#include "oxide_redirection_intercept_throttle.h"41#include "oxide_redirection_intercept_throttle.h"
42#include "oxide_resource_dispatcher_host_login_delegate.h"
40#include "oxide_web_view.h"43#include "oxide_web_view.h"
4144
42namespace oxide {45namespace oxide {
@@ -193,8 +196,8 @@
193 params.render_process_id, params.render_view_id);196 params.render_process_id, params.render_view_id);
194 if (!rvh) {197 if (!rvh) {
195 LOG(ERROR) << "Invalid or non-existent render_process_id & render_view_id:"198 LOG(ERROR) << "Invalid or non-existent render_process_id & render_view_id:"
196 << params.render_process_id << ", " << params.render_view_id199 << params.render_process_id << ", " << params.render_view_id
197 << "during download url delegate dispatch";200 << "during download url delegate dispatch";
198 return;201 return;
199 }202 }
200203
@@ -239,6 +242,14 @@
239 return BrowserPlatformIntegration::GetInstance()->LaunchURLExternally(url);242 return BrowserPlatformIntegration::GetInstance()->LaunchURLExternally(url);
240}243}
241244
245content::ResourceDispatcherHostLoginDelegate*
246 ResourceDispatcherHostDelegate::CreateLoginDelegate(
247 net::AuthChallengeInfo* auth_info,
248 net::URLRequest* request) {
249 // Chromium will own the delegate
250 return new ResourceDispatcherHostLoginDelegate(auth_info, request);
251}
252
242ResourceDispatcherHostDelegate::ResourceDispatcherHostDelegate() {}253ResourceDispatcherHostDelegate::ResourceDispatcherHostDelegate() {}
243254
244ResourceDispatcherHostDelegate::~ResourceDispatcherHostDelegate() {}255ResourceDispatcherHostDelegate::~ResourceDispatcherHostDelegate() {}
245256
=== modified file 'shared/browser/oxide_resource_dispatcher_host_delegate.h'
--- shared/browser/oxide_resource_dispatcher_host_delegate.h 2015-06-02 15:31:02 +0000
+++ shared/browser/oxide_resource_dispatcher_host_delegate.h 2015-06-18 16:37:15 +0000
@@ -18,6 +18,7 @@
18#ifndef _OXIDE_SHARED_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_18#ifndef _OXIDE_SHARED_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_
19#define _OXIDE_SHARED_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_19#define _OXIDE_SHARED_BROWSER_RESOURCE_DISPATCHER_HOST_DELEGATE_H_
2020
21#include "base/callback.h"
21#include "base/macros.h"22#include "base/macros.h"
22#include "base/strings/string16.h"23#include "base/strings/string16.h"
23#include "content/public/browser/resource_dispatcher_host_delegate.h"24#include "content/public/browser/resource_dispatcher_host_delegate.h"
@@ -35,6 +36,8 @@
3536
36namespace oxide {37namespace oxide {
3738
39class ResourceDispatcherHostLoginDelegate;
40
38class ResourceDispatcherHostDelegate41class ResourceDispatcherHostDelegate
39 : public content::ResourceDispatcherHostDelegate {42 : public content::ResourceDispatcherHostDelegate {
40 public:43 public:
@@ -89,6 +92,11 @@
89 ui::PageTransition page_transition,92 ui::PageTransition page_transition,
90 bool has_user_gesture) override;93 bool has_user_gesture) override;
9194
95 content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(
96 net::AuthChallengeInfo* auth_info,
97 net::URLRequest* request) override;
98
99private:
92 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostDelegate);100 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostDelegate);
93};101};
94102
95103
=== added file 'shared/browser/oxide_resource_dispatcher_host_login_delegate.cc'
--- shared/browser/oxide_resource_dispatcher_host_login_delegate.cc 1970-01-01 00:00:00 +0000
+++ shared/browser/oxide_resource_dispatcher_host_login_delegate.cc 2015-06-18 16:37:15 +0000
@@ -0,0 +1,162 @@
1// vim:expandtab:shiftwidth=2:tabstop=2:
2// Copyright (C) 2014-2015 Canonical Ltd.
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18#include "oxide_resource_dispatcher_host_login_delegate.h"
19
20#include "base/bind.h"
21#include "base/logging.h"
22#include "base/strings/utf_string_conversions.h"
23#include "content/public/browser/browser_thread.h"
24#include "content/public/browser/render_frame_host.h"
25#include "content/public/browser/resource_dispatcher_host.h"
26#include "content/public/browser/resource_context.h"
27#include "content/public/browser/resource_request_info.h"
28#include "net/base/auth.h"
29#include "net/url_request/url_request.h"
30
31#include "oxide_web_view.h"
32
33namespace oxide {
34
35ResourceDispatcherHostLoginDelegate::ResourceDispatcherHostLoginDelegate(
36 net::AuthChallengeInfo* auth_info,
37 net::URLRequest* request)
38 : request_(request) {
39 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
40
41 host_ = auth_info->challenger.ToString();
42 realm_ = auth_info->realm;
43
44 WebView* webview = GetWebView(request_);
45 if (!webview) {
46 // Deny the request if we can not get access to the webview, as there is
47 // no other sensible thing to do.
48 Deny();
49 return;
50 }
51
52 content::BrowserThread::PostTask(
53 content::BrowserThread::UI,
54 FROM_HERE,
55 base::Bind(&ResourceDispatcherHostLoginDelegate::DispatchRequest,
56 this, webview));
57}
58
59ResourceDispatcherHostLoginDelegate::~ResourceDispatcherHostLoginDelegate() {}
60
61void ResourceDispatcherHostLoginDelegate::SetCancelledCallback(
62 const base::Closure& cancelled_callback) {
63 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
64
65 cancelled_callback_ = cancelled_callback;
66}
67
68void ResourceDispatcherHostLoginDelegate::OnRequestCancelled() {
69 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
70
71 request_ = nullptr;
72
73 content::BrowserThread::PostTask(
74 content::BrowserThread::UI,
75 FROM_HERE,
76 base::Bind(&ResourceDispatcherHostLoginDelegate::DispatchCancelledCallback,
77 this));
78}
79
80void ResourceDispatcherHostLoginDelegate::DispatchCancelledCallback() {
81 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
82
83 if (!cancelled_callback_.is_null()) {
84 content::BrowserThread::PostTask(
85 content::BrowserThread::UI,
86 FROM_HERE,
87 cancelled_callback_);
88 }
89}
90
91void ResourceDispatcherHostLoginDelegate::Deny() {
92 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
93 content::BrowserThread::PostTask(
94 content::BrowserThread::IO,
95 FROM_HERE,
96 base::Bind(&ResourceDispatcherHostLoginDelegate::Deny, this));
97 return;
98 }
99
100 if (!request_) {
101 return;
102 }
103
104 request_->CancelAuth();
105 content::ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(
106 request_);
107 request_ = nullptr;
108}
109
110void ResourceDispatcherHostLoginDelegate::Allow(const std::string &username,
111 const std::string &password)
112{
113 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
114 content::BrowserThread::PostTask(
115 content::BrowserThread::IO,
116 FROM_HERE,
117 base::Bind(&ResourceDispatcherHostLoginDelegate::Allow, this,
118 username, password));
119 return;
120 }
121
122 if (!request_) {
123 return;
124 }
125
126 request_->SetAuth(net::AuthCredentials(base::UTF8ToUTF16(username),
127 base::UTF8ToUTF16(password)));
128 content::ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(
129 request_);
130 request_ = nullptr;
131}
132
133WebView* ResourceDispatcherHostLoginDelegate::GetWebView(
134 net::URLRequest* request) {
135 int processId;
136 int frameId;
137 content::ResourceRequestInfo::GetRenderFrameForRequest(request, &processId,
138 &frameId);
139 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID(processId,
140 frameId);
141 if (!rfh) {
142 return nullptr;
143 }
144
145 return WebView::FromRenderFrameHost(rfh);
146}
147
148void ResourceDispatcherHostLoginDelegate::DispatchRequest(WebView* webview) {
149 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
150
151 webview->HttpAuthenticationRequested(this);
152}
153
154std::string ResourceDispatcherHostLoginDelegate::Host() const {
155 return host_;
156}
157
158std::string ResourceDispatcherHostLoginDelegate::Realm() const {
159 return realm_;
160}
161
162} // namespace oxide
0163
=== added file 'shared/browser/oxide_resource_dispatcher_host_login_delegate.h'
--- shared/browser/oxide_resource_dispatcher_host_login_delegate.h 1970-01-01 00:00:00 +0000
+++ shared/browser/oxide_resource_dispatcher_host_login_delegate.h 2015-06-18 16:37:15 +0000
@@ -0,0 +1,65 @@
1// vim:expandtab:shiftwidth=2:tabstop=2:
2// Copyright (C) 2014-2015 Canonical Ltd.
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18#ifndef _OXIDE_SHARED_BROWSER_RESOURCE_DISPATCHER_HOST_LOGIN_DELEGATE_H_
19#define _OXIDE_SHARED_BROWSER_RESOURCE_DISPATCHER_HOST_LOGIN_DELEGATE_H_
20
21#include "base/callback.h"
22#include "content/public/browser/resource_dispatcher_host_login_delegate.h"
23
24namespace net {
25class URLRequest;
26class AuthChallengeInfo;
27}
28
29namespace oxide {
30
31class ResourceDispatcherHostDelegate;
32class WebView;
33
34class ResourceDispatcherHostLoginDelegate
35 : public content::ResourceDispatcherHostLoginDelegate {
36 public:
37 ResourceDispatcherHostLoginDelegate(net::AuthChallengeInfo* auth_info,
38 net::URLRequest* request);
39 ~ResourceDispatcherHostLoginDelegate() override;
40 void OnRequestCancelled() override;
41
42 void Deny();
43 void Allow(const std::string& username, const std::string& password);
44
45 void SetCancelledCallback(const base::Closure& cancelled_callback);
46
47 std::string Host() const;
48 std::string Realm() const;
49
50private:
51 friend class ResourceDispatcherHostDelegate;
52 void DispatchRequest(WebView* webview);
53 void DispatchCancelledCallback();
54 WebView* GetWebView(net::URLRequest* request);
55
56 net::URLRequest* request_;
57 std::string host_;
58 std::string realm_;
59 base::Closure cancelled_callback_;
60};
61
62} // namespace oxide
63
64#endif // OXIDE_SHARED_BROWSER_RESOURCE_DISPATCHER_HOST_LOGIN_DELEGATE
65
066
=== modified file 'shared/browser/oxide_web_view.cc'
--- shared/browser/oxide_web_view.cc 2015-06-17 21:04:11 +0000
+++ shared/browser/oxide_web_view.cc 2015-06-18 16:37:15 +0000
@@ -1269,7 +1269,7 @@
1269 DCHECK(root_frame_.get());1269 DCHECK(root_frame_.get());
12701270
1271 if (params->context && init_data_->load_params) {1271 if (params->context && init_data_->load_params) {
1272 web_contents_->GetController().LoadURLWithParams(*init_data_->load_params); 1272 web_contents_->GetController().LoadURLWithParams(*init_data_->load_params);
1273 }1273 }
12741274
1275 web_contents_->GetController().LoadIfNecessary();1275 web_contents_->GetController().LoadIfNecessary();
@@ -2100,6 +2100,11 @@
2100 user_agent);2100 user_agent);
2101}2101}
21022102
2103void WebView::HttpAuthenticationRequested(
2104 ResourceDispatcherHostLoginDelegate* login_delegate) {
2105 client_->HttpAuthenticationRequested(login_delegate);
2106}
2107
2103CompositorFrameHandle* WebView::GetCompositorFrameHandle() const {2108CompositorFrameHandle* WebView::GetCompositorFrameHandle() const {
2104 return current_compositor_frame_.get();2109 return current_compositor_frame_.get();
2105}2110}
21062111
=== modified file 'shared/browser/oxide_web_view.h'
--- shared/browser/oxide_web_view.h 2015-06-11 13:06:02 +0000
+++ shared/browser/oxide_web_view.h 2015-06-18 16:37:15 +0000
@@ -98,6 +98,7 @@
98class CompositorFrameHandle;98class CompositorFrameHandle;
99class FilePicker;99class FilePicker;
100class JavaScriptDialog;100class JavaScriptDialog;
101class ResourceDispatcherHostLoginDelegate;
101class RenderWidgetHostView;102class RenderWidgetHostView;
102class WebContextMenu;103class WebContextMenu;
103class WebFrame;104class WebFrame;
@@ -310,6 +311,9 @@
310 const std::string& referrer,311 const std::string& referrer,
311 const std::string& user_agent);312 const std::string& user_agent);
312313
314 void HttpAuthenticationRequested(
315 ResourceDispatcherHostLoginDelegate* login_delegate);
316
313 CompositorFrameHandle* GetCompositorFrameHandle() const;317 CompositorFrameHandle* GetCompositorFrameHandle() const;
314 void DidCommitCompositorFrame();318 void DidCommitCompositorFrame();
315319
316320
=== modified file 'shared/browser/oxide_web_view_client.cc'
--- shared/browser/oxide_web_view_client.cc 2015-06-04 13:21:49 +0000
+++ shared/browser/oxide_web_view_client.cc 2015-06-18 16:37:15 +0000
@@ -168,4 +168,7 @@
168168
169void WebViewClient::FindInPageCountChanged() {}169void WebViewClient::FindInPageCountChanged() {}
170170
171void WebViewClient::HttpAuthenticationRequested(
172 ResourceDispatcherHostLoginDelegate* login_delegate) {}
173
171} // namespace oxide174} // namespace oxide
172175
=== modified file 'shared/browser/oxide_web_view_client.h'
--- shared/browser/oxide_web_view_client.h 2015-06-04 13:21:49 +0000
+++ shared/browser/oxide_web_view_client.h 2015-06-18 16:37:15 +0000
@@ -48,6 +48,7 @@
48class CertificateError;48class CertificateError;
49class FilePicker;49class FilePicker;
50class JavaScriptDialog;50class JavaScriptDialog;
51class ResourceDispatcherHostLoginDelegate;
51class SecurityStatus;52class SecurityStatus;
52class WebContextMenu;53class WebContextMenu;
53class WebFrame;54class WebFrame;
@@ -206,6 +207,9 @@
206207
207 virtual void FindInPageCurrentChanged();208 virtual void FindInPageCurrentChanged();
208 virtual void FindInPageCountChanged();209 virtual void FindInPageCountChanged();
210
211 virtual void HttpAuthenticationRequested(
212 ResourceDispatcherHostLoginDelegate* login_delegate);
209};213};
210214
211} // namespace oxide215} // namespace oxide
212216
=== modified file 'shared/shared.gyp'
--- shared/shared.gyp 2015-06-10 13:10:39 +0000
+++ shared/shared.gyp 2015-06-18 16:37:15 +0000
@@ -370,6 +370,8 @@
370 'browser/oxide_render_widget_host_view_delegate.h',370 'browser/oxide_render_widget_host_view_delegate.h',
371 'browser/oxide_resource_dispatcher_host_delegate.cc',371 'browser/oxide_resource_dispatcher_host_delegate.cc',
372 'browser/oxide_resource_dispatcher_host_delegate.h',372 'browser/oxide_resource_dispatcher_host_delegate.h',
373 'browser/oxide_resource_dispatcher_host_login_delegate.cc',
374 'browser/oxide_resource_dispatcher_host_login_delegate.h',
373 'browser/oxide_script_message_dispatcher_browser.cc',375 'browser/oxide_script_message_dispatcher_browser.cc',
374 'browser/oxide_script_message_dispatcher_browser.h',376 'browser/oxide_script_message_dispatcher_browser.h',
375 'browser/oxide_script_message_impl_browser.cc',377 'browser/oxide_script_message_impl_browser.cc',

Subscribers

People subscribed via source and target branches

to all changes: