mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
chrome: Support client-created request contexts (see issue #2969)
RequestContextTest and URLRequestTest suites now pass with the Chrome runtime enabled.
This commit is contained in:
@@ -443,9 +443,11 @@ CefRefPtr<CefRequestContext> AlloyMainDelegate::GetGlobalRequestContext() {
|
||||
}
|
||||
|
||||
CefBrowserContext* AlloyMainDelegate::CreateNewBrowserContext(
|
||||
const CefRequestContextSettings& settings) {
|
||||
const CefRequestContextSettings& settings,
|
||||
base::OnceClosure initialized_cb) {
|
||||
auto context = new AlloyBrowserContext(settings);
|
||||
context->Initialize();
|
||||
std::move(initialized_cb).Run();
|
||||
return context;
|
||||
}
|
||||
|
||||
|
@@ -62,7 +62,8 @@ class AlloyMainDelegate : public content::ContentMainDelegate,
|
||||
}
|
||||
CefRefPtr<CefRequestContext> GetGlobalRequestContext() override;
|
||||
CefBrowserContext* CreateNewBrowserContext(
|
||||
const CefRequestContextSettings& settings) override;
|
||||
const CefRequestContextSettings& settings,
|
||||
base::OnceClosure initialized_cb) override;
|
||||
|
||||
// CefTaskRunnerManager overrides.
|
||||
scoped_refptr<base::SingleThreadTaskRunner> GetBackgroundTaskRunner()
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include "include/cef_app.h"
|
||||
#include "include/cef_request_context.h"
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/macros.h"
|
||||
#include "build/build_config.h"
|
||||
#include "content/public/common/content_client.h"
|
||||
@@ -44,10 +45,12 @@ class CefAppManager {
|
||||
|
||||
// The following methods are only available in the main (browser) process.
|
||||
|
||||
// Called from CefRequestContextImpl.
|
||||
// Called from CefRequestContextImpl. |initialized_cb| may be executed
|
||||
// synchronously or asynchronously.
|
||||
virtual CefRefPtr<CefRequestContext> GetGlobalRequestContext() = 0;
|
||||
virtual CefBrowserContext* CreateNewBrowserContext(
|
||||
const CefRequestContextSettings& settings) = 0;
|
||||
const CefRequestContextSettings& settings,
|
||||
base::OnceClosure initialized_cb) = 0;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Returns the module name (usually libcef.dll).
|
||||
|
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "sandbox/policy/switches.h"
|
||||
|
||||
@@ -194,9 +195,10 @@ CefRefPtr<CefRequestContext> ChromeMainDelegateCef::GetGlobalRequestContext() {
|
||||
}
|
||||
|
||||
CefBrowserContext* ChromeMainDelegateCef::CreateNewBrowserContext(
|
||||
const CefRequestContextSettings& settings) {
|
||||
const CefRequestContextSettings& settings,
|
||||
base::OnceClosure initialized_cb) {
|
||||
auto context = new ChromeBrowserContext(settings);
|
||||
context->Initialize();
|
||||
context->InitializeAsync(std::move(initialized_cb));
|
||||
return context;
|
||||
}
|
||||
|
||||
|
@@ -54,7 +54,8 @@ class ChromeMainDelegateCef : public ChromeMainDelegate,
|
||||
}
|
||||
CefRefPtr<CefRequestContext> GetGlobalRequestContext() override;
|
||||
CefBrowserContext* CreateNewBrowserContext(
|
||||
const CefRequestContextSettings& settings) override;
|
||||
const CefRequestContextSettings& settings,
|
||||
base::OnceClosure initialized_cb) override;
|
||||
|
||||
// CefTaskRunnerManager overrides.
|
||||
scoped_refptr<base::SingleThreadTaskRunner> GetBackgroundTaskRunner()
|
||||
|
@@ -8,6 +8,8 @@
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#include "libcef/features/runtime.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/files/file_util.h"
|
||||
@@ -80,8 +82,21 @@ bool GetDefaultUserDataDirectory(base::FilePath* result) {
|
||||
base::FilePath GetUserDataPath(CefSettings* settings,
|
||||
const base::CommandLine* command_line) {
|
||||
// |settings| will be non-nullptr in the main process only.
|
||||
if (settings && settings->user_data_path.length > 0)
|
||||
return base::FilePath(CefString(&settings->user_data_path));
|
||||
if (settings) {
|
||||
// With the Chrome runtime Profile paths must always be relative to the
|
||||
// user data directory, so defaulting to |root_cache_path| first is
|
||||
// appropriate.
|
||||
CefString user_data_path;
|
||||
if (cef::IsChromeRuntimeEnabled() && settings->root_cache_path.length > 0) {
|
||||
user_data_path = CefString(&settings->root_cache_path);
|
||||
}
|
||||
if (user_data_path.empty() && settings->user_data_path.length > 0) {
|
||||
user_data_path = CefString(&settings->user_data_path);
|
||||
}
|
||||
if (!user_data_path.empty()) {
|
||||
return base::FilePath(user_data_path);
|
||||
}
|
||||
}
|
||||
|
||||
// This may be set for sub-processes.
|
||||
base::FilePath result =
|
||||
|
Reference in New Issue
Block a user