| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/profiles/profile_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 #include "components/omnibox/browser/autocomplete_classifier.h" | 99 #include "components/omnibox/browser/autocomplete_classifier.h" |
| 100 #include "components/policy/core/browser/browser_policy_connector.h" | 100 #include "components/policy/core/browser/browser_policy_connector.h" |
| 101 #include "components/pref_registry/pref_registry_syncable.h" | 101 #include "components/pref_registry/pref_registry_syncable.h" |
| 102 #include "components/prefs/json_pref_store.h" | 102 #include "components/prefs/json_pref_store.h" |
| 103 #include "components/prefs/scoped_user_pref_update.h" | 103 #include "components/prefs/scoped_user_pref_update.h" |
| 104 #include "components/proxy_config/pref_proxy_config_tracker.h" | 104 #include "components/proxy_config/pref_proxy_config_tracker.h" |
| 105 #include "components/signin/core/browser/signin_manager.h" | 105 #include "components/signin/core/browser/signin_manager.h" |
| 106 #include "components/signin/core/common/signin_pref_names.h" | 106 #include "components/signin/core/common/signin_pref_names.h" |
| 107 #include "components/ssl_config/ssl_config_service_manager.h" | 107 #include "components/ssl_config/ssl_config_service_manager.h" |
| 108 #include "components/sync_preferences/pref_service_syncable.h" | 108 #include "components/sync_preferences/pref_service_syncable.h" |
| 109 #include "components/sync_preferences/pref_service_syncable_factory.h" |
| 109 #include "components/url_formatter/url_fixer.h" | 110 #include "components/url_formatter/url_fixer.h" |
| 110 #include "components/user_prefs/user_prefs.h" | 111 #include "components/user_prefs/user_prefs.h" |
| 111 #include "components/zoom/zoom_event_manager.h" | 112 #include "components/zoom/zoom_event_manager.h" |
| 112 #include "content/public/browser/browser_thread.h" | 113 #include "content/public/browser/browser_thread.h" |
| 113 #include "content/public/browser/dom_storage_context.h" | 114 #include "content/public/browser/dom_storage_context.h" |
| 114 #include "content/public/browser/notification_service.h" | 115 #include "content/public/browser/notification_service.h" |
| 115 #include "content/public/browser/render_process_host.h" | 116 #include "content/public/browser/render_process_host.h" |
| 116 #include "content/public/browser/storage_partition.h" | 117 #include "content/public/browser/storage_partition.h" |
| 117 #include "content/public/browser/url_data_source.h" | 118 #include "content/public/browser/url_data_source.h" |
| 118 #include "content/public/common/content_constants.h" | 119 #include "content/public/common/content_constants.h" |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 } | 497 } |
| 497 } | 498 } |
| 498 | 499 |
| 499 content::BrowserContext::Initialize(this, path_); | 500 content::BrowserContext::Initialize(this, path_); |
| 500 | 501 |
| 501 { | 502 { |
| 502 service_manager::Connector* connector = nullptr; | 503 service_manager::Connector* connector = nullptr; |
| 503 if (features::PrefServiceEnabled()) { | 504 if (features::PrefServiceEnabled()) { |
| 504 connector = content::BrowserContext::GetConnectorFor(this); | 505 connector = content::BrowserContext::GetConnectorFor(this); |
| 505 } | 506 } |
| 506 prefs_ = chrome_prefs::CreateProfilePrefs( | 507 prefs_factory_ = chrome_prefs::CreateProfilePrefs( |
| 507 path_, std::move(pref_validation_delegate), | 508 path_, std::move(pref_validation_delegate), |
| 508 profile_policy_connector_->policy_service(), supervised_user_settings, | 509 profile_policy_connector_->policy_service(), supervised_user_settings, |
| 509 CreateExtensionPrefStore(this, false), pref_registry_, async_prefs, | 510 CreateExtensionPrefStore(this, false), pref_registry_, async_prefs, |
| 510 connector); | 511 connector); |
| 512 prefs_ = prefs_factory_->CreateSyncable(pref_registry_.get(), connector); |
| 511 // Register on BrowserContext. | 513 // Register on BrowserContext. |
| 512 user_prefs::UserPrefs::Set(this, prefs_.get()); | 514 user_prefs::UserPrefs::Set(this, prefs_.get()); |
| 513 } | 515 } |
| 514 | 516 |
| 515 if (async_prefs) { | 517 if (async_prefs) { |
| 516 // Wait for the notification that prefs has been loaded | 518 // Wait for the notification that prefs has been loaded |
| 517 // (successfully or not). Note that we can use base::Unretained | 519 // (successfully or not). Note that we can use base::Unretained |
| 518 // because the PrefService is owned by this class and lives on | 520 // because the PrefService is owned by this class and lives on |
| 519 // the same thread. | 521 // the same thread. |
| 520 prefs_->AddPrefInitObserver(base::Bind( | 522 prefs_->AddPrefInitObserver(base::Bind( |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 const PrefService* ProfileImpl::GetPrefs() const { | 962 const PrefService* ProfileImpl::GetPrefs() const { |
| 961 DCHECK(prefs_); // Should explicitly be initialized. | 963 DCHECK(prefs_); // Should explicitly be initialized. |
| 962 return prefs_.get(); | 964 return prefs_.get(); |
| 963 } | 965 } |
| 964 | 966 |
| 965 ChromeZoomLevelPrefs* ProfileImpl::GetZoomLevelPrefs() { | 967 ChromeZoomLevelPrefs* ProfileImpl::GetZoomLevelPrefs() { |
| 966 return static_cast<ChromeZoomLevelPrefs*>( | 968 return static_cast<ChromeZoomLevelPrefs*>( |
| 967 GetDefaultStoragePartition(this)->GetZoomLevelDelegate()); | 969 GetDefaultStoragePartition(this)->GetZoomLevelDelegate()); |
| 968 } | 970 } |
| 969 | 971 |
| 970 PrefService* ProfileImpl::GetOffTheRecordPrefs() { | 972 sync_preferences::PrefServiceSyncable* ProfileImpl::CreateOffTheRecordPrefs( |
| 973 service_manager::Connector* otr_connector) { |
| 971 DCHECK(prefs_); | 974 DCHECK(prefs_); |
| 972 if (!otr_prefs_) { | 975 if (!otr_prefs_) { |
| 976 service_manager::Connector* user_connector = nullptr; |
| 977 if (otr_connector) { |
| 978 user_connector = content::BrowserContext::GetConnectorFor(this); |
| 979 } |
| 980 // List of keys that cannot be changed in the user prefs file by the |
| 981 // incognito |
| 982 // profile. All preferences that store information about the browsing |
| 983 // history or behavior of the user should have this property. |
| 984 std::vector<const char*> overlay_pref_names; |
| 985 overlay_pref_names.push_back(prefs::kBrowserWindowPlacement); |
| 986 overlay_pref_names.push_back(prefs::kMediaRouterTabMirroringSources); |
| 987 overlay_pref_names.push_back(prefs::kSaveFileDefaultDirectory); |
| 988 #if defined(OS_ANDROID) |
| 989 overlay_pref_names.push_back(proxy_config::prefs::kProxy); |
| 990 #endif |
| 991 |
| 973 // The new ExtensionPrefStore is ref_counted and the new PrefService | 992 // The new ExtensionPrefStore is ref_counted and the new PrefService |
| 974 // stores a reference so that we do not leak memory here. | 993 // stores a reference so that we do not leak memory here. |
| 975 otr_prefs_.reset(CreateIncognitoPrefServiceSyncable( | 994 otr_prefs_ = prefs_factory_->CreateIncognitoSyncable( |
| 976 prefs_.get(), CreateExtensionPrefStore(this, true))); | 995 pref_registry_.get(), CreateExtensionPrefStore(this, true), |
| 996 overlay_pref_names, chrome::InProcessIncognitoPrefStores(), |
| 997 otr_connector, user_connector); |
| 977 } | 998 } |
| 978 return otr_prefs_.get(); | 999 return otr_prefs_.get(); |
| 979 } | 1000 } |
| 980 | 1001 |
| 1002 PrefService* ProfileImpl::GetOffTheRecordPrefs() { |
| 1003 return GetOffTheRecordProfile()->GetPrefs(); |
| 1004 } |
| 1005 |
| 981 content::ResourceContext* ProfileImpl::GetResourceContext() { | 1006 content::ResourceContext* ProfileImpl::GetResourceContext() { |
| 982 return io_data_.GetResourceContext(); | 1007 return io_data_.GetResourceContext(); |
| 983 } | 1008 } |
| 984 | 1009 |
| 985 net::URLRequestContextGetter* ProfileImpl::GetRequestContext() { | 1010 net::URLRequestContextGetter* ProfileImpl::GetRequestContext() { |
| 986 return GetDefaultStoragePartition(this)->GetURLRequestContext(); | 1011 return GetDefaultStoragePartition(this)->GetURLRequestContext(); |
| 987 } | 1012 } |
| 988 | 1013 |
| 989 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { | 1014 net::URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() { |
| 990 return io_data_.GetExtensionsRequestContextGetter().get(); | 1015 return io_data_.GetExtensionsRequestContextGetter().get(); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 return std::unique_ptr<domain_reliability::DomainReliabilityMonitor>(); | 1386 return std::unique_ptr<domain_reliability::DomainReliabilityMonitor>(); |
| 1362 | 1387 |
| 1363 return service->CreateMonitor( | 1388 return service->CreateMonitor( |
| 1364 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); | 1389 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); |
| 1365 } | 1390 } |
| 1366 | 1391 |
| 1367 std::unique_ptr<service_manager::Service> ProfileImpl::CreateIdentityService() { | 1392 std::unique_ptr<service_manager::Service> ProfileImpl::CreateIdentityService() { |
| 1368 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile(this); | 1393 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile(this); |
| 1369 return base::MakeUnique<identity::IdentityService>(signin_manager); | 1394 return base::MakeUnique<identity::IdentityService>(signin_manager); |
| 1370 } | 1395 } |
| OLD | NEW |