2018-04-19 17:44:42 +02:00
|
|
|
diff --git chrome/browser/extensions/api/streams_private/streams_private_api.cc chrome/browser/extensions/api/streams_private/streams_private_api.cc
|
|
|
|
index 53c7404ef1f9..ac33df7cfe0e 100644
|
|
|
|
--- chrome/browser/extensions/api/streams_private/streams_private_api.cc
|
|
|
|
+++ chrome/browser/extensions/api/streams_private/streams_private_api.cc
|
|
|
|
@@ -9,6 +9,7 @@
|
2018-05-14 13:24:05 +02:00
|
|
|
|
2018-04-19 17:44:42 +02:00
|
|
|
#include "base/lazy_instance.h"
|
|
|
|
#include "base/values.h"
|
|
|
|
+#include "cef/libcef/features/features.h"
|
|
|
|
#include "chrome/browser/extensions/extension_tab_util.h"
|
|
|
|
#include "chrome/browser/prerender/prerender_contents.h"
|
|
|
|
#include "chrome/common/extensions/api/streams_private.h"
|
|
|
|
@@ -79,6 +80,7 @@ void StreamsPrivateAPI::SendExecuteMimeTypeHandlerEvent(
|
|
|
|
if (!web_contents)
|
|
|
|
return;
|
2018-05-14 13:24:05 +02:00
|
|
|
|
2018-04-19 17:44:42 +02:00
|
|
|
+#if !BUILDFLAG(ENABLE_CEF)
|
|
|
|
// If the request was for a prerender, abort the prerender and do not
|
|
|
|
// continue. This is because plugins cancel prerender, see
|
|
|
|
// http://crbug.com/343590.
|
|
|
|
@@ -88,6 +90,7 @@ void StreamsPrivateAPI::SendExecuteMimeTypeHandlerEvent(
|
|
|
|
prerender_contents->Destroy(prerender::FINAL_STATUS_DOWNLOAD);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
+#endif // !BUILDFLAG(ENABLE_CEF)
|
2018-05-14 13:24:05 +02:00
|
|
|
|
2018-04-19 17:44:42 +02:00
|
|
|
auto* browser_context = web_contents->GetBrowserContext();
|
|
|
|
StreamsPrivateAPI* streams_private = GetStreamsPrivateAPI(browser_context);
|
2017-08-04 00:55:19 +02:00
|
|
|
diff --git content/browser/frame_host/render_frame_host_manager.cc content/browser/frame_host/render_frame_host_manager.cc
|
2018-09-04 11:43:21 +02:00
|
|
|
index 49ad391a3133..b7216126976b 100644
|
2017-08-04 00:55:19 +02:00
|
|
|
--- content/browser/frame_host/render_frame_host_manager.cc
|
|
|
|
+++ content/browser/frame_host/render_frame_host_manager.cc
|
2018-07-24 00:32:02 +02:00
|
|
|
@@ -928,10 +928,11 @@ bool RenderFrameHostManager::ShouldSwapBrowsingInstancesForNavigation(
|
2017-08-04 00:55:19 +02:00
|
|
|
// TODO(alexmos): This check should've been enforced earlier in the
|
|
|
|
// navigation, in chrome::Navigate(). Verify this, and then convert this to
|
|
|
|
// a CHECK and remove the fallback.
|
|
|
|
- DCHECK_EQ(browser_context,
|
|
|
|
- render_frame_host_->GetSiteInstance()->GetBrowserContext());
|
|
|
|
- if (browser_context !=
|
|
|
|
- render_frame_host_->GetSiteInstance()->GetBrowserContext()) {
|
|
|
|
+ const bool is_same = GetContentClient()->browser()->IsSameBrowserContext(
|
|
|
|
+ browser_context,
|
|
|
|
+ render_frame_host_->GetSiteInstance()->GetBrowserContext());
|
|
|
|
+ DCHECK(is_same);
|
|
|
|
+ if (!is_same) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-07-24 00:32:02 +02:00
|
|
|
@@ -1070,7 +1071,8 @@ RenderFrameHostManager::GetSiteInstanceForNavigation(
|
2017-08-04 00:55:19 +02:00
|
|
|
|
|
|
|
// Double-check that the new SiteInstance is associated with the right
|
|
|
|
// BrowserContext.
|
|
|
|
- DCHECK_EQ(new_instance->GetBrowserContext(), browser_context);
|
|
|
|
+ DCHECK(GetContentClient()->browser()->IsSameBrowserContext(
|
|
|
|
+ new_instance->GetBrowserContext(), browser_context));
|
|
|
|
|
2018-02-15 01:12:09 +01:00
|
|
|
// If |new_instance| is a new SiteInstance for a subframe that requires a
|
|
|
|
// dedicated process, set its process reuse policy so that such subframes are
|
2017-08-04 00:55:19 +02:00
|
|
|
diff --git content/public/browser/content_browser_client.h content/public/browser/content_browser_client.h
|
2018-09-04 11:43:21 +02:00
|
|
|
index bc2b501331e9..acf916d35479 100644
|
2017-08-04 00:55:19 +02:00
|
|
|
--- content/public/browser/content_browser_client.h
|
|
|
|
+++ content/public/browser/content_browser_client.h
|
2018-09-04 11:43:21 +02:00
|
|
|
@@ -422,6 +422,13 @@ class CONTENT_EXPORT ContentBrowserClient {
|
2018-05-20 15:51:42 +02:00
|
|
|
// Returns true if error page should be isolated in its own process.
|
|
|
|
virtual bool ShouldIsolateErrorPage(bool in_main_frame);
|
2017-08-04 00:55:19 +02:00
|
|
|
|
|
|
|
+ // Returns true if two browser contexts should be considered the same. CEF
|
|
|
|
+ // uses this to treat *Impl and *Proxy contexts as the same.
|
|
|
|
+ virtual bool IsSameBrowserContext(BrowserContext* context1,
|
|
|
|
+ BrowserContext* context2) {
|
|
|
|
+ return context1 == context2;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
// Returns true if the passed in URL should be assigned as the site of the
|
|
|
|
// current SiteInstance, if it does not yet have a site.
|
|
|
|
virtual bool ShouldAssignSiteForURL(const GURL& url);
|
|
|
|
diff --git extensions/browser/extension_host.cc extensions/browser/extension_host.cc
|
2018-09-04 11:43:21 +02:00
|
|
|
index 6cf7f34bfbd7..a2dcdb88fbe3 100644
|
2017-08-04 00:55:19 +02:00
|
|
|
--- extensions/browser/extension_host.cc
|
|
|
|
+++ extensions/browser/extension_host.cc
|
2018-07-02 19:11:49 +02:00
|
|
|
@@ -67,11 +67,12 @@ ExtensionHost::ExtensionHost(const Extension* extension,
|
2017-08-04 00:55:19 +02:00
|
|
|
DCHECK(host_type == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE ||
|
|
|
|
host_type == VIEW_TYPE_EXTENSION_DIALOG ||
|
|
|
|
host_type == VIEW_TYPE_EXTENSION_POPUP);
|
2018-05-18 12:45:18 +02:00
|
|
|
- host_contents_ = WebContents::Create(
|
|
|
|
- WebContents::CreateParams(browser_context_, site_instance)),
|
2017-08-04 00:55:19 +02:00
|
|
|
- content::WebContentsObserver::Observe(host_contents_.get());
|
2018-05-18 12:45:18 +02:00
|
|
|
+ host_contents_owned_ = WebContents::Create(
|
|
|
|
+ WebContents::CreateParams(browser_context_, site_instance));
|
2017-08-04 00:55:19 +02:00
|
|
|
+ host_contents_ = host_contents_owned_.get();
|
|
|
|
+ content::WebContentsObserver::Observe(host_contents_);
|
|
|
|
host_contents_->SetDelegate(this);
|
|
|
|
- SetViewType(host_contents_.get(), host_type);
|
|
|
|
+ SetViewType(host_contents_, host_type);
|
|
|
|
|
|
|
|
render_view_host_ = host_contents_->GetRenderViewHost();
|
|
|
|
|
2018-07-02 19:11:49 +02:00
|
|
|
@@ -86,6 +87,48 @@ ExtensionHost::ExtensionHost(const Extension* extension,
|
2017-08-04 00:55:19 +02:00
|
|
|
dispatcher()->set_delegate(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ExtensionHost::ExtensionHost(ExtensionHostDelegate* delegate,
|
|
|
|
+ const Extension* extension,
|
|
|
|
+ content::BrowserContext* browser_context,
|
|
|
|
+ content::WebContents* host_contents,
|
|
|
|
+ const GURL& url,
|
|
|
|
+ ViewType host_type)
|
|
|
|
+ : delegate_(delegate),
|
|
|
|
+ extension_(extension),
|
|
|
|
+ extension_id_(extension->id()),
|
|
|
|
+ browser_context_(browser_context),
|
|
|
|
+ host_contents_(host_contents),
|
|
|
|
+ render_view_host_(nullptr),
|
|
|
|
+ is_render_view_creation_pending_(false),
|
|
|
|
+ has_loaded_once_(false),
|
|
|
|
+ document_element_available_(false),
|
|
|
|
+ initial_url_(url),
|
|
|
|
+ extension_host_type_(host_type) {
|
|
|
|
+ DCHECK(delegate);
|
|
|
|
+ DCHECK(browser_context);
|
|
|
|
+ DCHECK(host_contents);
|
|
|
|
+
|
|
|
|
+ // Not used for panels, see PanelHost.
|
|
|
|
+ DCHECK(host_type == VIEW_TYPE_EXTENSION_BACKGROUND_PAGE ||
|
|
|
|
+ host_type == VIEW_TYPE_EXTENSION_DIALOG ||
|
|
|
|
+ host_type == VIEW_TYPE_EXTENSION_POPUP);
|
|
|
|
+
|
|
|
|
+ content::WebContentsObserver::Observe(host_contents_);
|
|
|
|
+ SetViewType(host_contents_, host_type);
|
|
|
|
+
|
|
|
|
+ render_view_host_ = host_contents_->GetRenderViewHost();
|
|
|
|
+
|
|
|
|
+ // Listen for when an extension is unloaded from the same profile, as it may
|
|
|
|
+ // be the same extension that this points to.
|
|
|
|
+ ExtensionRegistry::Get(browser_context_)->AddObserver(this);
|
|
|
|
+
|
|
|
|
+ // Set up web contents observers and pref observers.
|
|
|
|
+ delegate_->OnExtensionHostCreated(host_contents_);
|
|
|
|
+
|
|
|
|
+ ExtensionWebContentsObserver::GetForWebContents(host_contents_)->
|
|
|
|
+ dispatcher()->set_delegate(this);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
ExtensionHost::~ExtensionHost() {
|
|
|
|
ExtensionRegistry::Get(browser_context_)->RemoveObserver(this);
|
|
|
|
|
|
|
|
diff --git extensions/browser/extension_host.h extensions/browser/extension_host.h
|
2018-09-04 11:43:21 +02:00
|
|
|
index ad1ef1bd0b8f..8014a61c5083 100644
|
2017-08-04 00:55:19 +02:00
|
|
|
--- extensions/browser/extension_host.h
|
|
|
|
+++ extensions/browser/extension_host.h
|
2017-12-07 22:44:24 +01:00
|
|
|
@@ -51,13 +51,19 @@ class ExtensionHost : public DeferredStartRenderHost,
|
2017-08-04 00:55:19 +02:00
|
|
|
ExtensionHost(const Extension* extension,
|
|
|
|
content::SiteInstance* site_instance,
|
|
|
|
const GURL& url, ViewType host_type);
|
|
|
|
+ ExtensionHost(ExtensionHostDelegate* delegate,
|
|
|
|
+ const Extension* extension,
|
|
|
|
+ content::BrowserContext* browser_context,
|
|
|
|
+ content::WebContents* host_contents,
|
|
|
|
+ const GURL& url,
|
|
|
|
+ ViewType host_type);
|
|
|
|
~ExtensionHost() override;
|
|
|
|
|
2017-12-07 22:44:24 +01:00
|
|
|
// This may be null if the extension has been or is being unloaded.
|
2017-08-04 00:55:19 +02:00
|
|
|
const Extension* extension() const { return extension_; }
|
2017-12-07 22:44:24 +01:00
|
|
|
|
2017-08-04 00:55:19 +02:00
|
|
|
const std::string& extension_id() const { return extension_id_; }
|
|
|
|
- content::WebContents* host_contents() const { return host_contents_.get(); }
|
|
|
|
+ content::WebContents* host_contents() const { return host_contents_; }
|
|
|
|
content::RenderViewHost* render_view_host() const;
|
|
|
|
content::RenderProcessHost* render_process_host() const;
|
|
|
|
bool has_loaded_once() const { return has_loaded_once_; }
|
2018-09-04 11:43:21 +02:00
|
|
|
@@ -178,7 +184,8 @@ class ExtensionHost : public DeferredStartRenderHost,
|
2017-08-04 00:55:19 +02:00
|
|
|
content::BrowserContext* browser_context_;
|
|
|
|
|
|
|
|
// The host for our HTML content.
|
|
|
|
- std::unique_ptr<content::WebContents> host_contents_;
|
|
|
|
+ std::unique_ptr<content::WebContents> host_contents_owned_;
|
|
|
|
+ content::WebContents* host_contents_;
|
|
|
|
|
|
|
|
// A weak pointer to the current or pending RenderViewHost. We don't access
|
|
|
|
// this through the host_contents because we want to deal with the pending
|
|
|
|
diff --git extensions/browser/extensions_browser_client.h extensions/browser/extensions_browser_client.h
|
2018-09-04 11:43:21 +02:00
|
|
|
index 7e0c178e1e36..98066c8437a1 100644
|
2017-08-04 00:55:19 +02:00
|
|
|
--- extensions/browser/extensions_browser_client.h
|
|
|
|
+++ extensions/browser/extensions_browser_client.h
|
2018-09-04 11:43:21 +02:00
|
|
|
@@ -61,6 +61,7 @@ class ComponentExtensionResourceManager;
|
2017-08-04 00:55:19 +02:00
|
|
|
class Extension;
|
|
|
|
class ExtensionCache;
|
|
|
|
class ExtensionError;
|
|
|
|
+class ExtensionHost;
|
|
|
|
class ExtensionHostDelegate;
|
|
|
|
class ExtensionPrefsObserver;
|
|
|
|
class ExtensionApiFrameIdMap;
|
2018-09-04 11:43:21 +02:00
|
|
|
@@ -132,6 +133,11 @@ class ExtensionsBrowserClient {
|
2017-08-04 00:55:19 +02:00
|
|
|
virtual content::BrowserContext* GetOriginalContext(
|
|
|
|
content::BrowserContext* context) = 0;
|
|
|
|
|
|
|
|
+ // Returns the CEF *Impl context. Used in cases where we want special CEF
|
|
|
|
+ // handling without interfering with the side-by-side Chrome build.
|
|
|
|
+ virtual content::BrowserContext* GetCefImplContext(
|
|
|
|
+ content::BrowserContext* context) { return nullptr; }
|
|
|
|
+
|
|
|
|
#if defined(OS_CHROMEOS)
|
|
|
|
// Returns a user id hash from |context| or an empty string if no hash could
|
|
|
|
// be extracted.
|
2018-09-04 11:43:21 +02:00
|
|
|
@@ -214,6 +220,14 @@ class ExtensionsBrowserClient {
|
2017-08-04 00:55:19 +02:00
|
|
|
virtual std::unique_ptr<ExtensionHostDelegate>
|
|
|
|
CreateExtensionHostDelegate() = 0;
|
|
|
|
|
|
|
|
+ // CEF creates a custom ExtensionHost for background pages. If the return
|
|
|
|
+ // value is true and |host| is NULL then fail the background host creation.
|
|
|
|
+ virtual bool CreateBackgroundExtensionHost(
|
|
|
|
+ const Extension* extension,
|
|
|
|
+ content::BrowserContext* browser_context,
|
|
|
|
+ const GURL& url,
|
|
|
|
+ ExtensionHost** host) { return false; }
|
|
|
|
+
|
|
|
|
// Returns true if the client version has updated since the last run. Called
|
|
|
|
// once each time the extensions system is loaded per browser_context. The
|
|
|
|
// implementation may wish to use the BrowserContext to record the current
|
|
|
|
diff --git extensions/browser/process_manager.cc extensions/browser/process_manager.cc
|
2018-09-04 11:43:21 +02:00
|
|
|
index ceb2f535caab..6e57be3d9241 100644
|
2017-08-04 00:55:19 +02:00
|
|
|
--- extensions/browser/process_manager.cc
|
|
|
|
+++ extensions/browser/process_manager.cc
|
2018-09-04 11:43:21 +02:00
|
|
|
@@ -358,9 +358,16 @@ bool ProcessManager::CreateBackgroundHost(const Extension* extension,
|
2017-08-04 00:55:19 +02:00
|
|
|
return true; // TODO(kalman): return false here? It might break things...
|
|
|
|
|
|
|
|
DVLOG(1) << "CreateBackgroundHost " << extension->id();
|
|
|
|
- ExtensionHost* host =
|
|
|
|
- new ExtensionHost(extension, GetSiteInstanceForURL(url).get(), url,
|
|
|
|
- VIEW_TYPE_EXTENSION_BACKGROUND_PAGE);
|
|
|
|
+ ExtensionHost* host = nullptr;
|
|
|
|
+ if (ExtensionsBrowserClient::Get()->CreateBackgroundExtensionHost(
|
|
|
|
+ extension, browser_context_, url, &host) && !host) {
|
|
|
|
+ // Explicitly fail if the client can't create the host.
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (!host) {
|
|
|
|
+ host = new ExtensionHost(extension, GetSiteInstanceForURL(url).get(), url,
|
|
|
|
+ VIEW_TYPE_EXTENSION_BACKGROUND_PAGE);
|
|
|
|
+ }
|
|
|
|
host->CreateRenderViewSoon();
|
|
|
|
OnBackgroundHostCreated(host);
|
|
|
|
return true;
|
|
|
|
diff --git extensions/browser/process_manager_factory.cc extensions/browser/process_manager_factory.cc
|
2017-09-06 23:40:58 +02:00
|
|
|
index e8929c5da255..5ae43b4361a4 100644
|
2017-08-04 00:55:19 +02:00
|
|
|
--- extensions/browser/process_manager_factory.cc
|
|
|
|
+++ extensions/browser/process_manager_factory.cc
|
|
|
|
@@ -5,6 +5,7 @@
|
|
|
|
#include "extensions/browser/process_manager_factory.h"
|
|
|
|
|
|
|
|
#include "components/keyed_service/content/browser_context_dependency_manager.h"
|
|
|
|
+#include "extensions/browser/extensions_browser_client.h"
|
|
|
|
#include "extensions/browser/extension_registry_factory.h"
|
|
|
|
#include "extensions/browser/lazy_background_task_queue_factory.h"
|
|
|
|
#include "extensions/browser/process_manager.h"
|
|
|
|
@@ -50,6 +51,12 @@ KeyedService* ProcessManagerFactory::BuildServiceInstanceFor(
|
|
|
|
|
|
|
|
BrowserContext* ProcessManagerFactory::GetBrowserContextToUse(
|
|
|
|
BrowserContext* context) const {
|
|
|
|
+ // CEF wants all extension state routed to the *Impl context.
|
|
|
|
+ content::BrowserContext* cef_context =
|
|
|
|
+ ExtensionsBrowserClient::Get()->GetCefImplContext(context);
|
|
|
|
+ if (cef_context)
|
|
|
|
+ return cef_context;
|
|
|
|
+
|
|
|
|
// ProcessManager::Create handles guest and incognito profiles, returning an
|
|
|
|
// IncognitoProcessManager in incognito mode.
|
|
|
|
return context;
|