diff options
Diffstat (limited to 'src/core/web_contents_delegate_qt.cpp')
-rw-r--r-- | src/core/web_contents_delegate_qt.cpp | 93 |
1 files changed, 67 insertions, 26 deletions
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index c2cccfedb..03e03acc3 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -40,6 +40,7 @@ #include "web_contents_delegate_qt.h" +#include "browser_context_adapter.h" #include "media_capture_devices_dispatcher.h" #include "type_conversion.h" #include "web_contents_adapter_client.h" @@ -52,12 +53,13 @@ #include "content/public/browser/invalidate_type.h" #include "content/public/browser/navigation_entry.h" #include "content/public/browser/render_view_host.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" #include "content/public/common/favicon_url.h" #include "content/public/common/file_chooser_params.h" #include "content/public/common/frame_navigate_params.h" #include "content/public/common/url_constants.h" -#include "webkit/common/webpreferences.h" +#include "content/public/common/web_preferences.h" // Maps the LogSeverity defines in base/logging.h to the web engines message levels. static WebContentsAdapterClient::JavaScriptConsoleMessageLevel mapToJavascriptConsoleMessageLevel(int32 messageLevel) { @@ -83,7 +85,7 @@ content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents if (params.disposition != CURRENT_TAB) { WebContentsAdapter *targetAdapter = createWindow(0, params.disposition, gfx::Rect(), params.user_gesture); if (targetAdapter) - target = targetAdapter->d_func()->webContents.get(); + target = targetAdapter->webContents(); } content::NavigationController::LoadURLParams load_url_params(params.url); @@ -101,7 +103,7 @@ content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents return target; } -void WebContentsDelegateQt::NavigationStateChanged(const content::WebContents* source, unsigned changed_flags) +void WebContentsDelegateQt::NavigationStateChanged(const content::WebContents* source, content::InvalidateTypes changed_flags) { if (changed_flags & content::INVALIDATE_TYPE_URL) m_viewClient->urlChanged(toQt(source->GetVisibleURL())); @@ -129,21 +131,28 @@ void WebContentsDelegateQt::LoadProgressChanged(content::WebContents* source, do m_viewClient->loadProgressChanged(qRound(progress * 100)); } -void WebContentsDelegateQt::DidStartProvisionalLoadForFrame(int64 frame_id, int64 parent_frame_id, bool is_main_frame, const GURL &validated_url, bool isErrorPage, bool, content::RenderViewHost*) +void WebContentsDelegateQt::HandleKeyboardEvent(content::WebContents *, const content::NativeWebKeyboardEvent &event) { - if (isErrorPage) { - m_loadingErrorFrameList.append(frame_id); + Q_ASSERT(!event.skip_in_browser); + if (event.os_event) + m_viewClient->unhandledKeyEvent(reinterpret_cast<QKeyEvent *>(event.os_event)); +} + +void WebContentsDelegateQt::DidStartProvisionalLoadForFrame(content::RenderFrameHost* render_frame_host, const GURL& validated_url, bool is_error_page, bool is_iframe_srcdoc) +{ + if (is_error_page) { + m_loadingErrorFrameList.append(render_frame_host->GetRoutingID()); return; } - if (!is_main_frame) + if (render_frame_host->GetParent()) return; m_loadingErrorFrameList.clear(); m_viewClient->loadStarted(toQt(validated_url)); } -void WebContentsDelegateQt::DidCommitProvisionalLoadForFrame(int64 frame_id, const base::string16& frame_unique_name, bool is_main_frame, const GURL& url, content::PageTransition transition_type, content::RenderViewHost* render_view_host) +void WebContentsDelegateQt::DidCommitProvisionalLoadForFrame(content::RenderFrameHost* render_frame_host, const GURL& url, ui::PageTransition transition_type) { // Make sure that we don't set the findNext WebFindOptions on a new frame. m_lastSearchedString = QString(); @@ -152,32 +161,32 @@ void WebContentsDelegateQt::DidCommitProvisionalLoadForFrame(int64 frame_id, con m_viewClient->loadCommitted(); } -void WebContentsDelegateQt::DidFailProvisionalLoad(int64 frame_id, const base::string16& frame_unique_name, bool is_main_frame, const GURL& validated_url, int error_code, const base::string16& error_description, content::RenderViewHost* render_view_host) +void WebContentsDelegateQt::DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, const base::string16& error_description) { - DidFailLoad(frame_id, validated_url, is_main_frame, error_code, error_description, render_view_host); + DidFailLoad(render_frame_host, validated_url, error_code, error_description); } -void WebContentsDelegateQt::DidFailLoad(int64 frame_id, const GURL &validated_url, bool is_main_frame, int error_code, const base::string16 &error_description, content::RenderViewHost *rvh) +void WebContentsDelegateQt::DidFailLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url, int error_code, const base::string16& error_description) { - if (m_loadingErrorFrameList.removeOne(frame_id) || !is_main_frame) + if (m_loadingErrorFrameList.removeOne(render_frame_host->GetRoutingID()) || render_frame_host->GetParent()) return; m_viewClient->loadFinished(false, toQt(validated_url), error_code, toQt(error_description)); m_viewClient->loadProgressChanged(0); } -void WebContentsDelegateQt::DidFinishLoad(int64 frame_id, const GURL &url, bool is_main_frame, content::RenderViewHost*) +void WebContentsDelegateQt::DidFinishLoad(content::RenderFrameHost* render_frame_host, const GURL& validated_url) { - if (m_loadingErrorFrameList.removeOne(frame_id)) { - Q_ASSERT(url.is_valid() && url.spec() == content::kUnreachableWebDataURL); + if (m_loadingErrorFrameList.removeOne(render_frame_host->GetRoutingID())) { + Q_ASSERT(validated_url.is_valid() && validated_url.spec() == content::kUnreachableWebDataURL); m_viewClient->iconChanged(QUrl()); return; } - if (!is_main_frame) + if (render_frame_host->GetParent()) return; - m_viewClient->loadFinished(true, toQt(url)); + m_viewClient->loadFinished(true, toQt(validated_url)); content::NavigationEntry *entry = web_contents()->GetController().GetActiveEntry(); if (!entry) @@ -222,8 +231,8 @@ bool WebContentsDelegateQt::IsFullscreenForTabOrPending(const content::WebConten return m_viewClient->isFullScreen(); } -Q_STATIC_ASSERT_X(static_cast<int>(WebContentsAdapterClient::Open) == static_cast<int>(content::FileChooserParams::Open), "Enums out of sync"); -Q_STATIC_ASSERT_X(static_cast<int>(WebContentsAdapterClient::Save) == static_cast<int>(content::FileChooserParams::Save), "Enums out of sync"); +ASSERT_ENUMS_MATCH(WebContentsAdapterClient::Open, content::FileChooserParams::Open) +ASSERT_ENUMS_MATCH(WebContentsAdapterClient::Save, content::FileChooserParams::Save) void WebContentsDelegateQt::RunFileChooser(content::WebContents *web_contents, const content::FileChooserParams ¶ms) { @@ -259,22 +268,31 @@ void WebContentsDelegateQt::RequestMediaAccessPermission(content::WebContents *w MediaCaptureDevicesDispatcher::GetInstance()->processMediaAccessRequest(m_viewClient, web_contents, request, callback); } -void WebContentsDelegateQt::UpdateTargetURL(content::WebContents *source, int32 page_id, const GURL &url) +void WebContentsDelegateQt::UpdateTargetURL(content::WebContents* source, const GURL& url) { Q_UNUSED(source) - Q_UNUSED(page_id) m_viewClient->didUpdateTargetURL(toQt(url)); } -void WebContentsDelegateQt::DidNavigateAnyFrame(const content::LoadCommittedDetails &, const content::FrameNavigateParams ¶ms) +void WebContentsDelegateQt::DidNavigateAnyFrame(content::RenderFrameHost* render_frame_host, const content::LoadCommittedDetails& details, const content::FrameNavigateParams& params) { - if (!params.should_update_history) + // VisistedLinksMaster asserts !IsOffTheRecord(). + if (!params.should_update_history || !m_viewClient->browserContextAdapter()->trackVisitedLinks()) return; - WebEngineContext::current()->visitedLinksManager()->addUrl(params.url); + m_viewClient->browserContextAdapter()->visitedLinksManager()->addUrl(params.url); } +void WebContentsDelegateQt::RequestToLockMouse(content::WebContents *web_contents, bool user_gesture, bool last_unlocked_by_target) +{ + Q_UNUSED(user_gesture); -void WebContentsDelegateQt::overrideWebPreferences(content::WebContents *, WebPreferences *webPreferences) + if (last_unlocked_by_target) + web_contents->GotResponseToLockMouseRequest(true); + else + m_viewClient->runMouseLockPermissionRequest(toQt(web_contents->GetVisibleURL())); +} + +void WebContentsDelegateQt::overrideWebPreferences(content::WebContents *, content::WebPreferences *webPreferences) { m_viewClient->webEngineSettings()->overrideWebPreferences(webPreferences); } @@ -296,7 +314,30 @@ WebContentsAdapter *WebContentsDelegateQt::createWindow(content::WebContents *ne return newAdapter; } -void WebContentsDelegateQt::allowCertificateError(const QExplicitlySharedDataPointer<CertificateErrorController> &errorController) +void WebContentsDelegateQt::allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController) { m_viewClient->allowCertificateError(errorController); } + +void WebContentsDelegateQt::requestGeolocationPermission(const GURL &requestingFrameOrigin, const base::Callback<void (bool)> &resultCallback) +{ + QUrl url = toQt(requestingFrameOrigin); + bool newRequest = !m_geolocationPermissionRequests.contains(url); + m_geolocationPermissionRequests[url] = resultCallback; + if (newRequest) + m_viewClient->runGeolocationPermissionRequest(url); +} + +void WebContentsDelegateQt::cancelGeolocationPermissionRequest(const GURL &requestingFrameOrigin) +{ + m_geolocationPermissionRequests.remove(toQt(requestingFrameOrigin)); + // FIXME: Tell the API layer to cancel the permission request? +} + +void WebContentsDelegateQt::geolocationPermissionReply(const QUrl &origin, bool permission) +{ + if (m_geolocationPermissionRequests.contains(origin)) { + m_geolocationPermissionRequests[origin].Run(permission); + m_geolocationPermissionRequests.remove(origin); + } +} |