mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-01-28 10:09:25 +01:00
198 lines
8.8 KiB
Diff
198 lines
8.8 KiB
Diff
diff --git chrome/browser/net/profile_network_context_service.cc chrome/browser/net/profile_network_context_service.cc
|
|
index 75981a42a314..d29366145453 100644
|
|
--- chrome/browser/net/profile_network_context_service.cc
|
|
+++ chrome/browser/net/profile_network_context_service.cc
|
|
@@ -17,6 +17,7 @@
|
|
#include "base/metrics/histogram_macros.h"
|
|
#include "base/strings/string_split.h"
|
|
#include "base/task/post_task.h"
|
|
+#include "cef/libcef/features/features.h"
|
|
#include "chrome/browser/browser_process.h"
|
|
#include "chrome/browser/content_settings/cookie_settings_factory.h"
|
|
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
|
|
@@ -678,9 +679,22 @@ ProfileNetworkContextService::CreateNetworkContextParams(
|
|
network_context_params->cookie_manager_params =
|
|
CreateCookieManagerParams(profile_, *cookie_settings_);
|
|
|
|
+ network_context_params->cookieable_schemes = profile_->GetCookieableSchemes();
|
|
+
|
|
// Configure on-disk storage for non-OTR profiles. OTR profiles just use
|
|
// default behavior (in memory storage, default sizes).
|
|
if (!in_memory) {
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
+ PrefService* prefs = profile_->GetPrefs();
|
|
+ // Configure the HTTP cache path and size.
|
|
+ const base::FilePath& base_cache_path =
|
|
+ prefs->GetFilePath(prefs::kDiskCacheDir);
|
|
+ DCHECK(!base_cache_path.empty());
|
|
+ network_context_params->http_cache_path =
|
|
+ base_cache_path.Append(chrome::kCacheDirname);
|
|
+ network_context_params->http_cache_max_size =
|
|
+ prefs->GetInteger(prefs::kDiskCacheSize);
|
|
+#else
|
|
PrefService* local_state = g_browser_process->local_state();
|
|
// Configure the HTTP cache path and size.
|
|
base::FilePath base_cache_path;
|
|
@@ -693,6 +707,7 @@ ProfileNetworkContextService::CreateNetworkContextParams(
|
|
base_cache_path.Append(chrome::kCacheDirname);
|
|
network_context_params->http_cache_max_size =
|
|
local_state->GetInteger(prefs::kDiskCacheSize);
|
|
+#endif
|
|
|
|
// Currently this just contains HttpServerProperties, but that will likely
|
|
// change.
|
|
diff --git chrome/browser/profiles/profile.h chrome/browser/profiles/profile.h
|
|
index 442d72296903..aec40aa4b77d 100644
|
|
--- chrome/browser/profiles/profile.h
|
|
+++ chrome/browser/profiles/profile.h
|
|
@@ -380,6 +380,11 @@ class Profile : public content::BrowserContext {
|
|
virtual bool ShouldRestoreOldSessionCookies();
|
|
virtual bool ShouldPersistSessionCookies();
|
|
|
|
+ // Returns schemes that should be cookieable, if other than the defaults.
|
|
+ virtual base::Optional<std::vector<std::string>> GetCookieableSchemes() {
|
|
+ return base::nullopt;
|
|
+ }
|
|
+
|
|
// Creates NetworkContext for the specified isolated app (or for the profile
|
|
// itself, if |relative_path| is empty).
|
|
virtual mojo::Remote<network::mojom::NetworkContext> CreateNetworkContext(
|
|
diff --git net/cookies/cookie_monster.cc net/cookies/cookie_monster.cc
|
|
index 84a7d50dfd71..aaa1346043da 100644
|
|
--- net/cookies/cookie_monster.cc
|
|
+++ net/cookies/cookie_monster.cc
|
|
@@ -476,6 +476,25 @@ void CookieMonster::SetCookieableSchemes(
|
|
MaybeRunCookieCallback(std::move(callback), true);
|
|
}
|
|
|
|
+void CookieMonster::AddCookieableSchemes(
|
|
+ const std::vector<std::string>& schemes,
|
|
+ SetCookieableSchemesCallback callback) {
|
|
+ DCHECK(thread_checker_.CalledOnValidThread());
|
|
+
|
|
+ // Calls to this method will have no effect if made after a WebView or
|
|
+ // CookieManager instance has been created.
|
|
+ if (initialized_) {
|
|
+ MaybeRunCookieCallback(std::move(callback), false);
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ if (!schemes.empty()) {
|
|
+ cookieable_schemes_.insert(cookieable_schemes_.begin(), schemes.begin(),
|
|
+ schemes.end());
|
|
+ }
|
|
+ MaybeRunCookieCallback(std::move(callback), true);
|
|
+}
|
|
+
|
|
// This function must be called before the CookieMonster is used.
|
|
void CookieMonster::SetPersistSessionCookies(bool persist_session_cookies) {
|
|
DCHECK(thread_checker_.CalledOnValidThread());
|
|
diff --git net/cookies/cookie_monster.h net/cookies/cookie_monster.h
|
|
index 431fab884a5f..eeed129b49f2 100644
|
|
--- net/cookies/cookie_monster.h
|
|
+++ net/cookies/cookie_monster.h
|
|
@@ -180,6 +180,8 @@ class NET_EXPORT CookieMonster : public CookieStore {
|
|
CookieChangeDispatcher& GetChangeDispatcher() override;
|
|
void SetCookieableSchemes(const std::vector<std::string>& schemes,
|
|
SetCookieableSchemesCallback callback) override;
|
|
+ void AddCookieableSchemes(const std::vector<std::string>& schemes,
|
|
+ SetCookieableSchemesCallback callback) override;
|
|
|
|
// Enables writing session cookies into the cookie database. If this this
|
|
// method is called, it must be called before first use of the instance
|
|
diff --git net/cookies/cookie_store.h net/cookies/cookie_store.h
|
|
index 996ad7d14dfb..5c8e43c1d29c 100644
|
|
--- net/cookies/cookie_store.h
|
|
+++ net/cookies/cookie_store.h
|
|
@@ -148,6 +148,11 @@ class NET_EXPORT CookieStore {
|
|
// Transfer ownership of a CookieAccessDelegate.
|
|
void SetCookieAccessDelegate(std::unique_ptr<CookieAccessDelegate> delegate);
|
|
|
|
+ // Adds to the list of cookieable schemes. Does nothing if called after first
|
|
+ // use of the instance (i.e. after the instance initialization process).
|
|
+ virtual void AddCookieableSchemes(const std::vector<std::string>& schemes,
|
|
+ SetCookieableSchemesCallback callback) = 0;
|
|
+
|
|
// Reports the estimate of dynamically allocated memory in bytes.
|
|
virtual void DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd,
|
|
const std::string& parent_absolute_name) const;
|
|
diff --git services/network/cookie_manager.cc services/network/cookie_manager.cc
|
|
index 5dbc9d2dfcfb..1c31d97825c2 100644
|
|
--- services/network/cookie_manager.cc
|
|
+++ services/network/cookie_manager.cc
|
|
@@ -228,14 +228,9 @@ void CookieManager::FlushCookieStore(FlushCookieStoreCallback callback) {
|
|
void CookieManager::AllowFileSchemeCookies(
|
|
bool allow,
|
|
AllowFileSchemeCookiesCallback callback) {
|
|
- std::vector<std::string> cookieable_schemes(
|
|
- net::CookieMonster::kDefaultCookieableSchemes,
|
|
- net::CookieMonster::kDefaultCookieableSchemes +
|
|
- net::CookieMonster::kDefaultCookieableSchemesCount);
|
|
- if (allow) {
|
|
- cookieable_schemes.push_back(url::kFileScheme);
|
|
- }
|
|
- cookie_store_->SetCookieableSchemes(cookieable_schemes, std::move(callback));
|
|
+ if (!allow)
|
|
+ return;
|
|
+ cookie_store_->AddCookieableSchemes({url::kFileScheme}, std::move(callback));
|
|
}
|
|
|
|
void CookieManager::SetForceKeepSessionState() {
|
|
diff --git services/network/network_context.cc services/network/network_context.cc
|
|
index e5dfb9c6fd20..07578a987dd9 100644
|
|
--- services/network/network_context.cc
|
|
+++ services/network/network_context.cc
|
|
@@ -1765,6 +1765,7 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext(
|
|
}
|
|
|
|
scoped_refptr<SessionCleanupCookieStore> session_cleanup_cookie_store;
|
|
+ std::unique_ptr<net::CookieMonster> cookie_store;
|
|
if (params_->cookie_path) {
|
|
scoped_refptr<base::SequencedTaskRunner> client_task_runner =
|
|
base::ThreadTaskRunnerHandle::Get();
|
|
@@ -1792,18 +1793,27 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext(
|
|
session_cleanup_cookie_store =
|
|
base::MakeRefCounted<SessionCleanupCookieStore>(sqlite_store);
|
|
|
|
- std::unique_ptr<net::CookieMonster> cookie_store =
|
|
+ cookie_store =
|
|
std::make_unique<net::CookieMonster>(session_cleanup_cookie_store.get(),
|
|
net_log);
|
|
if (params_->persist_session_cookies)
|
|
cookie_store->SetPersistSessionCookies(true);
|
|
-
|
|
- builder.SetCookieStore(std::move(cookie_store));
|
|
} else {
|
|
DCHECK(!params_->restore_old_session_cookies);
|
|
DCHECK(!params_->persist_session_cookies);
|
|
+
|
|
+ cookie_store =
|
|
+ std::make_unique<net::CookieMonster>(nullptr /* store */, net_log);
|
|
}
|
|
|
|
+ if (params_->cookieable_schemes.has_value()) {
|
|
+ cookie_store->SetCookieableSchemes(
|
|
+ *params_->cookieable_schemes,
|
|
+ net::CookieStore::SetCookieableSchemesCallback());
|
|
+ }
|
|
+
|
|
+ builder.SetCookieStore(std::move(cookie_store));
|
|
+
|
|
std::unique_ptr<net::StaticHttpUserAgentSettings> user_agent_settings =
|
|
std::make_unique<net::StaticHttpUserAgentSettings>(
|
|
params_->accept_language, params_->user_agent);
|
|
diff --git services/network/public/mojom/network_context.mojom services/network/public/mojom/network_context.mojom
|
|
index c37e71fb1eac..3504614682bb 100644
|
|
--- services/network/public/mojom/network_context.mojom
|
|
+++ services/network/public/mojom/network_context.mojom
|
|
@@ -243,6 +243,9 @@ struct NetworkContextParams {
|
|
// cookies. Otherwise it should be false.
|
|
bool persist_session_cookies = false;
|
|
|
|
+ // Schemes that will be passed to CookieMonster::SetCookieableSchemes.
|
|
+ array<string>? cookieable_schemes;
|
|
+
|
|
// True if an HTTP cache should be used.
|
|
bool http_cache_enabled = true;
|
|
// Maximum size of the HTTP cache. 0 means to use the default size.
|