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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 #include "chrome/browser/extensions/extension_service.h" | 140 #include "chrome/browser/extensions/extension_service.h" |
141 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 141 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
142 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 142 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
143 #include "components/guest_view/browser/guest_view_manager.h" | 143 #include "components/guest_view/browser/guest_view_manager.h" |
144 #include "extensions/browser/extension_pref_store.h" | 144 #include "extensions/browser/extension_pref_store.h" |
145 #include "extensions/browser/extension_pref_value_map.h" | 145 #include "extensions/browser/extension_pref_value_map.h" |
146 #include "extensions/browser/extension_pref_value_map_factory.h" | 146 #include "extensions/browser/extension_pref_value_map_factory.h" |
147 #include "extensions/browser/extension_system.h" | 147 #include "extensions/browser/extension_system.h" |
148 #endif | 148 #endif |
149 | 149 |
150 #if defined(ENABLE_SUPERVISED_USERS) | 150 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
151 #include "chrome/browser/content_settings/content_settings_supervised_provider.h
" | 151 #include "chrome/browser/content_settings/content_settings_supervised_provider.h
" |
152 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 152 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
153 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" | 153 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
154 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor
y.h" | 154 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor
y.h" |
155 #endif | 155 #endif |
156 | 156 |
157 using base::Time; | 157 using base::Time; |
158 using base::TimeDelta; | 158 using base::TimeDelta; |
159 using base::UserMetricsAction; | 159 using base::UserMetricsAction; |
160 using bookmarks::BookmarkModel; | 160 using bookmarks::BookmarkModel; |
161 using content::BrowserThread; | 161 using content::BrowserThread; |
162 using content::DownloadManagerDelegate; | 162 using content::DownloadManagerDelegate; |
163 | 163 |
164 namespace { | 164 namespace { |
165 | 165 |
166 #if defined(ENABLE_SESSION_SERVICE) | 166 #if BUILDFLAG(ENABLE_SESSION_SERVICE) |
167 // Delay, in milliseconds, before we explicitly create the SessionService. | 167 // Delay, in milliseconds, before we explicitly create the SessionService. |
168 const int kCreateSessionServiceDelayMS = 500; | 168 const int kCreateSessionServiceDelayMS = 500; |
169 #endif | 169 #endif |
170 | 170 |
171 // Text content of README file created in each profile directory. Both %s | 171 // Text content of README file created in each profile directory. Both %s |
172 // placeholders must contain the product name. This is not localizable and hence | 172 // placeholders must contain the product name. This is not localizable and hence |
173 // not in resources. | 173 // not in resources. |
174 const char kReadmeText[] = | 174 const char kReadmeText[] = |
175 "%s settings and storage represent user-selected preferences and " | 175 "%s settings and storage represent user-selected preferences and " |
176 "information and MUST not be extracted, overwritten or modified except " | 176 "information and MUST not be extracted, overwritten or modified except " |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 pref_registry_(new user_prefs::PrefRegistrySyncable), | 402 pref_registry_(new user_prefs::PrefRegistrySyncable), |
403 io_data_(this), | 403 io_data_(this), |
404 last_session_exit_type_(EXIT_NORMAL), | 404 last_session_exit_type_(EXIT_NORMAL), |
405 start_time_(Time::Now()), | 405 start_time_(Time::Now()), |
406 delegate_(delegate), | 406 delegate_(delegate), |
407 predictor_(NULL) { | 407 predictor_(NULL) { |
408 TRACE_EVENT0("browser,startup", "ProfileImpl::ctor") | 408 TRACE_EVENT0("browser,startup", "ProfileImpl::ctor") |
409 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 409 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
410 "profile files to the root directory!"; | 410 "profile files to the root directory!"; |
411 | 411 |
412 #if defined(ENABLE_SESSION_SERVICE) | 412 #if BUILDFLAG(ENABLE_SESSION_SERVICE) |
413 create_session_service_timer_.Start(FROM_HERE, | 413 create_session_service_timer_.Start(FROM_HERE, |
414 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, | 414 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
415 &ProfileImpl::EnsureSessionServiceCreated); | 415 &ProfileImpl::EnsureSessionServiceCreated); |
416 #endif | 416 #endif |
417 | 417 |
418 set_is_guest_profile(path == ProfileManager::GetGuestProfilePath()); | 418 set_is_guest_profile(path == ProfileManager::GetGuestProfilePath()); |
419 set_is_system_profile(path == ProfileManager::GetSystemProfilePath()); | 419 set_is_system_profile(path == ProfileManager::GetSystemProfilePath()); |
420 | 420 |
421 // If profile_manager is not present, it means we are in a unittest. | 421 // If profile_manager is not present, it means we are in a unittest. |
422 predictor_ = chrome_browser_net::Predictor::CreatePredictor( | 422 predictor_ = chrome_browser_net::Predictor::CreatePredictor( |
(...skipping 30 matching lines...) Expand all Loading... |
453 if (chromeos::ProfileHelper::IsSigninProfile(this)) | 453 if (chromeos::ProfileHelper::IsSigninProfile(this)) |
454 chrome::RegisterLoginProfilePrefs(pref_registry_.get()); | 454 chrome::RegisterLoginProfilePrefs(pref_registry_.get()); |
455 else | 455 else |
456 #endif | 456 #endif |
457 chrome::RegisterUserProfilePrefs(pref_registry_.get()); | 457 chrome::RegisterUserProfilePrefs(pref_registry_.get()); |
458 | 458 |
459 BrowserContextDependencyManager::GetInstance()-> | 459 BrowserContextDependencyManager::GetInstance()-> |
460 RegisterProfilePrefsForServices(this, pref_registry_.get()); | 460 RegisterProfilePrefsForServices(this, pref_registry_.get()); |
461 | 461 |
462 SupervisedUserSettingsService* supervised_user_settings = nullptr; | 462 SupervisedUserSettingsService* supervised_user_settings = nullptr; |
463 #if defined(ENABLE_SUPERVISED_USERS) | 463 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
464 supervised_user_settings = | 464 supervised_user_settings = |
465 SupervisedUserSettingsServiceFactory::GetForProfile(this); | 465 SupervisedUserSettingsServiceFactory::GetForProfile(this); |
466 supervised_user_settings->Init( | 466 supervised_user_settings->Init( |
467 path_, sequenced_task_runner, create_mode == CREATE_MODE_SYNCHRONOUS); | 467 path_, sequenced_task_runner, create_mode == CREATE_MODE_SYNCHRONOUS); |
468 #endif | 468 #endif |
469 | 469 |
470 scoped_refptr<safe_browsing::SafeBrowsingService> safe_browsing_service( | 470 scoped_refptr<safe_browsing::SafeBrowsingService> safe_browsing_service( |
471 g_browser_process->safe_browsing_service()); | 471 g_browser_process->safe_browsing_service()); |
472 if (safe_browsing_service.get()) { | 472 if (safe_browsing_service.get()) { |
473 pref_validation_delegate_ = | 473 pref_validation_delegate_ = |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 void ProfileImpl::set_last_selected_directory(const base::FilePath& path) { | 672 void ProfileImpl::set_last_selected_directory(const base::FilePath& path) { |
673 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); | 673 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); |
674 } | 674 } |
675 | 675 |
676 ProfileImpl::~ProfileImpl() { | 676 ProfileImpl::~ProfileImpl() { |
677 MaybeSendDestroyedNotification(); | 677 MaybeSendDestroyedNotification(); |
678 | 678 |
679 bool prefs_loaded = prefs_->GetInitializationStatus() != | 679 bool prefs_loaded = prefs_->GetInitializationStatus() != |
680 PrefService::INITIALIZATION_STATUS_WAITING; | 680 PrefService::INITIALIZATION_STATUS_WAITING; |
681 | 681 |
682 #if defined(ENABLE_SESSION_SERVICE) | 682 #if BUILDFLAG(ENABLE_SESSION_SERVICE) |
683 StopCreateSessionServiceTimer(); | 683 StopCreateSessionServiceTimer(); |
684 #endif | 684 #endif |
685 | 685 |
686 // Remove pref observers | 686 // Remove pref observers |
687 pref_change_registrar_.RemoveAll(); | 687 pref_change_registrar_.RemoveAll(); |
688 | 688 |
689 #if defined(ENABLE_PLUGINS) | 689 #if defined(ENABLE_PLUGINS) |
690 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( | 690 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( |
691 io_data_.GetResourceContextNoInit()); | 691 io_data_.GetResourceContextNoInit()); |
692 #endif | 692 #endif |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 | 778 |
779 Profile* ProfileImpl::GetOriginalProfile() { | 779 Profile* ProfileImpl::GetOriginalProfile() { |
780 return this; | 780 return this; |
781 } | 781 } |
782 | 782 |
783 bool ProfileImpl::IsSupervised() const { | 783 bool ProfileImpl::IsSupervised() const { |
784 return !GetPrefs()->GetString(prefs::kSupervisedUserId).empty(); | 784 return !GetPrefs()->GetString(prefs::kSupervisedUserId).empty(); |
785 } | 785 } |
786 | 786 |
787 bool ProfileImpl::IsChild() const { | 787 bool ProfileImpl::IsChild() const { |
788 #if defined(ENABLE_SUPERVISED_USERS) | 788 #if BUILDFLAG(ENABLE_SUPERVISED_USERS) |
789 return GetPrefs()->GetString(prefs::kSupervisedUserId) == | 789 return GetPrefs()->GetString(prefs::kSupervisedUserId) == |
790 supervised_users::kChildAccountSUID; | 790 supervised_users::kChildAccountSUID; |
791 #else | 791 #else |
792 return false; | 792 return false; |
793 #endif | 793 #endif |
794 } | 794 } |
795 | 795 |
796 bool ProfileImpl::IsLegacySupervised() const { | 796 bool ProfileImpl::IsLegacySupervised() const { |
797 return IsSupervised() && !IsChild(); | 797 return IsSupervised() && !IsChild(); |
798 } | 798 } |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 if (profile == static_cast<Profile*>(this)) | 1027 if (profile == static_cast<Profile*>(this)) |
1028 return true; | 1028 return true; |
1029 Profile* otr_profile = off_the_record_profile_.get(); | 1029 Profile* otr_profile = off_the_record_profile_.get(); |
1030 return otr_profile && profile == otr_profile; | 1030 return otr_profile && profile == otr_profile; |
1031 } | 1031 } |
1032 | 1032 |
1033 Time ProfileImpl::GetStartTime() const { | 1033 Time ProfileImpl::GetStartTime() const { |
1034 return start_time_; | 1034 return start_time_; |
1035 } | 1035 } |
1036 | 1036 |
1037 #if defined(ENABLE_SESSION_SERVICE) | 1037 #if BUILDFLAG(ENABLE_SESSION_SERVICE) |
1038 void ProfileImpl::StopCreateSessionServiceTimer() { | 1038 void ProfileImpl::StopCreateSessionServiceTimer() { |
1039 create_session_service_timer_.Stop(); | 1039 create_session_service_timer_.Stop(); |
1040 } | 1040 } |
1041 | 1041 |
1042 void ProfileImpl::EnsureSessionServiceCreated() { | 1042 void ProfileImpl::EnsureSessionServiceCreated() { |
1043 SessionServiceFactory::GetForProfile(this); | 1043 SessionServiceFactory::GetForProfile(this); |
1044 } | 1044 } |
1045 #endif | 1045 #endif |
1046 | 1046 |
1047 #if defined(OS_CHROMEOS) | 1047 #if defined(OS_CHROMEOS) |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1272 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { | 1272 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { |
1273 domain_reliability::DomainReliabilityService* service = | 1273 domain_reliability::DomainReliabilityService* service = |
1274 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> | 1274 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> |
1275 GetForBrowserContext(this); | 1275 GetForBrowserContext(this); |
1276 if (!service) | 1276 if (!service) |
1277 return std::unique_ptr<domain_reliability::DomainReliabilityMonitor>(); | 1277 return std::unique_ptr<domain_reliability::DomainReliabilityMonitor>(); |
1278 | 1278 |
1279 return service->CreateMonitor( | 1279 return service->CreateMonitor( |
1280 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); | 1280 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); |
1281 } | 1281 } |
OLD | NEW |