| Index: chrome/browser/profiles/profile_impl.cc
|
| diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
|
| index c3650e8ba514879259e8d40b907acc558da8e9aa..9f473737e623dd52c92ca9612330e338b758b2d0 100644
|
| --- a/chrome/browser/profiles/profile_impl.cc
|
| +++ b/chrome/browser/profiles/profile_impl.cc
|
| @@ -48,6 +48,7 @@
|
| #include "chrome/browser/media/chrome_midi_permission_context_factory.h"
|
| #include "chrome/browser/metrics/metrics_service.h"
|
| #include "chrome/browser/net/chrome_url_request_context.h"
|
| +#include "chrome/browser/net/cookie_store_util.h"
|
| #include "chrome/browser/net/net_pref_observer.h"
|
| #include "chrome/browser/net/predictor.h"
|
| #include "chrome/browser/net/pref_proxy_config_tracker.h"
|
| @@ -86,6 +87,8 @@
|
| #include "components/user_prefs/pref_registry_syncable.h"
|
| #include "components/user_prefs/user_prefs.h"
|
| #include "content/public/browser/browser_thread.h"
|
| +#include "content/public/browser/cookie_store_factory.h"
|
| +#include "content/public/browser/cookie_store_map.h"
|
| #include "content/public/browser/dom_storage_context.h"
|
| #include "content/public/browser/host_zoom_map.h"
|
| #include "content/public/browser/notification_service.h"
|
| @@ -93,6 +96,7 @@
|
| #include "content/public/browser/storage_partition.h"
|
| #include "content/public/browser/user_metrics.h"
|
| #include "content/public/common/content_constants.h"
|
| +#include "extensions/common/constants.h"
|
| #include "grit/chromium_strings.h"
|
| #include "grit/generated_resources.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| @@ -497,8 +501,6 @@ void ProfileImpl::DoFinalInit() {
|
| g_browser_process->background_mode_manager()->RegisterProfile(this);
|
| }
|
|
|
| - base::FilePath cookie_path = GetPath();
|
| - cookie_path = cookie_path.Append(chrome::kCookieFilename);
|
| base::FilePath server_bound_cert_path = GetPath();
|
| server_bound_cert_path =
|
| server_bound_cert_path.Append(chrome::kOBCertFilename);
|
| @@ -520,28 +522,14 @@ void ProfileImpl::DoFinalInit() {
|
| infinite_cache_path =
|
| infinite_cache_path.Append(FILE_PATH_LITERAL("Infinite Cache"));
|
|
|
| -#if defined(OS_ANDROID)
|
| - SessionStartupPref::Type startup_pref_type =
|
| - SessionStartupPref::GetDefaultStartupType();
|
| -#else
|
| - SessionStartupPref::Type startup_pref_type =
|
| - StartupBrowserCreator::GetSessionStartupPref(
|
| - *CommandLine::ForCurrentProcess(), this).type;
|
| -#endif
|
| - bool restore_old_session_cookies =
|
| - (GetLastSessionExitType() == Profile::EXIT_CRASHED ||
|
| - startup_pref_type == SessionStartupPref::LAST);
|
| -
|
| InitHostZoomMap();
|
|
|
| // Make sure we initialize the ProfileIOData after everything else has been
|
| // initialized that we might be reading from the IO thread.
|
|
|
| - io_data_.Init(cookie_path, server_bound_cert_path, cache_path,
|
| + io_data_.Init(server_bound_cert_path, cache_path,
|
| cache_max_size, media_cache_path, media_cache_max_size,
|
| - extensions_cookie_path, GetPath(), infinite_cache_path,
|
| - predictor_,
|
| - restore_old_session_cookies,
|
| + GetPath(), infinite_cache_path, predictor_,
|
| GetSpecialStoragePolicy());
|
|
|
| #if defined(ENABLE_PLUGINS)
|
| @@ -559,7 +547,7 @@ void ProfileImpl::DoFinalInit() {
|
| if (!CommandLine::ForCurrentProcess()->HasSwitch(
|
| switches::kDisableRestoreSessionState)) {
|
| TRACE_EVENT0("browser", "ProfileImpl::SetSaveSessionStorageOnDisk")
|
| - content::BrowserContext::GetDefaultStoragePartition(this)->
|
| + GetDefaultStoragePartition(this)->
|
| GetDOMStorageContext()->SetSaveSessionStorageOnDisk();
|
| }
|
|
|
| @@ -677,6 +665,40 @@ bool ProfileImpl::IsOffTheRecord() const {
|
| return false;
|
| }
|
|
|
| +content::CookieStoreConfig ProfileImpl::GetCookieStoreConfig() {
|
| + // The delegate is stateless so it's silly to create more than one per
|
| + // profile.
|
| + if (!cookie_delegate_) {
|
| + cookie_delegate_ = chrome_browser_net::CreateCookieDelegate(this);
|
| + }
|
| +
|
| + if (chrome_browser_net::ShouldUseInMemoryCookiesAndCache()) {
|
| + return content::CookieStoreConfig::InMemoryWithOptions(
|
| + GetSpecialStoragePolicy(), cookie_delegate_);
|
| + }
|
| +
|
| +#if defined(OS_ANDROID)
|
| + SessionStartupPref::Type startup_pref_type =
|
| + SessionStartupPref::GetDefaultStartupType();
|
| +#else
|
| + SessionStartupPref::Type startup_pref_type =
|
| + StartupBrowserCreator::GetSessionStartupPref(
|
| + *CommandLine::ForCurrentProcess(), this).type;
|
| +#endif
|
| +
|
| + content::CookieStoreConfig::SessionCookieMode session_cookie_mode =
|
| + content::CookieStoreConfig::PERSISTANT_SESSION_COOKIES;
|
| + if (GetLastSessionExitType() == Profile::EXIT_CRASHED ||
|
| + startup_pref_type == SessionStartupPref::LAST) {
|
| + session_cookie_mode = content::CookieStoreConfig::RESTORED_SESSION_COOKIES;
|
| + }
|
| +
|
| + return content::CookieStoreConfig::PersistentWithOptions(
|
| + GetPath().Append(content::kCookieFilename),
|
| + session_cookie_mode, GetSpecialStoragePolicy(),
|
| + cookie_delegate_);
|
| +}
|
| +
|
| Profile* ProfileImpl::GetOffTheRecordProfile() {
|
| if (!off_the_record_profile_) {
|
| scoped_ptr<Profile> p(CreateOffTheRecordProfile());
|
| @@ -886,10 +908,6 @@ content::ResourceContext* ProfileImpl::GetResourceContext() {
|
| return io_data_.GetResourceContext();
|
| }
|
|
|
| -net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() {
|
| - return io_data_.GetExtensionsRequestContextGetter().get();
|
| -}
|
| -
|
| net::URLRequestContextGetter*
|
| ProfileImpl::CreateRequestContextForStoragePartition(
|
| const base::FilePath& partition_path,
|
| @@ -931,6 +949,37 @@ quota::SpecialStoragePolicy* ProfileImpl::GetSpecialStoragePolicy() {
|
| return GetExtensionSpecialStoragePolicy();
|
| }
|
|
|
| +void ProfileImpl::OverrideCookieStoreMap(
|
| + bool in_memory,
|
| + const base::FilePath& partition_path,
|
| + bool is_default,
|
| + content::CookieStoreMap* cookie_store_map) {
|
| + using content::CreateCookieStore;
|
| + using content::CookieStoreConfig;
|
| +
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| +
|
| + net::CookieStore* cookie_store = NULL;
|
| + // This is called for each StoragePartition. Currently Extensions
|
| + // should only execute on the default partition.
|
| + if (is_default) {
|
| + if (in_memory) {
|
| + cookie_store = CreateCookieStore(CookieStoreConfig::InMemory());
|
| + } else {
|
| + base::FilePath cookie_path = partition_path.Append(
|
| + chrome::kExtensionsCookieFilename);
|
| + cookie_store = CreateCookieStore(
|
| + CookieStoreConfig::Persistent(
|
| + cookie_path,
|
| + GetCookieStoreConfig().session_cookie_mode));
|
| + }
|
| +
|
| + static const char* schemes[] = { extensions::kExtensionScheme };
|
| + cookie_store->GetCookieMonster()->SetCookieableSchemes(schemes, 1);
|
| + cookie_store_map->SetForScheme(extensions::kExtensionScheme, cookie_store);
|
| + }
|
| +}
|
| +
|
| bool ProfileImpl::IsSameProfile(Profile* profile) {
|
| if (profile == static_cast<Profile*>(this))
|
| return true;
|
|
|