diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-11-06 09:16:15 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-01-13 16:12:06 +0100 |
commit | c9d902ca6ca3b1aa2e2762329d18c226d26520af (patch) | |
tree | 199fdd7b3f0d0ad21597fafa086729dc2e75d4e1 /src/core/renderer | |
parent | 7869ec5823da36a3ce33b379d3d664204756cad5 (diff) |
Adaptations for Chromium 87
Change-Id: Ic4ffd98e02f986dbaf986405360e727c813e696e
Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
Diffstat (limited to 'src/core/renderer')
6 files changed, 27 insertions, 83 deletions
diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index 818b3c8f4..8dddf7a15 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -74,7 +74,6 @@ #include "third_party/blink/renderer/platform/weborigin/kurl.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/webui/jstemplate_builder.h" -#include "content/public/common/web_preferences.h" #if QT_CONFIG(webengine_printing_and_pdf) #include "renderer/print_web_view_helper_delegate_qt.h" @@ -254,11 +253,6 @@ bool ContentRendererClientQt::HasErrorPage(int httpStatusCode) return true; } -bool ContentRendererClientQt::ShouldSuppressErrorPage(content::RenderFrame *frame, const GURL &, int) -{ - return !(frame->GetWebkitPreferences().enable_error_page); -} - // To tap into the chromium localized strings. Ripped from the chrome layer (highly simplified). void ContentRendererClientQt::PrepareErrorPage(content::RenderFrame *renderFrame, const blink::WebURLError &web_error, @@ -373,19 +367,6 @@ blink::WebPlugin* ContentRendererClientQt::CreatePlugin(content::RenderFrame* re } #endif //BUILDFLAG(ENABLE_PLUGINS) -content::BrowserPluginDelegate *ContentRendererClientQt::CreateBrowserPluginDelegate(content::RenderFrame *render_frame, - const content::WebPluginInfo &info, - const std::string &mime_type, - const GURL &original_url) -{ -#if BUILDFLAG(ENABLE_EXTENSIONS) - return ExtensionsRendererClientQt::GetInstance()->CreateBrowserPluginDelegate(render_frame, info, mime_type, - original_url); -#else - return nullptr; -#endif -} - void ContentRendererClientQt::GetInterface(const std::string &interface_name, mojo::ScopedMessagePipeHandle interface_pipe) { content::RenderThread::Get()->BindHostReceiver(mojo::GenericPendingReceiver(interface_name, std::move(interface_pipe))); diff --git a/src/core/renderer/content_renderer_client_qt.h b/src/core/renderer/content_renderer_client_qt.h index bac723a4c..82d8af514 100644 --- a/src/core/renderer/content_renderer_client_qt.h +++ b/src/core/renderer/content_renderer_client_qt.h @@ -89,7 +89,6 @@ public: void RenderThreadStarted() override; void ExposeInterfacesToBrowser(mojo::BinderMap* binders) override; void RenderFrameCreated(content::RenderFrame *render_frame) override; - bool ShouldSuppressErrorPage(content::RenderFrame *, const GURL &, int) override; bool HasErrorPage(int http_status_code) override; void PrepareErrorPage(content::RenderFrame *render_frame, @@ -114,10 +113,6 @@ public: const blink::WebPluginParams ¶ms, blink::WebPlugin **plugin) override; bool IsOriginIsolatedPepperPlugin(const base::FilePath& plugin_path) override; - content::BrowserPluginDelegate *CreateBrowserPluginDelegate(content::RenderFrame *render_frame, - const content::WebPluginInfo &info, - const std::string &mime_type, - const GURL &original_url) override; void WillSendRequest(blink::WebLocalFrame *frame, ui::PageTransition transition_type, diff --git a/src/core/renderer/content_settings_observer_qt.cpp b/src/core/renderer/content_settings_observer_qt.cpp index 738d5bb87..18d52b50a 100644 --- a/src/core/renderer/content_settings_observer_qt.cpp +++ b/src/core/renderer/content_settings_observer_qt.cpp @@ -82,7 +82,7 @@ bool ContentSettingsObserverQt::OnMessageReceived(const IPC::Message &message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(ContentSettingsObserverQt, message) - IPC_MESSAGE_HANDLER(QtWebEngineMsg_RequestFileSystemAccessAsyncResponse, OnRequestFileSystemAccessAsyncResponse) + IPC_MESSAGE_HANDLER(QtWebEngineMsg_RequestStorageAccessAsyncResponse, OnRequestStorageAccessAsyncResponse) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -108,68 +108,51 @@ void ContentSettingsObserverQt::OnDestruct() delete this; } -bool ContentSettingsObserverQt::AllowDatabase() -{ - blink::WebFrame *frame = render_frame()->GetWebFrame(); - if (IsUniqueFrame(frame)) - return false; - - bool result = false; - Send(new QtWebEngineHostMsg_AllowDatabase(routing_id(), url::Origin(frame->GetSecurityOrigin()).GetURL(), - url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), &result)); - return result; -} - -void ContentSettingsObserverQt::RequestFileSystemAccessAsync(base::OnceCallback<void(bool)> callback) +void ContentSettingsObserverQt::AllowStorageAccess(StorageType storage_type, + base::OnceCallback<void(bool)> callback) { blink::WebFrame *frame = render_frame()->GetWebFrame(); if (IsUniqueFrame(frame)) { std::move(callback).Run(false); return; } + ++m_currentRequestId; bool inserted = m_permissionRequests.insert(std::make_pair(m_currentRequestId, std::move(callback))).second; // Verify there are no duplicate insertions. DCHECK(inserted); - Send(new QtWebEngineHostMsg_RequestFileSystemAccessAsync(routing_id(), m_currentRequestId, - url::Origin(frame->GetSecurityOrigin()).GetURL(), - url::Origin(frame->Top()->GetSecurityOrigin()).GetURL())); + Send(new QtWebEngineHostMsg_RequestStorageAccessAsync(routing_id(), m_currentRequestId, + url::Origin(frame->GetSecurityOrigin()).GetURL(), + url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), + int(storage_type))); } -bool ContentSettingsObserverQt::AllowIndexedDB() -{ - blink::WebFrame *frame = render_frame()->GetWebFrame(); - if (IsUniqueFrame(frame)) - return false; - - bool result = false; - Send(new QtWebEngineHostMsg_AllowIndexedDB(routing_id(), - url::Origin(frame->GetSecurityOrigin()).GetURL(), - url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), &result)); - return result; -} - -bool ContentSettingsObserverQt::AllowStorage(bool local) +bool ContentSettingsObserverQt::AllowStorageAccessSync(StorageType storage_type) { blink::WebLocalFrame *frame = render_frame()->GetWebFrame(); if (IsUniqueFrame(frame)) return false; - StoragePermissionsKey key(url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL(), local); - const auto permissions = m_cachedStoragePermissions.find(key); - if (permissions != m_cachedStoragePermissions.end()) - return permissions->second; + bool sameOrigin = url::Origin(frame->Top()->GetSecurityOrigin()).IsSameOriginWith(url::Origin(frame->GetSecurityOrigin())); + StoragePermissionsKey key(url::Origin(frame->GetSecurityOrigin()).GetURL(), int(storage_type)); + if (sameOrigin) { + const auto permissions = m_cachedStoragePermissions.find(key); + if (permissions != m_cachedStoragePermissions.end()) + return permissions->second; + } bool result = false; - Send(new QtWebEngineHostMsg_AllowDOMStorage(routing_id(), url::Origin(frame->GetSecurityOrigin()).GetURL(), - url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), local, &result)); - m_cachedStoragePermissions[key] = result; + Send(new QtWebEngineHostMsg_AllowStorageAccess(routing_id(), url::Origin(frame->GetSecurityOrigin()).GetURL(), + url::Origin(frame->Top()->GetSecurityOrigin()).GetURL(), + int(storage_type), &result)); + if (sameOrigin) + m_cachedStoragePermissions[key] = result; return result; } -void ContentSettingsObserverQt::OnRequestFileSystemAccessAsyncResponse(int request_id, bool allowed) +void ContentSettingsObserverQt::OnRequestStorageAccessAsyncResponse(int request_id, bool allowed) { auto it = m_permissionRequests.find(request_id); if (it == m_permissionRequests.end()) diff --git a/src/core/renderer/content_settings_observer_qt.h b/src/core/renderer/content_settings_observer_qt.h index a043f9e49..9268b4982 100644 --- a/src/core/renderer/content_settings_observer_qt.h +++ b/src/core/renderer/content_settings_observer_qt.h @@ -67,10 +67,9 @@ public: ~ContentSettingsObserverQt() override; // blink::WebContentSettingsClient: - bool AllowDatabase() override; - void RequestFileSystemAccessAsync(base::OnceCallback<void(bool)> callback) override; - bool AllowIndexedDB() override; - bool AllowStorage(bool local) override; + void AllowStorageAccess(StorageType storage_type, + base::OnceCallback<void(bool)> callback) override; + bool AllowStorageAccessSync(StorageType storage_type) override; private: // RenderFrameObserver implementation: @@ -79,13 +78,13 @@ private: void OnDestruct() override; // Message handlers. - void OnRequestFileSystemAccessAsyncResponse(int request_id, bool allowed); + void OnRequestStorageAccessAsyncResponse(int request_id, bool allowed); // Clears m_cachedStoragePermissions void ClearBlockedContentSettings(); // Caches the result of AllowStorage. - using StoragePermissionsKey = std::pair<GURL, bool>; + using StoragePermissionsKey = std::pair<GURL, int>; base::flat_map<StoragePermissionsKey, bool> m_cachedStoragePermissions; int m_currentRequestId; diff --git a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp index fd928df12..3d1a8685c 100644 --- a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp +++ b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp @@ -200,16 +200,6 @@ bool ExtensionsRendererClientQt::ShouldFork(blink::WebLocalFrame *frame, return false; // TODO: Fix this to a sensible value } -content::BrowserPluginDelegate *ExtensionsRendererClientQt::CreateBrowserPluginDelegate(content::RenderFrame *render_frame, - const content::WebPluginInfo &info, - const std::string &mime_type, - const GURL &original_url) -{ - if (mime_type == content::kBrowserPluginMimeType) - return new extensions::ExtensionsGuestViewContainer(render_frame); - return new extensions::MimeHandlerViewContainer(render_frame, info, mime_type, original_url); -} - void ExtensionsRendererClientQt::RunScriptsAtDocumentStart(content::RenderFrame *render_frame) { extension_dispatcher_->RunScriptsAtDocumentStart(render_frame); diff --git a/src/core/renderer/extensions/extensions_renderer_client_qt.h b/src/core/renderer/extensions/extensions_renderer_client_qt.h index 87e324213..85cc7bf2d 100644 --- a/src/core/renderer/extensions/extensions_renderer_client_qt.h +++ b/src/core/renderer/extensions/extensions_renderer_client_qt.h @@ -108,10 +108,6 @@ public: bool is_initial_navigation, bool is_server_redirect, bool *send_referrer); - static content::BrowserPluginDelegate *CreateBrowserPluginDelegate(content::RenderFrame *render_frame, - const content::WebPluginInfo &info, - const std::string &mime_type, - const GURL &original_url); bool ExtensionAPIEnabledForServiceWorkerScript(const GURL &scope, const GURL &script_url) const override; |