Add StoragePartition and extension object proxy support (issue #1973)

This commit is contained in:
Marshall Greenblatt
2016-08-24 12:28:52 +03:00
parent 1c06d8e3f5
commit 69334e22c2
19 changed files with 810 additions and 138 deletions

View File

@@ -80,6 +80,7 @@ base::DictionaryValue* ParseManifest(
CefExtensionSystem::CefExtensionSystem(BrowserContext* browser_context)
: browser_context_(browser_context),
initialized_(false),
registry_(ExtensionRegistry::Get(browser_context)),
weak_ptr_factory_(this) {
}
@@ -88,6 +89,8 @@ CefExtensionSystem::~CefExtensionSystem() {
}
void CefExtensionSystem::Init() {
DCHECK(!initialized_);
// There's complexity here related to the ordering of message delivery. For
// an extension to load correctly both the ExtensionMsg_Loaded and
// ExtensionMsg_ActivateExtension messages must be sent. These messages are
@@ -141,6 +144,8 @@ void CefExtensionSystem::Init() {
AddExtension(pdf_extension_util::GetManifest(),
base::FilePath(FILE_PATH_LITERAL("pdf")));
}
initialized_ = true;
}
// Implementation based on ComponentLoader::Add.
@@ -173,6 +178,7 @@ void CefExtensionSystem::Shutdown() {
}
void CefExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
DCHECK(!initialized_);
service_worker_manager_.reset(new ServiceWorkerManager(browser_context_));
runtime_data_.reset(new RuntimeData(registry_));
quota_service_.reset(new QuotaService);

View File

@@ -78,6 +78,8 @@ class CefExtensionSystem : public ExtensionSystem {
void InstallUpdate(const std::string& extension_id,
const base::FilePath& temp_dir) override;
bool initialized() const { return initialized_; }
private:
// Information about a registered component extension.
struct ComponentExtensionInfo {
@@ -120,6 +122,8 @@ class CefExtensionSystem : public ExtensionSystem {
content::BrowserContext* browser_context_; // Not owned.
bool initialized_;
// Data to be accessed on the IO thread. Must outlive process_manager_.
scoped_refptr<InfoMap> info_map_;

View File

@@ -6,6 +6,7 @@
#include "libcef/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "extensions/browser/extension_prefs_factory.h"
#include "extensions/browser/extension_registry_factory.h"
@@ -45,7 +46,7 @@ KeyedService* CefExtensionSystemFactory::BuildServiceInstanceFor(
BrowserContext* CefExtensionSystemFactory::GetBrowserContextToUse(
BrowserContext* context) const {
// Use a separate instance for incognito.
return context;
return chrome::GetBrowserContextOwnInstanceInIncognito(context);
}
bool CefExtensionSystemFactory::ServiceIsCreatedWithBrowserContext() const {

View File

@@ -18,6 +18,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/chrome_url_request_util.h"
#include "chrome/browser/extensions/event_router_forwarder.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
@@ -61,7 +62,10 @@ bool CefExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
bool CefExtensionsBrowserClient::IsSameContext(BrowserContext* first,
BrowserContext* second) {
return first == second;
// Returns true if |first| and |second| share the same underlying
// CefBrowserContextImpl.
return CefBrowserContextImpl::GetForContext(first).get() ==
CefBrowserContextImpl::GetForContext(second).get();
}
bool CefExtensionsBrowserClient::HasOffTheRecordContext(
@@ -77,7 +81,7 @@ BrowserContext* CefExtensionsBrowserClient::GetOffTheRecordContext(
BrowserContext* CefExtensionsBrowserClient::GetOriginalContext(
BrowserContext* context) {
return context;
return chrome::GetBrowserContextRedirectedInIncognito(context);
}
bool CefExtensionsBrowserClient::IsGuestSession(