diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-03 18:46:06 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-06-26 08:17:25 +0000 |
commit | 57c49df9c6fcbaaffc66900e191312d4e0a0edfa (patch) | |
tree | a067be82e9c367673b3f8efdbcf0a21a780b5451 /src/core/renderer_host | |
parent | 8d752cab84d437244ef0c2318b70d6516e99a044 (diff) |
Adaptations for Chromium 66
Change-Id: Iee88721a50036d4ef85a23dd1708d4fb84218708
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/core/renderer_host')
-rw-r--r-- | src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp | 39 | ||||
-rw-r--r-- | src/core/renderer_host/resource_dispatcher_host_delegate_qt.h | 21 |
2 files changed, 32 insertions, 28 deletions
diff --git a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp index 421b3167b..265386ee8 100644 --- a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp +++ b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.cpp @@ -56,26 +56,28 @@ namespace QtWebEngineCore { -ResourceDispatcherHostLoginDelegateQt::ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, net::URLRequest *request) +ResourceDispatcherHostLoginDelegateQt::ResourceDispatcherHostLoginDelegateQt( + net::AuthChallengeInfo *authInfo, + content::ResourceRequestInfo::WebContentsGetter web_contents_getter, + GURL url, + bool first_auth_attempt, + const base::Callback<void(const base::Optional<net::AuthCredentials>&)> &auth_required_callback) : m_authInfo(authInfo) - , m_request(request) + , m_url(url) + , m_auth_required_callback(auth_required_callback) { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - const content::ResourceRequestInfo *requestInfo = content::ResourceRequestInfo::ForRequest(request); - Q_ASSERT(requestInfo); content::BrowserThread::PostTask( content::BrowserThread::UI, FROM_HERE, base::Bind(&ResourceDispatcherHostLoginDelegateQt::triggerDialog, this, - requestInfo->GetWebContentsGetterForRequest())); + web_contents_getter)); } ResourceDispatcherHostLoginDelegateQt::~ResourceDispatcherHostLoginDelegateQt() { Q_ASSERT(m_dialogController.isNull()); - // We must have called ClearLoginDelegateForRequest if we didn't receive an OnRequestCancelled. - Q_ASSERT(!m_request); } void ResourceDispatcherHostLoginDelegateQt::OnRequestCancelled() @@ -85,7 +87,7 @@ void ResourceDispatcherHostLoginDelegateQt::OnRequestCancelled() QUrl ResourceDispatcherHostLoginDelegateQt::url() const { - return toQt(m_request->url()); + return toQt(m_url); } QString ResourceDispatcherHostLoginDelegateQt::realm() const @@ -120,14 +122,13 @@ void ResourceDispatcherHostLoginDelegateQt::triggerDialog(const content::Resourc void ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester(bool success, const QString &user, const QString &password) { Q_ASSERT(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); - if (!m_request) - return; - if (success) - m_request->SetAuth(net::AuthCredentials(toString16(user), toString16(password))); - else - m_request->CancelAuth(); - content::ResourceDispatcherHost::Get()->ClearLoginDelegateForRequest(m_request); + if (!m_auth_required_callback.is_null()) { + if (success) + std::move(m_auth_required_callback).Run(net::AuthCredentials(toString16(user), toString16(password))); + else + std::move(m_auth_required_callback).Run(base::nullopt); + } destroy(); } @@ -135,7 +136,7 @@ void ResourceDispatcherHostLoginDelegateQt::sendAuthToRequester(bool success, co void ResourceDispatcherHostLoginDelegateQt::destroy() { m_dialogController.reset(); - m_request = 0; + m_auth_required_callback.Reset(); } static void LaunchURL(const GURL& url, int render_process_id, @@ -169,10 +170,4 @@ bool ResourceDispatcherHostDelegateQt::HandleExternalProtocol(const GURL& url, c return true; } -content::ResourceDispatcherHostLoginDelegate *ResourceDispatcherHostDelegateQt::CreateLoginDelegate(net::AuthChallengeInfo *authInfo, net::URLRequest *request) -{ - // ResourceDispatcherHostLoginDelegateQt is ref-counted and will be released after we called ClearLoginDelegateForRequest. - return new ResourceDispatcherHostLoginDelegateQt(authInfo, request); -} - } // namespace QtWebEngineCore diff --git a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.h b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.h index c254a60f5..5bebe1599 100644 --- a/src/core/renderer_host/resource_dispatcher_host_delegate_qt.h +++ b/src/core/renderer_host/resource_dispatcher_host_delegate_qt.h @@ -42,16 +42,28 @@ #include "content/public/browser/resource_dispatcher_host_delegate.h" #include "content/public/browser/resource_dispatcher_host_login_delegate.h" +#include "url/gurl.h" #include "web_contents_adapter_client.h" +namespace net { +class AuthChallengeInfo; +class AuthCredentials; +} + namespace QtWebEngineCore { class AuthenticationDialogController; +// FIXME: move to separate file class ResourceDispatcherHostLoginDelegateQt : public content::ResourceDispatcherHostLoginDelegate { public: - ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, net::URLRequest *request); + ResourceDispatcherHostLoginDelegateQt(net::AuthChallengeInfo *authInfo, + content::ResourceRequestInfo::WebContentsGetter web_contents_getter, + GURL url, + bool first_auth_attempt, + const base::Callback<void(const base::Optional<net::AuthCredentials>&)> &auth_required_callback); + ~ResourceDispatcherHostLoginDelegateQt(); // ResourceDispatcherHostLoginDelegate implementation @@ -70,9 +82,8 @@ private: scoped_refptr<net::AuthChallengeInfo> m_authInfo; - // The request that wants login data. - // Must only be accessed on the IO thread. - net::URLRequest *m_request; + GURL m_url; + base::Callback<void(const base::Optional<net::AuthCredentials>&)> m_auth_required_callback; // This member is used to keep authentication dialog controller alive until // authorization is sent or cancelled. @@ -83,8 +94,6 @@ class ResourceDispatcherHostDelegateQt : public content::ResourceDispatcherHostD public: bool HandleExternalProtocol(const GURL& url, content::ResourceRequestInfo* info) override; - - content::ResourceDispatcherHostLoginDelegate* CreateLoginDelegate(net::AuthChallengeInfo *authInfo, net::URLRequest *request) override; }; } // namespace QtWebEngineCore |