mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-03-30 11:50:10 +02:00
Add initial NetworkService support (see issue #2622).
This change adds an --enable-network-service command-line flag to run with NetworkService enabled. To test: Run `cefclient --enable-network-service --disable-extensions`. The application should start, load a website and exit without crashing. Network-related handlers (for cookies, schemes, requests, etc) and extensions are not expected to work yet. There should be no functional change when running without the NetworkService enabled.
This commit is contained in:
parent
af349ade33
commit
6b2c1fe969
2
BUILD.gn
2
BUILD.gn
@ -522,6 +522,8 @@ static_library("libcef_static") {
|
||||
"libcef/common/net/upload_data.h",
|
||||
"libcef/common/net/upload_element.cc",
|
||||
"libcef/common/net/upload_element.h",
|
||||
"libcef/common/net_service/util.cc",
|
||||
"libcef/common/net_service/util.h",
|
||||
"libcef/common/parser_impl.cc",
|
||||
"libcef/common/process_message_impl.cc",
|
||||
"libcef/common/process_message_impl.h",
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "libcef/browser/extensions/extension_system.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/extensions/extensions_util.h"
|
||||
#include "libcef/common/net_service/util.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
|
||||
@ -116,6 +117,7 @@ CefBrowserContext::GetClientHintsControllerDelegate() {
|
||||
|
||||
net::URLRequestContextGetter* CefBrowserContext::GetRequestContext() {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(!net_service::IsEnabled());
|
||||
return GetDefaultStoragePartition(this)->GetURLRequestContext();
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
#include "libcef/common/extensions/extensions_util.h"
|
||||
#include "libcef/common/net_service/util.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/files/file_util.h"
|
||||
@ -290,12 +291,14 @@ void CefBrowserContextImpl::Initialize() {
|
||||
|
||||
CefBrowserContext::PostInitialize();
|
||||
|
||||
// Create the CefURLRequestContextGetterImpl via an indirect call to
|
||||
// CreateRequestContext. Triggers a call to CefURLRequestContextGetterImpl::
|
||||
// GetURLRequestContext() on the IO thread which creates the
|
||||
// CefURLRequestContextImpl.
|
||||
GetRequestContext();
|
||||
DCHECK(url_request_getter_.get());
|
||||
if (!net_service::IsEnabled()) {
|
||||
// Create the CefURLRequestContextGetterImpl via an indirect call to
|
||||
// CreateRequestContext. Triggers a call to CefURLRequestContextGetterImpl::
|
||||
// GetURLRequestContext() on the IO thread which creates the
|
||||
// CefURLRequestContextImpl.
|
||||
GetRequestContext();
|
||||
DCHECK(url_request_getter_.get());
|
||||
}
|
||||
|
||||
// Create the StoragePartitionImplMap and StoragePartitionImpl for this
|
||||
// object. This must be done before the first WebContents is created using a
|
||||
@ -444,6 +447,7 @@ net::URLRequestContextGetter* CefBrowserContextImpl::CreateRequestContext(
|
||||
content::ProtocolHandlerMap* protocol_handlers,
|
||||
content::URLRequestInterceptorScopedVector request_interceptors) {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(!net_service::IsEnabled());
|
||||
DCHECK(!url_request_getter_.get());
|
||||
|
||||
auto io_thread_runner =
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "libcef/browser/net/url_request_context_getter_proxy.h"
|
||||
#include "libcef/browser/storage_partition_proxy.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/net_service/util.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "chrome/browser/font_family_cache.h"
|
||||
@ -246,9 +247,11 @@ CefBrowserContextProxy::GetOrCreateStoragePartitionProxy(
|
||||
CEF_REQUIRE_UIT();
|
||||
|
||||
if (!storage_partition_proxy_) {
|
||||
scoped_refptr<CefURLRequestContextGetterProxy> url_request_getter =
|
||||
new CefURLRequestContextGetterProxy(handler_,
|
||||
parent_->request_context_getter());
|
||||
scoped_refptr<CefURLRequestContextGetterProxy> url_request_getter;
|
||||
if (!net_service::IsEnabled()) {
|
||||
url_request_getter = new CefURLRequestContextGetterProxy(
|
||||
handler_, parent_->request_context_getter());
|
||||
}
|
||||
storage_partition_proxy_.reset(
|
||||
new CefStoragePartitionProxy(partition_impl, url_request_getter.get()));
|
||||
|
||||
|
@ -7,14 +7,18 @@
|
||||
|
||||
#include "libcef/browser/browser_context_impl.h"
|
||||
#include "libcef/browser/chrome_profile_manager_stub.h"
|
||||
#include "libcef/browser/prefs/browser_prefs.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "chrome/browser/net/chrome_net_log_helper.h"
|
||||
#include "chrome/browser/net/system_network_context_manager.h"
|
||||
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
|
||||
#include "chrome/browser/printing/print_job_manager.h"
|
||||
#include "components/net_log/chrome_net_log.h"
|
||||
#include "components/net_log/net_export_file_writer.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "services/network/public/cpp/network_switches.h"
|
||||
#include "services/network/public/cpp/shared_url_loader_factory.h"
|
||||
@ -38,6 +42,12 @@ void ChromeBrowserProcessStub::Initialize() {
|
||||
DCHECK(!context_initialized_);
|
||||
DCHECK(!shutdown_);
|
||||
|
||||
// Used for very early NetworkService initialization.
|
||||
// TODO(cef): These preferences could be persisted in the DIR_USER_DATA
|
||||
// directory.
|
||||
local_state_ =
|
||||
browser_prefs::CreatePrefService(nullptr, base::FilePath(), false);
|
||||
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
@ -70,6 +80,9 @@ void ChromeBrowserProcessStub::Shutdown() {
|
||||
profile_manager_.reset();
|
||||
event_router_forwarder_ = nullptr;
|
||||
|
||||
local_state_.reset();
|
||||
browser_policy_connector_.reset();
|
||||
|
||||
shutdown_ = true;
|
||||
}
|
||||
|
||||
@ -108,8 +121,8 @@ IOThread* ChromeBrowserProcessStub::io_thread() {
|
||||
|
||||
SystemNetworkContextManager*
|
||||
ChromeBrowserProcessStub::system_network_context_manager() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
DCHECK(SystemNetworkContextManager::GetInstance());
|
||||
return SystemNetworkContextManager::GetInstance();
|
||||
}
|
||||
|
||||
net_log::NetExportFileWriter*
|
||||
@ -137,9 +150,8 @@ ProfileManager* ChromeBrowserProcessStub::profile_manager() {
|
||||
}
|
||||
|
||||
PrefService* ChromeBrowserProcessStub::local_state() {
|
||||
DCHECK(context_initialized_);
|
||||
return profile_manager_->GetLastUsedProfile(profile_manager_->user_data_dir())
|
||||
->GetPrefs();
|
||||
DCHECK(initialized_);
|
||||
return local_state_.get();
|
||||
}
|
||||
|
||||
net::URLRequestContextGetter*
|
||||
@ -183,13 +195,15 @@ ChromeBrowserProcessStub::notification_platform_bridge() {
|
||||
|
||||
policy::ChromeBrowserPolicyConnector*
|
||||
ChromeBrowserProcessStub::browser_policy_connector() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
if (!browser_policy_connector_) {
|
||||
browser_policy_connector_ =
|
||||
std::make_unique<policy::ChromeBrowserPolicyConnector>();
|
||||
}
|
||||
return browser_policy_connector_.get();
|
||||
}
|
||||
|
||||
policy::PolicyService* ChromeBrowserProcessStub::policy_service() {
|
||||
NOTREACHED();
|
||||
return NULL;
|
||||
return browser_policy_connector()->GetPolicyService();
|
||||
}
|
||||
|
||||
IconManager* ChromeBrowserProcessStub::icon_manager() {
|
||||
|
@ -126,6 +126,10 @@ class ChromeBrowserProcessStub : public BrowserProcess,
|
||||
scoped_refptr<extensions::EventRouterForwarder> event_router_forwarder_;
|
||||
std::unique_ptr<net_log::ChromeNetLog> net_log_;
|
||||
std::unique_ptr<net_log::NetExportFileWriter> net_export_file_writer_;
|
||||
std::unique_ptr<PrefService> local_state_;
|
||||
// Must be destroyed after |local_state_|.
|
||||
std::unique_ptr<policy::ChromeBrowserPolicyConnector>
|
||||
browser_policy_connector_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserProcessStub);
|
||||
};
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "libcef/common/content_client.h"
|
||||
#include "libcef/common/extensions/extensions_util.h"
|
||||
#include "libcef/common/net/scheme_registration.h"
|
||||
#include "libcef/common/net_service/util.h"
|
||||
#include "libcef/common/request_impl.h"
|
||||
#include "libcef/common/service_manifests/cef_content_browser_overlay_manifest.h"
|
||||
#include "libcef/common/service_manifests/cef_content_gpu_overlay_manifest.h"
|
||||
@ -51,9 +52,12 @@
|
||||
#include "cef/grit/cef_resources.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/chrome_service.h"
|
||||
#include "chrome/browser/net/system_network_context_manager.h"
|
||||
#include "chrome/browser/plugins/plugin_info_host_impl.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "chrome/common/chrome_paths_internal.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/constants.mojom.h"
|
||||
#include "chrome/grit/browser_resources.h"
|
||||
@ -839,6 +843,26 @@ std::string CefContentBrowserClient::GetApplicationLocale() {
|
||||
return g_browser_process->GetApplicationLocale();
|
||||
}
|
||||
|
||||
scoped_refptr<network::SharedURLLoaderFactory>
|
||||
CefContentBrowserClient::GetSystemSharedURLLoaderFactory() {
|
||||
DCHECK(
|
||||
content::BrowserThread::CurrentlyOn(content::BrowserThread::UI) ||
|
||||
!content::BrowserThread::IsThreadInitialized(content::BrowserThread::UI));
|
||||
|
||||
if (!SystemNetworkContextManager::GetInstance())
|
||||
return nullptr;
|
||||
|
||||
return SystemNetworkContextManager::GetInstance()
|
||||
->GetSharedURLLoaderFactory();
|
||||
}
|
||||
|
||||
network::mojom::NetworkContext*
|
||||
CefContentBrowserClient::GetSystemNetworkContext() {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
DCHECK(SystemNetworkContextManager::GetInstance());
|
||||
return SystemNetworkContextManager::GetInstance()->GetContext();
|
||||
}
|
||||
|
||||
content::QuotaPermissionContext*
|
||||
CefContentBrowserClient::CreateQuotaPermissionContext() {
|
||||
return new CefQuotaPermissionContext();
|
||||
@ -1173,6 +1197,51 @@ bool CefContentBrowserClient::WillCreateURLLoaderFactory(
|
||||
return use_proxy;
|
||||
}
|
||||
|
||||
void CefContentBrowserClient::OnNetworkServiceCreated(
|
||||
network::mojom::NetworkService* network_service) {
|
||||
if (!net_service::IsEnabled())
|
||||
return;
|
||||
|
||||
DCHECK(g_browser_process);
|
||||
PrefService* local_state = g_browser_process->local_state();
|
||||
DCHECK(local_state);
|
||||
|
||||
if (!SystemNetworkContextManager::GetInstance()) {
|
||||
SystemNetworkContextManager::CreateInstance(local_state);
|
||||
}
|
||||
// Need to set up global NetworkService state before anything else uses it.
|
||||
SystemNetworkContextManager::GetInstance()->OnNetworkServiceCreated(
|
||||
network_service);
|
||||
}
|
||||
|
||||
network::mojom::NetworkContextPtr CefContentBrowserClient::CreateNetworkContext(
|
||||
content::BrowserContext* context,
|
||||
bool in_memory,
|
||||
const base::FilePath& relative_partition_path) {
|
||||
Profile* profile = Profile::FromBrowserContext(context);
|
||||
return profile->CreateNetworkContext(in_memory, relative_partition_path);
|
||||
}
|
||||
|
||||
std::vector<base::FilePath>
|
||||
CefContentBrowserClient::GetNetworkContextsParentDirectory() {
|
||||
base::FilePath user_data_dir;
|
||||
base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
|
||||
DCHECK(!user_data_dir.empty());
|
||||
|
||||
// TODO(cef): Do we really want to create a cache directory underneath
|
||||
// DIR_USER_DATA?
|
||||
base::FilePath cache_dir;
|
||||
chrome::GetUserCacheDirectory(user_data_dir, &cache_dir);
|
||||
DCHECK(!cache_dir.empty());
|
||||
|
||||
// On some platforms, the cache is a child of the user_data_dir so only
|
||||
// return the one path.
|
||||
if (user_data_dir.IsParent(cache_dir))
|
||||
return {user_data_dir};
|
||||
|
||||
return {user_data_dir, cache_dir};
|
||||
}
|
||||
|
||||
bool CefContentBrowserClient::HandleExternalProtocol(
|
||||
const GURL& url,
|
||||
content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
|
||||
|
@ -68,6 +68,9 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
base::CommandLine* command_line) override;
|
||||
bool ShouldEnableStrictSiteIsolation() override;
|
||||
std::string GetApplicationLocale() override;
|
||||
scoped_refptr<network::SharedURLLoaderFactory>
|
||||
GetSystemSharedURLLoaderFactory() override;
|
||||
network::mojom::NetworkContext* GetSystemNetworkContext() override;
|
||||
content::QuotaPermissionContext* CreateQuotaPermissionContext() override;
|
||||
void GetQuotaSettings(
|
||||
content::BrowserContext* context,
|
||||
@ -154,7 +157,13 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
network::mojom::URLLoaderFactoryRequest* factory_request,
|
||||
network::mojom::TrustedURLLoaderHeaderClientPtrInfo* header_client,
|
||||
bool* bypass_redirect_checks) override;
|
||||
|
||||
void OnNetworkServiceCreated(
|
||||
network::mojom::NetworkService* network_service) override;
|
||||
network::mojom::NetworkContextPtr CreateNetworkContext(
|
||||
content::BrowserContext* context,
|
||||
bool in_memory,
|
||||
const base::FilePath& relative_partition_path) override;
|
||||
std::vector<base::FilePath> GetNetworkContextsParentDirectory() override;
|
||||
bool HandleExternalProtocol(
|
||||
const GURL& url,
|
||||
content::ResourceRequestInfo::WebContentsGetter web_contents_getter,
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/net/cookie_store_source.h"
|
||||
#include "libcef/browser/net/network_delegate.h"
|
||||
#include "libcef/common/net_service/util.h"
|
||||
#include "libcef/common/task_runner_impl.h"
|
||||
#include "libcef/common/time_util.h"
|
||||
|
||||
@ -141,9 +142,13 @@ void CefCookieManagerImpl::Initialize(
|
||||
CHECK(!is_blocking_);
|
||||
if (request_context.get()) {
|
||||
request_context_ = request_context;
|
||||
request_context_->GetRequestContextImpl(
|
||||
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}),
|
||||
base::Bind(&CefCookieManagerImpl::InitWithContext, this, callback));
|
||||
if (!net_service::IsEnabled()) {
|
||||
request_context_->GetRequestContextImpl(
|
||||
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}),
|
||||
base::Bind(&CefCookieManagerImpl::InitWithContext, this, callback));
|
||||
} else {
|
||||
RunAsyncCompletionOnIOThread(callback);
|
||||
}
|
||||
} else {
|
||||
SetStoragePath(path, persist_session_cookies, callback);
|
||||
}
|
||||
@ -477,9 +482,14 @@ void CefCookieManagerImpl::SetSupportedSchemesInternal(
|
||||
CEF_REQUIRE_IOT();
|
||||
|
||||
if (HasContext()) {
|
||||
RunMethodWithContext(
|
||||
base::Bind(&CefCookieManagerImpl::SetSupportedSchemesWithContext, this,
|
||||
schemes, callback));
|
||||
if (!net_service::IsEnabled()) {
|
||||
RunMethodWithContext(
|
||||
base::Bind(&CefCookieManagerImpl::SetSupportedSchemesWithContext,
|
||||
this, schemes, callback));
|
||||
} else {
|
||||
NOTIMPLEMENTED();
|
||||
RunAsyncCompletionOnIOThread(callback);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ CefURLRequestContextGetterImpl::~CefURLRequestContextGetterImpl() {
|
||||
// static
|
||||
void CefURLRequestContextGetterImpl::RegisterPrefs(
|
||||
PrefRegistrySimple* registry) {
|
||||
// Based on IOThread::RegisterPrefs.
|
||||
// Based on IOThread::RegisterPrefs.
|
||||
#if defined(OS_POSIX) && !defined(OS_ANDROID)
|
||||
registry->RegisterStringPref(prefs::kGSSAPILibraryName, std::string());
|
||||
#endif
|
||||
@ -249,6 +249,10 @@ void CefURLRequestContextGetterImpl::RegisterPrefs(
|
||||
|
||||
// Based on ProfileImpl::RegisterProfilePrefs.
|
||||
registry->RegisterBooleanPref(prefs::kForceGoogleSafeSearch, false);
|
||||
|
||||
// Based on IOThread::RegisterPrefs.
|
||||
registry->RegisterStringPref(prefs::kAuthServerWhitelist, "");
|
||||
registry->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, "");
|
||||
}
|
||||
|
||||
void CefURLRequestContextGetterImpl::ShutdownOnUIThread() {
|
||||
|
@ -17,9 +17,12 @@
|
||||
#include "base/values.h"
|
||||
#include "chrome/browser/accessibility/accessibility_ui.h"
|
||||
#include "chrome/browser/net/prediction_options.h"
|
||||
#include "chrome/browser/net/profile_network_context_service.h"
|
||||
#include "chrome/browser/net/system_network_context_manager.h"
|
||||
#include "chrome/browser/plugins/plugin_info_host_impl.h"
|
||||
#include "chrome/browser/prefs/chrome_command_line_pref_store.h"
|
||||
#include "chrome/browser/renderer_host/pepper/device_id_fetcher.h"
|
||||
#include "chrome/browser/ssl/ssl_config_service_manager.h"
|
||||
#include "chrome/browser/supervised_user/supervised_user_pref_store.h"
|
||||
#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
|
||||
#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
|
||||
@ -27,6 +30,7 @@
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "chrome/grit/locale_settings.h"
|
||||
#include "components/certificate_transparency/pref_names.h"
|
||||
#include "components/content_settings/core/browser/cookie_settings.h"
|
||||
#include "components/content_settings/core/browser/host_content_settings_map.h"
|
||||
#include "components/google/core/browser/google_url_tracker.h"
|
||||
@ -97,23 +101,25 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
|
||||
// Used to store supervised user preferences.
|
||||
SupervisedUserSettingsService* supervised_user_settings =
|
||||
SupervisedUserSettingsServiceFactory::GetForProfile(profile);
|
||||
if (profile) {
|
||||
// Used to store supervised user preferences.
|
||||
SupervisedUserSettingsService* supervised_user_settings =
|
||||
SupervisedUserSettingsServiceFactory::GetForProfile(profile);
|
||||
|
||||
if (store_on_disk) {
|
||||
supervised_user_settings->Init(cache_path, sequenced_task_runner.get(),
|
||||
true);
|
||||
} else {
|
||||
scoped_refptr<CefPrefStore> cef_pref_store = new CefPrefStore();
|
||||
cef_pref_store->SetInitializationCompleted();
|
||||
supervised_user_settings->Init(cef_pref_store);
|
||||
if (store_on_disk) {
|
||||
supervised_user_settings->Init(cache_path, sequenced_task_runner.get(),
|
||||
true);
|
||||
} else {
|
||||
scoped_refptr<CefPrefStore> cef_pref_store = new CefPrefStore();
|
||||
cef_pref_store->SetInitializationCompleted();
|
||||
supervised_user_settings->Init(cef_pref_store);
|
||||
}
|
||||
|
||||
scoped_refptr<PrefStore> supervised_user_prefs =
|
||||
base::MakeRefCounted<SupervisedUserPrefStore>(supervised_user_settings);
|
||||
DCHECK(supervised_user_prefs->IsInitializationComplete());
|
||||
factory.set_supervised_user_prefs(supervised_user_prefs);
|
||||
}
|
||||
|
||||
scoped_refptr<PrefStore> supervised_user_prefs =
|
||||
base::MakeRefCounted<SupervisedUserPrefStore>(supervised_user_settings);
|
||||
DCHECK(supervised_user_prefs->IsInitializationComplete());
|
||||
factory.set_supervised_user_prefs(supervised_user_prefs);
|
||||
#endif // BUILDFLAG(ENABLE_SUPERVISED_USERS)
|
||||
|
||||
// Registry that will be populated with all known preferences. Preferences
|
||||
@ -138,64 +144,24 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
|
||||
// use) then register the preferences directly instead of calling the
|
||||
// existing registration method.
|
||||
|
||||
// Call RegisterProfilePrefs() for all services listed by
|
||||
// EnsureBrowserContextKeyedServiceFactoriesBuilt().
|
||||
BrowserContextDependencyManager::GetInstance()
|
||||
->RegisterProfilePrefsForServices(profile, registry.get());
|
||||
|
||||
// Default preferences.
|
||||
AccessibilityUIMessageHandler::RegisterProfilePrefs(registry.get());
|
||||
CefMediaCaptureDevicesDispatcher::RegisterPrefs(registry.get());
|
||||
CefURLRequestContextGetterImpl::RegisterPrefs(registry.get());
|
||||
chrome_browser_net::RegisterPredictionOptionsProfilePrefs(registry.get());
|
||||
DeviceIDFetcher::RegisterProfilePrefs(registry.get());
|
||||
extensions::ExtensionPrefs::RegisterProfilePrefs(registry.get());
|
||||
GoogleURLTracker::RegisterProfilePrefs(registry.get());
|
||||
HostContentSettingsMap::RegisterProfilePrefs(registry.get());
|
||||
language::RegisterProfilePrefs(registry.get());
|
||||
certificate_transparency::prefs::RegisterPrefs(registry.get());
|
||||
PluginInfoHostImpl::RegisterUserPrefs(registry.get());
|
||||
PrefProxyConfigTrackerImpl::RegisterPrefs(registry.get());
|
||||
renderer_prefs::RegisterProfilePrefs(registry.get());
|
||||
SSLConfigServiceManager::RegisterPrefs(registry.get());
|
||||
update_client::RegisterPrefs(registry.get());
|
||||
|
||||
// Print preferences.
|
||||
// Based on ProfileImpl::RegisterProfilePrefs.
|
||||
registry->RegisterBooleanPref(prefs::kPrintingEnabled, true);
|
||||
|
||||
// Spell checking preferences.
|
||||
// Modify defaults from SpellcheckServiceFactory::RegisterProfilePrefs.
|
||||
std::string spellcheck_lang =
|
||||
command_line->GetSwitchValueASCII(switches::kOverrideSpellCheckLang);
|
||||
if (!spellcheck_lang.empty()) {
|
||||
registry->SetDefaultPrefValue(spellcheck::prefs::kSpellCheckDictionary,
|
||||
base::Value(spellcheck_lang));
|
||||
if (!command_line->HasSwitch(switches::kEnableNetworkService)) {
|
||||
CefURLRequestContextGetterImpl::RegisterPrefs(registry.get());
|
||||
} else if (!profile) {
|
||||
SystemNetworkContextManager::RegisterPrefs(registry.get());
|
||||
}
|
||||
const bool enable_spelling_service_ =
|
||||
command_line->HasSwitch(switches::kEnableSpellingService);
|
||||
registry->SetDefaultPrefValue(
|
||||
spellcheck::prefs::kSpellCheckUseSpellingService,
|
||||
base::Value(enable_spelling_service_));
|
||||
registry->SetDefaultPrefValue(spellcheck::prefs::kSpellCheckEnable,
|
||||
base::Value(!enable_spelling_service_));
|
||||
|
||||
// Pepper flash preferences.
|
||||
// Modify defaults from DeviceIDFetcher::RegisterProfilePrefs.
|
||||
registry->SetDefaultPrefValue(prefs::kEnableDRM, base::Value(false));
|
||||
|
||||
// Authentication preferences.
|
||||
// Based on IOThread::RegisterPrefs.
|
||||
registry->RegisterStringPref(prefs::kAuthServerWhitelist, "");
|
||||
registry->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, "");
|
||||
|
||||
// Browser UI preferences.
|
||||
// Based on chrome/browser/ui/browser_ui_prefs.cc RegisterBrowserPrefs.
|
||||
registry->RegisterBooleanPref(prefs::kAllowFileSelectionDialogs, true);
|
||||
|
||||
// DevTools preferences.
|
||||
// Based on DevToolsWindow::RegisterProfilePrefs.
|
||||
registry->RegisterDictionaryPref(prefs::kDevToolsPreferences);
|
||||
registry->RegisterDictionaryPref(prefs::kDevToolsEditedFiles);
|
||||
|
||||
if (command_line->HasSwitch(switches::kEnablePreferenceTesting)) {
|
||||
// Preferences used with unit tests.
|
||||
registry->RegisterBooleanPref("test.bool", true);
|
||||
@ -206,6 +172,53 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
|
||||
registry->RegisterDictionaryPref("test.dict");
|
||||
}
|
||||
|
||||
if (profile) {
|
||||
// Call RegisterProfilePrefs() for all services listed by
|
||||
// EnsureBrowserContextKeyedServiceFactoriesBuilt().
|
||||
BrowserContextDependencyManager::GetInstance()
|
||||
->RegisterProfilePrefsForServices(profile, registry.get());
|
||||
|
||||
// Default profile preferences.
|
||||
AccessibilityUIMessageHandler::RegisterProfilePrefs(registry.get());
|
||||
chrome_browser_net::RegisterPredictionOptionsProfilePrefs(registry.get());
|
||||
DeviceIDFetcher::RegisterProfilePrefs(registry.get());
|
||||
extensions::ExtensionPrefs::RegisterProfilePrefs(registry.get());
|
||||
GoogleURLTracker::RegisterProfilePrefs(registry.get());
|
||||
HostContentSettingsMap::RegisterProfilePrefs(registry.get());
|
||||
language::RegisterProfilePrefs(registry.get());
|
||||
ProfileNetworkContextService::RegisterProfilePrefs(registry.get());
|
||||
renderer_prefs::RegisterProfilePrefs(registry.get());
|
||||
|
||||
// Print preferences.
|
||||
// Based on ProfileImpl::RegisterProfilePrefs.
|
||||
registry->RegisterBooleanPref(prefs::kPrintingEnabled, true);
|
||||
|
||||
// Spell checking preferences.
|
||||
// Modify defaults from SpellcheckServiceFactory::RegisterProfilePrefs.
|
||||
std::string spellcheck_lang =
|
||||
command_line->GetSwitchValueASCII(switches::kOverrideSpellCheckLang);
|
||||
if (!spellcheck_lang.empty()) {
|
||||
registry->SetDefaultPrefValue(spellcheck::prefs::kSpellCheckDictionary,
|
||||
base::Value(spellcheck_lang));
|
||||
}
|
||||
const bool enable_spelling_service_ =
|
||||
command_line->HasSwitch(switches::kEnableSpellingService);
|
||||
registry->SetDefaultPrefValue(
|
||||
spellcheck::prefs::kSpellCheckUseSpellingService,
|
||||
base::Value(enable_spelling_service_));
|
||||
registry->SetDefaultPrefValue(spellcheck::prefs::kSpellCheckEnable,
|
||||
base::Value(!enable_spelling_service_));
|
||||
|
||||
// Pepper flash preferences.
|
||||
// Modify defaults from DeviceIDFetcher::RegisterProfilePrefs.
|
||||
registry->SetDefaultPrefValue(prefs::kEnableDRM, base::Value(false));
|
||||
|
||||
// DevTools preferences.
|
||||
// Based on DevToolsWindow::RegisterProfilePrefs.
|
||||
registry->RegisterDictionaryPref(prefs::kDevToolsPreferences);
|
||||
registry->RegisterDictionaryPref(prefs::kDevToolsEditedFiles);
|
||||
}
|
||||
|
||||
// Build the PrefService that manages the PrefRegistry and PrefStores.
|
||||
return factory.CreateSyncable(registry.get());
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ namespace browser_prefs {
|
||||
extern const char kUserPrefsFileName[];
|
||||
|
||||
// Create the PrefService used to manage pref registration and storage.
|
||||
// |profile| will be nullptr for the system-level PrefService.
|
||||
std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
|
||||
const base::FilePath& cache_path,
|
||||
bool persist_user_preferences);
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "libcef/browser/extensions/extension_system.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/extensions/extensions_util.h"
|
||||
#include "libcef/common/net_service/util.h"
|
||||
#include "libcef/common/task_runner_impl.h"
|
||||
#include "libcef/common/values_impl.h"
|
||||
|
||||
@ -194,6 +195,7 @@ void CefRequestContextImpl::GetBrowserContext(
|
||||
void CefRequestContextImpl::GetRequestContextImpl(
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner,
|
||||
const RequestContextCallback& callback) {
|
||||
DCHECK(!net_service::IsEnabled());
|
||||
if (!task_runner.get())
|
||||
task_runner = CefTaskRunnerImpl::GetCurrentTaskRunner();
|
||||
if (request_context_getter_impl_) {
|
||||
@ -305,6 +307,10 @@ bool CefRequestContextImpl::RegisterSchemeHandlerFactory(
|
||||
const CefString& scheme_name,
|
||||
const CefString& domain_name,
|
||||
CefRefPtr<CefSchemeHandlerFactory> factory) {
|
||||
if (net_service::IsEnabled()) {
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
GetRequestContextImpl(
|
||||
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}),
|
||||
base::Bind(&CefRequestContextImpl::RegisterSchemeHandlerFactoryInternal,
|
||||
@ -313,6 +319,10 @@ bool CefRequestContextImpl::RegisterSchemeHandlerFactory(
|
||||
}
|
||||
|
||||
bool CefRequestContextImpl::ClearSchemeHandlerFactories() {
|
||||
if (net_service::IsEnabled()) {
|
||||
NOTIMPLEMENTED();
|
||||
return false;
|
||||
}
|
||||
GetRequestContextImpl(
|
||||
base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO}),
|
||||
base::Bind(&CefRequestContextImpl::ClearSchemeHandlerFactoriesInternal,
|
||||
@ -614,14 +624,16 @@ void CefRequestContextImpl::Initialize() {
|
||||
DCHECK(!config_.is_global);
|
||||
}
|
||||
|
||||
request_context_getter_impl_ =
|
||||
browser_context_impl_->request_context_getter().get();
|
||||
DCHECK(request_context_getter_impl_);
|
||||
if (!net_service::IsEnabled()) {
|
||||
request_context_getter_impl_ =
|
||||
browser_context_impl_->request_context_getter().get();
|
||||
DCHECK(request_context_getter_impl_);
|
||||
|
||||
if (config_.handler.get()) {
|
||||
// Keep the handler alive until the associated request context is
|
||||
// destroyed.
|
||||
request_context_getter_impl_->AddHandler(config_.handler);
|
||||
if (config_.handler.get()) {
|
||||
// Keep the handler alive until the associated request context is
|
||||
// destroyed.
|
||||
request_context_getter_impl_->AddHandler(config_.handler);
|
||||
}
|
||||
}
|
||||
|
||||
if (config_.other) {
|
||||
@ -640,7 +652,7 @@ void CefRequestContextImpl::EnsureBrowserContext() {
|
||||
if (!browser_context())
|
||||
Initialize();
|
||||
DCHECK(browser_context());
|
||||
DCHECK(request_context_getter_impl_);
|
||||
DCHECK(net_service::IsEnabled() || request_context_getter_impl_);
|
||||
}
|
||||
|
||||
void CefRequestContextImpl::GetBrowserContextOnUIThread(
|
||||
@ -677,6 +689,7 @@ void CefRequestContextImpl::GetRequestContextImplOnIOThread(
|
||||
return;
|
||||
}
|
||||
|
||||
DCHECK(!net_service::IsEnabled());
|
||||
DCHECK(request_context_getter_impl_);
|
||||
|
||||
// Make sure the request context exists.
|
||||
|
@ -4,15 +4,21 @@
|
||||
|
||||
#include "libcef/browser/storage_partition_proxy.h"
|
||||
|
||||
#include "libcef/common/net_service/util.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "services/network/public/mojom/cookie_manager.mojom.h"
|
||||
|
||||
CefStoragePartitionProxy::CefStoragePartitionProxy(
|
||||
content::StoragePartition* parent,
|
||||
CefURLRequestContextGetterProxy* url_request_context)
|
||||
: parent_(parent), url_request_context_(url_request_context) {}
|
||||
: parent_(parent), url_request_context_(url_request_context) {
|
||||
DCHECK(net_service::IsEnabled() || url_request_context_);
|
||||
}
|
||||
|
||||
CefStoragePartitionProxy::~CefStoragePartitionProxy() {
|
||||
url_request_context_->ShutdownOnUIThread();
|
||||
if (url_request_context_)
|
||||
url_request_context_->ShutdownOnUIThread();
|
||||
}
|
||||
|
||||
base::FilePath CefStoragePartitionProxy::GetPath() {
|
||||
|
@ -116,6 +116,9 @@ const char kEnablePreferenceTesting[] = "enable-preference-testing";
|
||||
// Enable date-based expiration of built in network security information.
|
||||
const char kEnableNetSecurityExpiration[] = "enable-net-security-expiration";
|
||||
|
||||
// Enable the NetworkService.
|
||||
const char kEnableNetworkService[] = "enable-network-service";
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// Path to the framework directory.
|
||||
const char kFrameworkDirPath[] = "framework-dir-path";
|
||||
|
@ -52,6 +52,7 @@ extern const char kPluginPolicy_Detect[];
|
||||
extern const char kPluginPolicy_Block[];
|
||||
extern const char kEnablePreferenceTesting[];
|
||||
extern const char kEnableNetSecurityExpiration[];
|
||||
extern const char kEnableNetworkService[];
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
extern const char kFrameworkDirPath[];
|
||||
|
@ -570,7 +570,8 @@ bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||
// Disable NetworkService for now
|
||||
// TODO(cef): Implement the required changes for network service
|
||||
if (network::features::kNetworkService.default_state ==
|
||||
base::FEATURE_ENABLED_BY_DEFAULT) {
|
||||
base::FEATURE_ENABLED_BY_DEFAULT &&
|
||||
!command_line->HasSwitch(switches::kEnableNetworkService)) {
|
||||
disable_features.push_back(network::features::kNetworkService.name);
|
||||
}
|
||||
|
||||
|
16
libcef/common/net_service/util.cc
Normal file
16
libcef/common/net_service/util.cc
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#include "libcef/common/net_service/util.h"
|
||||
|
||||
#include "base/feature_list.h"
|
||||
#include "services/network/public/cpp/features.h"
|
||||
|
||||
namespace net_service {
|
||||
|
||||
bool IsEnabled() {
|
||||
return base::FeatureList::IsEnabled(network::features::kNetworkService);
|
||||
}
|
||||
|
||||
} // namespace net_service
|
16
libcef/common/net_service/util.h
Normal file
16
libcef/common/net_service/util.h
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_COMMON_NET_SERVICE_UTIL_H_
|
||||
#define CEF_LIBCEF_COMMON_NET_SERVICE_UTIL_H_
|
||||
#pragma once
|
||||
|
||||
namespace net_service {
|
||||
|
||||
// Returns true if the NetworkService is enabled.
|
||||
bool IsEnabled();
|
||||
|
||||
} // namespace net_service
|
||||
|
||||
#endif // CEF_LIBCEF_COMMON_NET_SERVICE_UTIL_H_
|
Loading…
x
Reference in New Issue
Block a user