mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add support for Chrome Storage Extension API (issue #1947)
- Supports chrome.storage.local and chrome.storage.sync - chrome.storage.sync behaves identically to chrome.storage.local
This commit is contained in:
committed by
Marshall Greenblatt
parent
a028976ac4
commit
d8a602ed2f
@ -9,6 +9,7 @@
|
||||
|
||||
#include "libcef/browser/extension_impl.h"
|
||||
#include "libcef/browser/extensions/pdf_extension_util.h"
|
||||
#include "libcef/browser/extensions/value_store/cef_value_store_factory.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/extensions/extensions_util.h"
|
||||
|
||||
@ -21,6 +22,7 @@
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task_scheduler/post_task.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "components/crx_file/id_util.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
@ -40,7 +42,7 @@
|
||||
#include "extensions/browser/renderer_startup_helper.h"
|
||||
#include "extensions/browser/runtime_data.h"
|
||||
#include "extensions/browser/service_worker_manager.h"
|
||||
#include "extensions/browser/value_store/value_store_factory.h"
|
||||
#include "extensions/browser/state_store.h"
|
||||
#include "extensions/common/constants.h"
|
||||
#include "extensions/common/extension_messages.h"
|
||||
#include "extensions/common/file_util.h"
|
||||
@ -153,7 +155,9 @@ CefExtensionSystem::CefExtensionSystem(BrowserContext* browser_context)
|
||||
renderer_helper_(
|
||||
extensions::RendererStartupHelperFactory::GetForBrowserContext(
|
||||
browser_context)),
|
||||
weak_ptr_factory_(this) {}
|
||||
weak_ptr_factory_(this) {
|
||||
InitPrefs();
|
||||
}
|
||||
|
||||
CefExtensionSystem::~CefExtensionSystem() {}
|
||||
|
||||
@ -384,15 +388,15 @@ SharedUserScriptMaster* CefExtensionSystem::shared_user_script_master() {
|
||||
}
|
||||
|
||||
StateStore* CefExtensionSystem::state_store() {
|
||||
return nullptr;
|
||||
return state_store_.get();
|
||||
}
|
||||
|
||||
StateStore* CefExtensionSystem::rules_store() {
|
||||
return nullptr;
|
||||
return rules_store_.get();
|
||||
}
|
||||
|
||||
scoped_refptr<ValueStoreFactory> CefExtensionSystem::store_factory() {
|
||||
return nullptr;
|
||||
return store_factory_;
|
||||
}
|
||||
|
||||
InfoMap* CefExtensionSystem::info_map() {
|
||||
@ -467,6 +471,21 @@ CefExtensionSystem::ComponentExtensionInfo::ComponentExtensionInfo(
|
||||
}
|
||||
}
|
||||
|
||||
void CefExtensionSystem::InitPrefs() {
|
||||
store_factory_ = new CefValueStoreFactory(browser_context_->GetPath());
|
||||
|
||||
Profile* profile = Profile::FromBrowserContext(browser_context_);
|
||||
|
||||
// Two state stores. The latter, which contains declarative rules, must be
|
||||
// loaded immediately so that the rules are ready before we issue network
|
||||
// requests.
|
||||
state_store_.reset(new StateStore(
|
||||
profile, store_factory_, ValueStoreFrontend::BackendType::STATE, true));
|
||||
|
||||
rules_store_.reset(new StateStore(
|
||||
profile, store_factory_, ValueStoreFrontend::BackendType::RULES, false));
|
||||
}
|
||||
|
||||
// Implementation based on ComponentLoader::CreateExtension.
|
||||
scoped_refptr<const Extension> CefExtensionSystem::CreateExtension(
|
||||
const ComponentExtensionInfo& info,
|
||||
|
Reference in New Issue
Block a user