cef/patch/patches/chrome_plugins.patch

225 lines
9.2 KiB
Diff
Raw Normal View History

diff --git chrome/browser/plugins/plugin_info_host_impl.cc chrome/browser/plugins/plugin_info_host_impl.cc
index 7ceb1d7b854d9..5efcb8c09058c 100644
--- chrome/browser/plugins/plugin_info_host_impl.cc
+++ chrome/browser/plugins/plugin_info_host_impl.cc
@@ -16,6 +16,7 @@
#include "base/strings/utf_string_conversions.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
Add chrome runtime support for more callbacks and ceftests (see issue #2969) This change adds support for: - Protocol and request handling. - Loading and navigation events. - Display and focus events. - Mouse/keyboard events. - Popup browsers. - Callbacks in the renderer process. - Misc. functionality required for ceftests. This change also adds a new CefBrowserProcessHandler::GetCookieableSchemes callback for configuring global state that will be applied to all CefCookieManagers by default. This global callback is currently required by the chrome runtime because the primary ProfileImpl is created via ChromeBrowserMainParts::PreMainMessageLoopRun (CreatePrimaryProfile) before OnContextCreated can be called. ProfileImpl will use the "C:\Users\[user]\AppData\Local\CEF\User Data\Default" directory by default (on Windows). Cookies may persist in this directory when running ceftests and may need to be manually deleted if those tests fail. Remaining work includes: - Support for client-created request contexts. - Embedding the browser in a Views hierarchy (cefclient support). - TryCloseBrowser and DoClose support. - Most of the CefSettings configuration. - DevTools protocol and window control (ShowDevTools, ExecuteDevToolsMethod). - CEF-specific WebUI pages (about, license, webui-hosts). - Context menu customization (CefContextMenuHandler). - Auto resize (SetAutoResizeEnabled). - Zoom settings (SetZoomLevel). - File dialog runner (RunFileDialog). - File and JS dialog handlers (CefDialogHandler, CefJSDialogHandler). - Extension loading (LoadExtension, etc). - Plugin loading (OnBeforePluginLoad). - Widevine loading (CefRegisterWidevineCdm). - PDF and print preview does not display. - Crash reporting is untested. - Mac: Web content loads but does not display. The following ceftests are now passing when run with the "--enable-chrome-runtime" command-line flag: CorsTest.* DisplayTest.*:-DisplayTest.AutoResize DOMTest.* DraggableRegionsTest.* ImageTest.* MessageRouterTest.* NavigationTest.* ParserTest.* RequestContextTest.*Global* RequestTest.* ResourceManagerTest.* ResourceRequestHandlerTest.* ResponseTest.* SchemeHandlerTest.* ServerTest.* StreamResourceHandlerTest.* StreamTest.* StringTest.* TaskTest.* TestServerTest.* ThreadTest.* URLRequestTest.*Global* V8Test.*:-V8Test.OnUncaughtExceptionDevTools ValuesTest.* WaitableEventTest.* XmlReaderTest.* ZipReaderTest.*
2020-09-25 03:40:47 +02:00
+#include "cef/libcef/features/runtime.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
@@ -50,6 +51,10 @@
#include "url/gurl.h"
#include "url/origin.h"
+#if BUILDFLAG(ENABLE_CEF)
+#include "cef/libcef/common/extensions/extensions_util.h"
+#endif
+
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "components/guest_view/browser/guest_view_base.h"
#include "extensions/browser/extension_registry.h"
@@ -135,6 +140,9 @@ bool IsPluginLoadingAccessibleResourceInWebView(
extensions::ExtensionRegistry* extension_registry,
int process_id,
const GURL& resource) {
+ if (!extension_registry)
+ return false;
+
extensions::WebViewRendererState* renderer_state =
extensions::WebViewRendererState::GetInstance();
std::string partition_id;
@@ -163,14 +171,18 @@ bool IsPluginLoadingAccessibleResourceInWebView(
PluginInfoHostImpl::Context::Context(int render_process_id, Profile* profile)
: render_process_id_(render_process_id),
-#if BUILDFLAG(ENABLE_EXTENSIONS)
- extension_registry_(extensions::ExtensionRegistry::Get(profile)),
-#endif
host_content_settings_map_(
HostContentSettingsMapFactory::GetForProfile(profile)),
plugin_prefs_(PluginPrefs::GetForProfile(profile)) {
allow_outdated_plugins_.Init(prefs::kPluginsAllowOutdated,
profile->GetPrefs());
+
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+#if BUILDFLAG(ENABLE_CEF)
Add chrome runtime support for more callbacks and ceftests (see issue #2969) This change adds support for: - Protocol and request handling. - Loading and navigation events. - Display and focus events. - Mouse/keyboard events. - Popup browsers. - Callbacks in the renderer process. - Misc. functionality required for ceftests. This change also adds a new CefBrowserProcessHandler::GetCookieableSchemes callback for configuring global state that will be applied to all CefCookieManagers by default. This global callback is currently required by the chrome runtime because the primary ProfileImpl is created via ChromeBrowserMainParts::PreMainMessageLoopRun (CreatePrimaryProfile) before OnContextCreated can be called. ProfileImpl will use the "C:\Users\[user]\AppData\Local\CEF\User Data\Default" directory by default (on Windows). Cookies may persist in this directory when running ceftests and may need to be manually deleted if those tests fail. Remaining work includes: - Support for client-created request contexts. - Embedding the browser in a Views hierarchy (cefclient support). - TryCloseBrowser and DoClose support. - Most of the CefSettings configuration. - DevTools protocol and window control (ShowDevTools, ExecuteDevToolsMethod). - CEF-specific WebUI pages (about, license, webui-hosts). - Context menu customization (CefContextMenuHandler). - Auto resize (SetAutoResizeEnabled). - Zoom settings (SetZoomLevel). - File dialog runner (RunFileDialog). - File and JS dialog handlers (CefDialogHandler, CefJSDialogHandler). - Extension loading (LoadExtension, etc). - Plugin loading (OnBeforePluginLoad). - Widevine loading (CefRegisterWidevineCdm). - PDF and print preview does not display. - Crash reporting is untested. - Mac: Web content loads but does not display. The following ceftests are now passing when run with the "--enable-chrome-runtime" command-line flag: CorsTest.* DisplayTest.*:-DisplayTest.AutoResize DOMTest.* DraggableRegionsTest.* ImageTest.* MessageRouterTest.* NavigationTest.* ParserTest.* RequestContextTest.*Global* RequestTest.* ResourceManagerTest.* ResourceRequestHandlerTest.* ResponseTest.* SchemeHandlerTest.* ServerTest.* StreamResourceHandlerTest.* StreamTest.* StringTest.* TaskTest.* TestServerTest.* ThreadTest.* URLRequestTest.*Global* V8Test.*:-V8Test.OnUncaughtExceptionDevTools ValuesTest.* WaitableEventTest.* XmlReaderTest.* ZipReaderTest.*
2020-09-25 03:40:47 +02:00
+ if (!cef::IsAlloyRuntimeEnabled() || extensions::ExtensionsEnabled())
+#endif
+ extension_registry_ = extensions::ExtensionRegistry::Get(profile);
+#endif
}
PluginInfoHostImpl::Context::~Context() {}
diff --git chrome/browser/plugins/plugin_utils.cc chrome/browser/plugins/plugin_utils.cc
index d63750d32aa5f..170bf0826235d 100644
--- chrome/browser/plugins/plugin_utils.cc
+++ chrome/browser/plugins/plugin_utils.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/plugins/plugin_utils.h"
#include "base/values.h"
+#include "cef/libcef/features/runtime.h"
#include "chrome/browser/profiles/profile.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings_types.h"
@@ -14,6 +15,10 @@
#include "url/gurl.h"
#include "url/origin.h"
+#if BUILDFLAG(ENABLE_CEF)
+#include "cef/libcef/common/extensions/extensions_util.h"
+#endif
+
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
@@ -68,6 +73,12 @@ base::flat_map<std::string, std::string>
PluginUtils::GetMimeTypeToExtensionIdMap(
content::BrowserContext* browser_context) {
base::flat_map<std::string, std::string> mime_type_to_extension_id_map;
+
+#if BUILDFLAG(ENABLE_CEF)
+ if (cef::IsAlloyRuntimeEnabled() && !extensions::ExtensionsEnabled())
+ return mime_type_to_extension_id_map;
+#endif
+
#if BUILDFLAG(ENABLE_EXTENSIONS)
Profile* profile = Profile::FromBrowserContext(browser_context);
const std::vector<std::string>& allowlist =
diff --git chrome/common/google_url_loader_throttle.cc chrome/common/google_url_loader_throttle.cc
index a29a2739af3c8..0feb1a87cef64 100644
--- chrome/common/google_url_loader_throttle.cc
+++ chrome/common/google_url_loader_throttle.cc
@@ -7,6 +7,7 @@
#include "base/feature_list.h"
#include "base/metrics/histogram_functions.h"
#include "build/build_config.h"
+#include "cef/libcef/features/runtime.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/net/safe_search_util.h"
#include "components/google/core/common/google_util.h"
@@ -19,6 +20,10 @@
#include "ui/base/device_form_factor.h"
#endif
+#if BUILDFLAG(ENABLE_CEF)
+#include "cef/libcef/common/extensions/extensions_util.h"
+#endif
+
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "extensions/common/extension_urls.h"
#endif
@@ -158,6 +163,11 @@ void GoogleURLLoaderThrottle::WillProcessResponse(
const GURL& response_url,
network::mojom::URLResponseHead* response_head,
bool* defer) {
+#if BUILDFLAG(ENABLE_CEF)
+ if (cef::IsAlloyRuntimeEnabled() && !extensions::ExtensionsEnabled())
+ return;
+#endif
+
// Built-in additional protection for the chrome web store origin by ensuring
// that the X-Frame-Options protection mechanism is set to either DENY or
// SAMEORIGIN.
diff --git chrome/renderer/chrome_content_renderer_client.cc chrome/renderer/chrome_content_renderer_client.cc
index 3c3286f049ebc..5e8aae24754e3 100644
--- chrome/renderer/chrome_content_renderer_client.cc
+++ chrome/renderer/chrome_content_renderer_client.cc
@@ -979,6 +979,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
if ((status == chrome::mojom::PluginStatus::kUnauthorized ||
status == chrome::mojom::PluginStatus::kBlocked) &&
+ content_settings_agent_delegate &&
content_settings_agent_delegate->IsPluginTemporarilyAllowed(
identifier)) {
status = chrome::mojom::PluginStatus::kAllowed;
@@ -1149,7 +1150,8 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
render_frame->GetRemoteAssociatedInterfaces()->GetInterface(
plugin_auth_host.BindNewEndpointAndPassReceiver());
plugin_auth_host->BlockedUnauthorizedPlugin(group_name, identifier);
- content_settings_agent->DidBlockContentType(content_type);
+ if (content_settings_agent)
+ content_settings_agent->DidBlockContentType(content_type);
break;
}
case chrome::mojom::PluginStatus::kBlocked: {
@@ -1158,7 +1160,8 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name));
placeholder->AllowLoading();
RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Blocked"));
- content_settings_agent->DidBlockContentType(content_type);
+ if (content_settings_agent)
+ content_settings_agent->DidBlockContentType(content_type);
break;
}
case chrome::mojom::PluginStatus::kBlockedByPolicy: {
@@ -1168,7 +1171,8 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
group_name));
RenderThread::Get()->RecordAction(
UserMetricsAction("Plugin_BlockedByPolicy"));
- content_settings_agent->DidBlockContentType(content_type);
+ if (content_settings_agent)
+ content_settings_agent->DidBlockContentType(content_type);
break;
}
}
diff --git content/browser/browser_plugin/browser_plugin_embedder.h content/browser/browser_plugin/browser_plugin_embedder.h
index d06734015cf17..5794b6ab1c25a 100644
--- content/browser/browser_plugin/browser_plugin_embedder.h
+++ content/browser/browser_plugin/browser_plugin_embedder.h
@@ -15,6 +15,7 @@
#define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_EMBEDDER_H_
#include "base/memory/raw_ptr.h"
+#include "content/common/content_export.h"
namespace content {
@@ -26,7 +27,7 @@ struct NativeWebKeyboardEvent;
// TODO(wjmaclean): Get rid of "BrowserPlugin" in the name of this class.
// Perhaps "WebContentsEmbedderDelegate" would be better?
-class BrowserPluginEmbedder {
+class CONTENT_EXPORT BrowserPluginEmbedder {
public:
BrowserPluginEmbedder(const BrowserPluginEmbedder&) = delete;
BrowserPluginEmbedder& operator=(const BrowserPluginEmbedder&) = delete;
diff --git content/browser/browser_plugin/browser_plugin_guest.cc content/browser/browser_plugin/browser_plugin_guest.cc
index 5c05c4c3bbde1..df728150ca821 100644
--- content/browser/browser_plugin/browser_plugin_guest.cc
+++ content/browser/browser_plugin/browser_plugin_guest.cc
@@ -84,6 +84,8 @@ void BrowserPluginGuest::InitInternal(WebContentsImpl* owner_web_contents) {
GetWebContents()->GetOrCreateWebPreferences();
prefs.navigate_on_drag_drop = false;
GetWebContents()->SetWebPreferences(prefs);
+
+ owner_web_contents_ = owner_web_contents;
}
BrowserPluginGuest::~BrowserPluginGuest() = default;
diff --git content/browser/browser_plugin/browser_plugin_guest.h content/browser/browser_plugin/browser_plugin_guest.h
index 4712cd8792fa4..60af76c988278 100644
--- content/browser/browser_plugin/browser_plugin_guest.h
+++ content/browser/browser_plugin/browser_plugin_guest.h
@@ -82,6 +82,8 @@ class BrowserPluginGuest : public WebContentsObserver {
WebContentsImpl* GetWebContents() const;
+ WebContentsImpl* owner_web_contents() const { return owner_web_contents_; }
+
private:
// BrowserPluginGuest is a WebContentsObserver of |web_contents| and
// |web_contents| has to stay valid for the lifetime of BrowserPluginGuest.
@@ -91,6 +93,8 @@ class BrowserPluginGuest : public WebContentsObserver {
void InitInternal(WebContentsImpl* owner_web_contents);
const raw_ptr<BrowserPluginGuestDelegate, DanglingUntriaged> delegate_;
+
+ raw_ptr<WebContentsImpl> owner_web_contents_ = nullptr;
};
} // namespace content