cef/patch/patches/chrome_plugins.patch

142 lines
6.5 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 2bb525046619c..611fa1fb57369 100644
--- chrome/browser/plugins/plugin_info_host_impl.cc
+++ chrome/browser/plugins/plugin_info_host_impl.cc
@@ -140,6 +140,10 @@ bool IsPluginLoadingAccessibleResourceInWebView(
extensions::ExtensionRegistry* extension_registry,
int process_id,
const GURL& resource) {
+ // May be nullptr if using CEF Alloy with extensions disabled.
+ if (!extension_registry)
+ return false;
+
extensions::WebViewRendererState* renderer_state =
extensions::WebViewRendererState::GetInstance();
std::string partition_id;
diff --git chrome/browser/plugins/plugin_utils.cc chrome/browser/plugins/plugin_utils.cc
index 438276b719c2f..69635e429be78 100644
--- chrome/browser/plugins/plugin_utils.cc
+++ chrome/browser/plugins/plugin_utils.cc
@@ -68,6 +68,13 @@ PluginUtils::GetMimeTypeToExtensionIdMap(
content::BrowserContext* browser_context) {
base::flat_map<std::string, std::string> mime_type_to_extension_id_map;
#if BUILDFLAG(ENABLE_EXTENSIONS)
+ // May be nullptr if using CEF Alloy with extensions disabled.
+ extensions::ExtensionRegistry* registry =
+ extensions::ExtensionRegistry::Get(browser_context);
+ if (!registry) {
+ return mime_type_to_extension_id_map;
+ }
+
Profile* profile = Profile::FromBrowserContext(browser_context);
if (extensions::ChromeContentBrowserClientExtensionsPart::
AreExtensionsDisabledForProfile(profile)) {
@@ -78,9 +85,6 @@ PluginUtils::GetMimeTypeToExtensionIdMap(
MimeTypesHandler::GetMIMETypeAllowlist();
// Go through the allowed extensions and try to use them to intercept
// the URL request.
- extensions::ExtensionRegistry* registry =
- extensions::ExtensionRegistry::Get(browser_context);
- DCHECK(registry);
for (const std::string& extension_id : allowlist) {
const extensions::Extension* extension =
registry->enabled_extensions().GetByID(extension_id);
diff --git chrome/renderer/chrome_content_renderer_client.cc chrome/renderer/chrome_content_renderer_client.cc
index bf59360fb366d..df9547d986cf1 100644
--- chrome/renderer/chrome_content_renderer_client.cc
+++ chrome/renderer/chrome_content_renderer_client.cc
@@ -1011,6 +1011,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;
@@ -1171,7 +1172,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: {
@@ -1180,7 +1182,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: {
@@ -1190,7 +1193,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 8b26a93f7527e..17890bf20e481 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 f94fcfcf562db..066c66f46b7ae 100644
--- content/browser/browser_plugin/browser_plugin_guest.cc
+++ content/browser/browser_plugin/browser_plugin_guest.cc
@@ -49,6 +49,8 @@ std::unique_ptr<WebContentsImpl> BrowserPluginGuest::CreateNewGuestWindow(
}
void BrowserPluginGuest::InitInternal(WebContentsImpl* owner_web_contents) {
+ owner_web_contents_ = owner_web_contents;
+
RenderWidgetHostImpl* rwhi =
GetWebContents()->GetPrimaryMainFrame()->GetRenderWidgetHost();
DCHECK(rwhi);
diff --git content/browser/browser_plugin/browser_plugin_guest.h content/browser/browser_plugin/browser_plugin_guest.h
index 7f3083029d45e..94a5cbed96a10 100644
--- content/browser/browser_plugin/browser_plugin_guest.h
+++ content/browser/browser_plugin/browser_plugin_guest.h
@@ -70,6 +70,8 @@ class BrowserPluginGuest : public WebContentsObserver {
WebContentsImpl* GetWebContents() const;
RenderFrameHostImpl* GetProspectiveOuterDocument();
+ 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.
@@ -80,6 +82,8 @@ class BrowserPluginGuest : public WebContentsObserver {
// May be null during guest destruction.
const base::WeakPtr<BrowserPluginGuestDelegate> delegate_;
+
+ raw_ptr<WebContentsImpl> owner_web_contents_ = nullptr;
};
} // namespace content