| 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 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 53 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 54 #include "chrome/browser/policy/schema_registry_service.h" | 54 #include "chrome/browser/policy/schema_registry_service.h" |
| 55 #include "chrome/browser/policy/schema_registry_service_factory.h" | 55 #include "chrome/browser/policy/schema_registry_service_factory.h" |
| 56 #include "chrome/browser/prefs/browser_prefs.h" | 56 #include "chrome/browser/prefs/browser_prefs.h" |
| 57 #include "chrome/browser/prefs/chrome_pref_service_factory.h" | 57 #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
| 58 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 58 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
| 59 #include "chrome/browser/prerender/prerender_manager_factory.h" | 59 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 60 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" | 60 #include "chrome/browser/profiles/bookmark_model_loaded_observer.h" |
| 61 #include "chrome/browser/profiles/chrome_version_service.h" | 61 #include "chrome/browser/profiles/chrome_version_service.h" |
| 62 #include "chrome/browser/profiles/gaia_info_update_service_factory.h" | 62 #include "chrome/browser/profiles/gaia_info_update_service_factory.h" |
| 63 #include "chrome/browser/profiles/profile_attributes_entry.h" |
| 64 #include "chrome/browser/profiles/profile_attributes_storage.h" |
| 63 #include "chrome/browser/profiles/profile_destroyer.h" | 65 #include "chrome/browser/profiles/profile_destroyer.h" |
| 64 #include "chrome/browser/profiles/profile_info_cache.h" | |
| 65 #include "chrome/browser/profiles/profile_manager.h" | 66 #include "chrome/browser/profiles/profile_manager.h" |
| 66 #include "chrome/browser/profiles/profile_metrics.h" | 67 #include "chrome/browser/profiles/profile_metrics.h" |
| 67 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" | 68 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" |
| 68 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" | 69 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" |
| 69 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 70 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 70 #include "chrome/browser/sessions/session_service_factory.h" | 71 #include "chrome/browser/sessions/session_service_factory.h" |
| 71 #include "chrome/browser/signin/signin_manager_factory.h" | 72 #include "chrome/browser/signin/signin_manager_factory.h" |
| 72 #include "chrome/browser/signin/signin_ui_util.h" | 73 #include "chrome/browser/signin/signin_ui_util.h" |
| 73 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" | 74 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
| 74 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" | 75 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 } | 482 } |
| 482 | 483 |
| 483 void ProfileImpl::DoFinalInit() { | 484 void ProfileImpl::DoFinalInit() { |
| 484 TRACE_EVENT0("browser", "ProfileImpl::DoFinalInit") | 485 TRACE_EVENT0("browser", "ProfileImpl::DoFinalInit") |
| 485 SCOPED_UMA_HISTOGRAM_TIMER("Profile.ProfileImplDoFinalInit"); | 486 SCOPED_UMA_HISTOGRAM_TIMER("Profile.ProfileImplDoFinalInit"); |
| 486 | 487 |
| 487 PrefService* prefs = GetPrefs(); | 488 PrefService* prefs = GetPrefs(); |
| 488 pref_change_registrar_.Init(prefs); | 489 pref_change_registrar_.Init(prefs); |
| 489 pref_change_registrar_.Add( | 490 pref_change_registrar_.Add( |
| 490 prefs::kSupervisedUserId, | 491 prefs::kSupervisedUserId, |
| 491 base::Bind(&ProfileImpl::UpdateProfileSupervisedUserIdCache, | 492 base::Bind(&ProfileImpl::UpdateSupervisedUserIdInStorage, |
| 492 base::Unretained(this))); | 493 base::Unretained(this))); |
| 493 | 494 |
| 494 // Changes in the profile avatar. | 495 // Changes in the profile avatar. |
| 495 pref_change_registrar_.Add( | 496 pref_change_registrar_.Add( |
| 496 prefs::kProfileAvatarIndex, | 497 prefs::kProfileAvatarIndex, |
| 497 base::Bind(&ProfileImpl::UpdateProfileAvatarCache, | 498 base::Bind(&ProfileImpl::UpdateAvatarInStorage, |
| 498 base::Unretained(this))); | 499 base::Unretained(this))); |
| 499 pref_change_registrar_.Add( | 500 pref_change_registrar_.Add( |
| 500 prefs::kProfileUsingDefaultAvatar, | 501 prefs::kProfileUsingDefaultAvatar, |
| 501 base::Bind(&ProfileImpl::UpdateProfileAvatarCache, | 502 base::Bind(&ProfileImpl::UpdateAvatarInStorage, |
| 502 base::Unretained(this))); | 503 base::Unretained(this))); |
| 503 pref_change_registrar_.Add( | 504 pref_change_registrar_.Add( |
| 504 prefs::kProfileUsingGAIAAvatar, | 505 prefs::kProfileUsingGAIAAvatar, |
| 505 base::Bind(&ProfileImpl::UpdateProfileAvatarCache, | 506 base::Bind(&ProfileImpl::UpdateAvatarInStorage, |
| 506 base::Unretained(this))); | 507 base::Unretained(this))); |
| 507 | 508 |
| 508 // Changes in the profile name. | 509 // Changes in the profile name. |
| 509 pref_change_registrar_.Add( | 510 pref_change_registrar_.Add( |
| 510 prefs::kProfileUsingDefaultName, | 511 prefs::kProfileUsingDefaultName, |
| 511 base::Bind(&ProfileImpl::UpdateProfileNameCache, | 512 base::Bind(&ProfileImpl::UpdateNameInStorage, |
| 512 base::Unretained(this))); | 513 base::Unretained(this))); |
| 513 pref_change_registrar_.Add( | 514 pref_change_registrar_.Add( |
| 514 prefs::kProfileName, | 515 prefs::kProfileName, |
| 515 base::Bind(&ProfileImpl::UpdateProfileNameCache, | 516 base::Bind(&ProfileImpl::UpdateNameInStorage, |
| 516 base::Unretained(this))); | 517 base::Unretained(this))); |
| 517 | 518 |
| 518 pref_change_registrar_.Add( | 519 pref_change_registrar_.Add( |
| 519 prefs::kForceEphemeralProfiles, | 520 prefs::kForceEphemeralProfiles, |
| 520 base::Bind(&ProfileImpl::UpdateProfileIsEphemeralCache, | 521 base::Bind(&ProfileImpl::UpdateIsEphemeralInStorage, |
| 521 base::Unretained(this))); | 522 base::Unretained(this))); |
| 522 | 523 |
| 523 // It would be nice to use PathService for fetching this directory, but | 524 // It would be nice to use PathService for fetching this directory, but |
| 524 // the cache directory depends on the profile directory, which isn't available | 525 // the cache directory depends on the profile directory, which isn't available |
| 525 // to PathService. | 526 // to PathService. |
| 526 chrome::GetUserCacheDirectory(path_, &base_cache_path_); | 527 chrome::GetUserCacheDirectory(path_, &base_cache_path_); |
| 527 // Always create the cache directory asynchronously. | 528 // Always create the cache directory asynchronously. |
| 528 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = | 529 scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = |
| 529 JsonPrefStore::GetTaskRunnerForFile(base_cache_path_, | 530 JsonPrefStore::GetTaskRunnerForFile(base_cache_path_, |
| 530 BrowserThread::GetBlockingPool()); | 531 BrowserThread::GetBlockingPool()); |
| 531 CreateProfileDirectory(sequenced_task_runner.get(), base_cache_path_, false); | 532 CreateProfileDirectory(sequenced_task_runner.get(), base_cache_path_, false); |
| 532 | 533 |
| 533 // Initialize components that depend on the current value. | 534 // Initialize components that depend on the current value. |
| 534 UpdateProfileSupervisedUserIdCache(); | 535 UpdateSupervisedUserIdInStorage(); |
| 535 UpdateProfileIsEphemeralCache(); | 536 UpdateIsEphemeralInStorage(); |
| 536 GAIAInfoUpdateServiceFactory::GetForProfile(this); | 537 GAIAInfoUpdateServiceFactory::GetForProfile(this); |
| 537 | 538 |
| 538 PrefService* local_state = g_browser_process->local_state(); | 539 PrefService* local_state = g_browser_process->local_state(); |
| 539 ssl_config_service_manager_.reset( | 540 ssl_config_service_manager_.reset( |
| 540 ssl_config::SSLConfigServiceManager::CreateDefaultManager( | 541 ssl_config::SSLConfigServiceManager::CreateDefaultManager( |
| 541 local_state, | 542 local_state, |
| 542 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 543 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
| 543 | 544 |
| 544 #if BUILDFLAG(ENABLE_BACKGROUND) | 545 #if BUILDFLAG(ENABLE_BACKGROUND) |
| 545 // Initialize the BackgroundModeManager - this has to be done here before | 546 // Initialize the BackgroundModeManager - this has to be done here before |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 | 1186 |
| 1186 if (GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)) | 1187 if (GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)) |
| 1187 return GURL(chrome::kChromeUINewTabURL); | 1188 return GURL(chrome::kChromeUINewTabURL); |
| 1188 GURL home_page(url_formatter::FixupURL( | 1189 GURL home_page(url_formatter::FixupURL( |
| 1189 GetPrefs()->GetString(prefs::kHomePage), std::string())); | 1190 GetPrefs()->GetString(prefs::kHomePage), std::string())); |
| 1190 if (!home_page.is_valid()) | 1191 if (!home_page.is_valid()) |
| 1191 return GURL(chrome::kChromeUINewTabURL); | 1192 return GURL(chrome::kChromeUINewTabURL); |
| 1192 return home_page; | 1193 return home_page; |
| 1193 } | 1194 } |
| 1194 | 1195 |
| 1195 void ProfileImpl::UpdateProfileSupervisedUserIdCache() { | 1196 void ProfileImpl::UpdateSupervisedUserIdInStorage() { |
| 1196 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1197 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1197 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1198 ProfileAttributesEntry* entry; |
| 1198 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | 1199 bool has_entry = profile_manager->GetProfileAttributesStorage(). |
| 1199 if (index != std::string::npos) { | 1200 GetProfileAttributesWithPath(GetPath(), &entry); |
| 1200 std::string supervised_user_id = | 1201 if (has_entry) { |
| 1201 GetPrefs()->GetString(prefs::kSupervisedUserId); | 1202 entry->SetSupervisedUserId(GetPrefs()->GetString(prefs::kSupervisedUserId)); |
| 1202 cache.SetSupervisedUserIdOfProfileAtIndex(index, supervised_user_id); | |
| 1203 ProfileMetrics::UpdateReportedProfilesStatistics(profile_manager); | 1203 ProfileMetrics::UpdateReportedProfilesStatistics(profile_manager); |
| 1204 } | 1204 } |
| 1205 } | 1205 } |
| 1206 | 1206 |
| 1207 void ProfileImpl::UpdateProfileNameCache() { | 1207 void ProfileImpl::UpdateNameInStorage() { |
| 1208 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1208 ProfileAttributesEntry* entry; |
| 1209 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1209 bool has_entry = |
| 1210 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | 1210 g_browser_process->profile_manager()->GetProfileAttributesStorage(). |
| 1211 if (index != std::string::npos) { | 1211 GetProfileAttributesWithPath(GetPath(), &entry); |
| 1212 std::string profile_name = | 1212 if (has_entry) { |
| 1213 GetPrefs()->GetString(prefs::kProfileName); | 1213 entry->SetName( |
| 1214 cache.SetNameOfProfileAtIndex(index, base::UTF8ToUTF16(profile_name)); | 1214 base::UTF8ToUTF16(GetPrefs()->GetString(prefs::kProfileName))); |
| 1215 bool default_name = | 1215 entry->SetIsUsingDefaultName( |
| 1216 GetPrefs()->GetBoolean(prefs::kProfileUsingDefaultName); | 1216 GetPrefs()->GetBoolean(prefs::kProfileUsingDefaultName)); |
| 1217 cache.SetProfileIsUsingDefaultNameAtIndex(index, default_name); | |
| 1218 } | 1217 } |
| 1219 } | 1218 } |
| 1220 | 1219 |
| 1221 void ProfileImpl::UpdateProfileAvatarCache() { | 1220 void ProfileImpl::UpdateAvatarInStorage() { |
| 1222 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1221 ProfileAttributesEntry* entry; |
| 1223 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1222 bool has_entry = |
| 1224 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | 1223 g_browser_process->profile_manager()->GetProfileAttributesStorage(). |
| 1225 if (index != std::string::npos) { | 1224 GetProfileAttributesWithPath(GetPath(), &entry); |
| 1226 size_t avatar_index = | 1225 if (has_entry) { |
| 1227 GetPrefs()->GetInteger(prefs::kProfileAvatarIndex); | 1226 entry->SetAvatarIconIndex( |
| 1228 cache.SetAvatarIconOfProfileAtIndex(index, avatar_index); | 1227 GetPrefs()->GetInteger(prefs::kProfileAvatarIndex)); |
| 1229 bool default_avatar = | 1228 entry->SetIsUsingDefaultAvatar( |
| 1230 GetPrefs()->GetBoolean(prefs::kProfileUsingDefaultAvatar); | 1229 GetPrefs()->GetBoolean(prefs::kProfileUsingDefaultAvatar)); |
| 1231 cache.SetProfileIsUsingDefaultAvatarAtIndex(index, default_avatar); | 1230 entry->SetIsUsingGAIAPicture( |
| 1232 bool gaia_avatar = | 1231 GetPrefs()->GetBoolean(prefs::kProfileUsingGAIAAvatar)); |
| 1233 GetPrefs()->GetBoolean(prefs::kProfileUsingGAIAAvatar); | |
| 1234 cache.SetIsUsingGAIAPictureOfProfileAtIndex(index, gaia_avatar); | |
| 1235 } | 1232 } |
| 1236 } | 1233 } |
| 1237 | 1234 |
| 1238 void ProfileImpl::UpdateProfileIsEphemeralCache() { | 1235 void ProfileImpl::UpdateIsEphemeralInStorage() { |
| 1239 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1236 ProfileAttributesEntry* entry; |
| 1240 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 1237 bool has_entry = |
| 1241 size_t index = cache.GetIndexOfProfileWithPath(GetPath()); | 1238 g_browser_process->profile_manager()->GetProfileAttributesStorage(). |
| 1242 if (index != std::string::npos) { | 1239 GetProfileAttributesWithPath(GetPath(), &entry); |
| 1243 bool is_ephemeral = GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles); | 1240 if (has_entry) { |
| 1244 cache.SetProfileIsEphemeralAtIndex(index, is_ephemeral); | 1241 entry->SetIsEphemeral( |
| 1242 GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)); |
| 1245 } | 1243 } |
| 1246 } | 1244 } |
| 1247 | 1245 |
| 1248 // Gets the cache parameters from the command line. If |is_media_context| is | 1246 // Gets the cache parameters from the command line. If |is_media_context| is |
| 1249 // set to true then settings for the media context type is what we need, | 1247 // set to true then settings for the media context type is what we need, |
| 1250 // |cache_path| will be set to the user provided path, or will not be touched if | 1248 // |cache_path| will be set to the user provided path, or will not be touched if |
| 1251 // there is not an argument. |max_size| will be the user provided value or zero | 1249 // there is not an argument. |max_size| will be the user provided value or zero |
| 1252 // by default. | 1250 // by default. |
| 1253 void ProfileImpl::GetCacheParameters(bool is_media_context, | 1251 void ProfileImpl::GetCacheParameters(bool is_media_context, |
| 1254 base::FilePath* cache_path, | 1252 base::FilePath* cache_path, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1277 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { | 1275 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { |
| 1278 domain_reliability::DomainReliabilityService* service = | 1276 domain_reliability::DomainReliabilityService* service = |
| 1279 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> | 1277 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> |
| 1280 GetForBrowserContext(this); | 1278 GetForBrowserContext(this); |
| 1281 if (!service) | 1279 if (!service) |
| 1282 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); | 1280 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); |
| 1283 | 1281 |
| 1284 return service->CreateMonitor( | 1282 return service->CreateMonitor( |
| 1285 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 1283 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
| 1286 } | 1284 } |
| OLD | NEW |