| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 const base::FilePath& path, | 372 const base::FilePath& path, |
| 373 Delegate* delegate, | 373 Delegate* delegate, |
| 374 CreateMode create_mode, | 374 CreateMode create_mode, |
| 375 base::SequencedTaskRunner* sequenced_task_runner) | 375 base::SequencedTaskRunner* sequenced_task_runner) |
| 376 : path_(path), | 376 : path_(path), |
| 377 pref_registry_(new user_prefs::PrefRegistrySyncable), | 377 pref_registry_(new user_prefs::PrefRegistrySyncable), |
| 378 io_data_(this), | 378 io_data_(this), |
| 379 host_content_settings_map_(NULL), | 379 host_content_settings_map_(NULL), |
| 380 last_session_exit_type_(EXIT_NORMAL), | 380 last_session_exit_type_(EXIT_NORMAL), |
| 381 start_time_(Time::Now()), | 381 start_time_(Time::Now()), |
| 382 #if defined(OS_CHROMEOS) | |
| 383 is_login_profile_(false), | |
| 384 #endif | |
| 385 delegate_(delegate), | 382 delegate_(delegate), |
| 386 predictor_(NULL) { | 383 predictor_(NULL) { |
| 387 TRACE_EVENT0("browser", "ProfileImpl::ctor") | 384 TRACE_EVENT0("browser", "ProfileImpl::ctor") |
| 388 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 385 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
| 389 "profile files to the root directory!"; | 386 "profile files to the root directory!"; |
| 390 | 387 |
| 391 #if defined(ENABLE_SESSION_SERVICE) | 388 #if defined(ENABLE_SESSION_SERVICE) |
| 392 create_session_service_timer_.Start(FROM_HERE, | 389 create_session_service_timer_.Start(FROM_HERE, |
| 393 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, | 390 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
| 394 &ProfileImpl::EnsureSessionServiceCreated); | 391 &ProfileImpl::EnsureSessionServiceCreated); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 417 #endif | 414 #endif |
| 418 profile_policy_connector_ = | 415 profile_policy_connector_ = |
| 419 policy::ProfilePolicyConnectorFactory::CreateForProfile( | 416 policy::ProfilePolicyConnectorFactory::CreateForProfile( |
| 420 this, force_immediate_policy_load); | 417 this, force_immediate_policy_load); |
| 421 | 418 |
| 422 DCHECK(create_mode == CREATE_MODE_ASYNCHRONOUS || | 419 DCHECK(create_mode == CREATE_MODE_ASYNCHRONOUS || |
| 423 create_mode == CREATE_MODE_SYNCHRONOUS); | 420 create_mode == CREATE_MODE_SYNCHRONOUS); |
| 424 bool async_prefs = create_mode == CREATE_MODE_ASYNCHRONOUS; | 421 bool async_prefs = create_mode == CREATE_MODE_ASYNCHRONOUS; |
| 425 | 422 |
| 426 #if defined(OS_CHROMEOS) | 423 #if defined(OS_CHROMEOS) |
| 427 is_login_profile_ = chromeos::ProfileHelper::IsSigninProfile(this); | 424 if (chromeos::ProfileHelper::IsSigninProfile(this)) |
| 428 if (is_login_profile_) | |
| 429 chrome::RegisterLoginProfilePrefs(pref_registry_.get()); | 425 chrome::RegisterLoginProfilePrefs(pref_registry_.get()); |
| 430 else | 426 else |
| 431 #endif | 427 #endif |
| 432 chrome::RegisterUserProfilePrefs(pref_registry_.get()); | 428 chrome::RegisterUserProfilePrefs(pref_registry_.get()); |
| 433 | 429 |
| 434 ManagedUserSettingsService* managed_user_settings = NULL; | 430 ManagedUserSettingsService* managed_user_settings = NULL; |
| 435 #if defined(ENABLE_MANAGED_USERS) | 431 #if defined(ENABLE_MANAGED_USERS) |
| 436 managed_user_settings = | 432 managed_user_settings = |
| 437 ManagedUserSettingsServiceFactory::GetForProfile(this); | 433 ManagedUserSettingsServiceFactory::GetForProfile(this); |
| 438 managed_user_settings->Init( | 434 managed_user_settings->Init( |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 } | 804 } |
| 809 | 805 |
| 810 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { | 806 bool ProfileImpl::WasCreatedByVersionOrLater(const std::string& version) { |
| 811 Version profile_version(ChromeVersionService::GetVersion(prefs_.get())); | 807 Version profile_version(ChromeVersionService::GetVersion(prefs_.get())); |
| 812 Version arg_version(version); | 808 Version arg_version(version); |
| 813 return (profile_version.CompareTo(arg_version) >= 0); | 809 return (profile_version.CompareTo(arg_version) >= 0); |
| 814 } | 810 } |
| 815 | 811 |
| 816 void ProfileImpl::SetExitType(ExitType exit_type) { | 812 void ProfileImpl::SetExitType(ExitType exit_type) { |
| 817 #if defined(OS_CHROMEOS) | 813 #if defined(OS_CHROMEOS) |
| 818 if (is_login_profile_) | 814 if (chromeos::ProfileHelper::IsSigninProfile(this)) |
| 819 return; | 815 return; |
| 820 #endif | 816 #endif |
| 821 if (!prefs_) | 817 if (!prefs_) |
| 822 return; | 818 return; |
| 823 ExitType current_exit_type = SessionTypePrefValueToExitType( | 819 ExitType current_exit_type = SessionTypePrefValueToExitType( |
| 824 prefs_->GetString(prefs::kSessionExitType)); | 820 prefs_->GetString(prefs::kSessionExitType)); |
| 825 // This may be invoked multiple times during shutdown. Only persist the value | 821 // This may be invoked multiple times during shutdown. Only persist the value |
| 826 // first passed in (unless it's a reset to the crash state, which happens when | 822 // first passed in (unless it's a reset to the crash state, which happens when |
| 827 // foregrounding the app on mobile). | 823 // foregrounding the app on mobile). |
| 828 if (exit_type == EXIT_CRASHED || current_exit_type == EXIT_CRASHED) { | 824 if (exit_type == EXIT_CRASHED || current_exit_type == EXIT_CRASHED) { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 } | 1119 } |
| 1124 | 1120 |
| 1125 void ProfileImpl::InitChromeOSPreferences() { | 1121 void ProfileImpl::InitChromeOSPreferences() { |
| 1126 chromeos_preferences_.reset(new chromeos::Preferences()); | 1122 chromeos_preferences_.reset(new chromeos::Preferences()); |
| 1127 bool is_primary_user = chromeos::UserManager::Get()->GetPrimaryUser() == | 1123 bool is_primary_user = chromeos::UserManager::Get()->GetPrimaryUser() == |
| 1128 chromeos::UserManager::Get()->GetUserByProfile(this); | 1124 chromeos::UserManager::Get()->GetUserByProfile(this); |
| 1129 chromeos_preferences_->Init(PrefServiceSyncable::FromProfile(this), | 1125 chromeos_preferences_->Init(PrefServiceSyncable::FromProfile(this), |
| 1130 is_primary_user); | 1126 is_primary_user); |
| 1131 } | 1127 } |
| 1132 | 1128 |
| 1133 bool ProfileImpl::IsLoginProfile() { | |
| 1134 return is_login_profile_; | |
| 1135 } | |
| 1136 | |
| 1137 #endif // defined(OS_CHROMEOS) | 1129 #endif // defined(OS_CHROMEOS) |
| 1138 | 1130 |
| 1139 PrefProxyConfigTracker* ProfileImpl::GetProxyConfigTracker() { | 1131 PrefProxyConfigTracker* ProfileImpl::GetProxyConfigTracker() { |
| 1140 if (!pref_proxy_config_tracker_) | 1132 if (!pref_proxy_config_tracker_) |
| 1141 pref_proxy_config_tracker_.reset(CreateProxyConfigTracker()); | 1133 pref_proxy_config_tracker_.reset(CreateProxyConfigTracker()); |
| 1142 return pref_proxy_config_tracker_.get(); | 1134 return pref_proxy_config_tracker_.get(); |
| 1143 } | 1135 } |
| 1144 | 1136 |
| 1145 chrome_browser_net::Predictor* ProfileImpl::GetNetworkPredictor() { | 1137 chrome_browser_net::Predictor* ProfileImpl::GetNetworkPredictor() { |
| 1146 return predictor_; | 1138 return predictor_; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { | 1233 PrefProxyConfigTracker* ProfileImpl::CreateProxyConfigTracker() { |
| 1242 #if defined(OS_CHROMEOS) | 1234 #if defined(OS_CHROMEOS) |
| 1243 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 1235 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
| 1244 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 1236 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
| 1245 g_browser_process->local_state()); | 1237 g_browser_process->local_state()); |
| 1246 } | 1238 } |
| 1247 #endif // defined(OS_CHROMEOS) | 1239 #endif // defined(OS_CHROMEOS) |
| 1248 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 1240 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
| 1249 GetPrefs(), g_browser_process->local_state()); | 1241 GetPrefs(), g_browser_process->local_state()); |
| 1250 } | 1242 } |
| OLD | NEW |