Chromium Code Reviews| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 17 #include "base/environment.h" | 17 #include "base/environment.h" |
| 18 #include "base/files/file_path.h" | 18 #include "base/files/file_path.h" |
| 19 #include "base/files/file_util.h" | 19 #include "base/files/file_util.h" |
| 20 #include "base/logging.h" | |
| 20 #include "base/memory/ptr_util.h" | 21 #include "base/memory/ptr_util.h" |
| 21 #include "base/memory/weak_ptr.h" | 22 #include "base/memory/weak_ptr.h" |
| 22 #include "base/metrics/histogram_macros.h" | 23 #include "base/metrics/histogram_macros.h" |
| 23 #include "base/path_service.h" | 24 #include "base/path_service.h" |
| 24 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
| 25 #include "base/strings/string_util.h" | 26 #include "base/strings/string_util.h" |
| 26 #include "base/strings/stringprintf.h" | 27 #include "base/strings/stringprintf.h" |
| 27 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
| 28 #include "base/synchronization/waitable_event.h" | 29 #include "base/synchronization/waitable_event.h" |
| 29 #include "base/threading/sequenced_worker_pool.h" | 30 #include "base/threading/sequenced_worker_pool.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 #include "services/identity/identity_service.h" | 125 #include "services/identity/identity_service.h" |
| 125 #include "services/identity/public/interfaces/constants.mojom.h" | 126 #include "services/identity/public/interfaces/constants.mojom.h" |
| 126 #include "services/preferences/public/cpp/pref_service_main.h" | 127 #include "services/preferences/public/cpp/pref_service_main.h" |
| 127 #include "services/preferences/public/interfaces/preferences.mojom.h" | 128 #include "services/preferences/public/interfaces/preferences.mojom.h" |
| 128 #include "services/preferences/public/interfaces/tracked_preference_validation_d elegate.mojom.h" | 129 #include "services/preferences/public/interfaces/tracked_preference_validation_d elegate.mojom.h" |
| 129 #include "services/service_manager/public/cpp/service.h" | 130 #include "services/service_manager/public/cpp/service.h" |
| 130 #include "ui/base/l10n/l10n_util.h" | 131 #include "ui/base/l10n/l10n_util.h" |
| 131 | 132 |
| 132 #if defined(OS_CHROMEOS) | 133 #if defined(OS_CHROMEOS) |
| 133 #include "chrome/browser/chromeos/locale_change_guard.h" | 134 #include "chrome/browser/chromeos/locale_change_guard.h" |
| 135 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | |
| 136 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | |
| 137 #include "chrome/browser/chromeos/policy/user_policy_manager_factory_chromeos.h" | |
| 134 #include "chrome/browser/chromeos/preferences.h" | 138 #include "chrome/browser/chromeos/preferences.h" |
| 135 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 139 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 136 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 140 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 141 #include "components/session_manager/core/session_manager.h" | |
| 142 #include "components/user_manager/user.h" | |
| 137 #include "components/user_manager/user_manager.h" | 143 #include "components/user_manager/user_manager.h" |
| 138 #endif | 144 #endif |
| 139 | 145 |
| 140 #if BUILDFLAG(ENABLE_BACKGROUND) | 146 #if BUILDFLAG(ENABLE_BACKGROUND) |
| 141 #include "chrome/browser/background/background_mode_manager.h" | 147 #include "chrome/browser/background/background_mode_manager.h" |
| 142 #endif | 148 #endif |
| 143 | 149 |
| 144 #if defined(OS_CHROMEOS) | 150 #if !defined(OS_CHROMEOS) |
| 145 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | |
| 146 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | |
| 147 #include "chrome/browser/chromeos/policy/user_policy_manager_factory_chromeos.h" | |
| 148 #else | |
| 149 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" | 151 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" |
| 150 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" | 152 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" |
| 151 #endif | 153 #endif |
| 152 | 154 |
| 153 #if BUILDFLAG(ENABLE_EXTENSIONS) | 155 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 154 #include "chrome/browser/extensions/extension_service.h" | 156 #include "chrome/browser/extensions/extension_service.h" |
| 155 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 157 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 156 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 158 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 157 #include "components/guest_view/browser/guest_view_manager.h" | 159 #include "components/guest_view/browser/guest_view_manager.h" |
| 158 #include "extensions/browser/extension_pref_store.h" | 160 #include "extensions/browser/extension_pref_store.h" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 417 pref_registry_(new user_prefs::PrefRegistrySyncable), | 419 pref_registry_(new user_prefs::PrefRegistrySyncable), |
| 418 io_data_(this), | 420 io_data_(this), |
| 419 last_session_exit_type_(EXIT_NORMAL), | 421 last_session_exit_type_(EXIT_NORMAL), |
| 420 start_time_(Time::Now()), | 422 start_time_(Time::Now()), |
| 421 delegate_(delegate), | 423 delegate_(delegate), |
| 422 predictor_(NULL) { | 424 predictor_(NULL) { |
| 423 TRACE_EVENT0("browser,startup", "ProfileImpl::ctor") | 425 TRACE_EVENT0("browser,startup", "ProfileImpl::ctor") |
| 424 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 426 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
| 425 "profile files to the root directory!"; | 427 "profile files to the root directory!"; |
| 426 | 428 |
| 429 #if defined(OS_CHROMEOS) | |
| 430 if (!chromeos::ProfileHelper::IsSigninProfile(this)) { | |
| 431 const user_manager::User* user = | |
| 432 chromeos::ProfileHelper::Get()->GetUserByProfile(this); | |
| 433 // A |User| instance should always exist for a profile which is not the | |
| 434 // initial or the sign-in profile. | |
| 435 CHECK(user); | |
| 436 CHECK(session_manager::SessionManager::Get()->HasSessionForAccountId( | |
|
xiyuan
2017/05/09 16:30:52
nit: CHECK -> LOG_IF(FATAL, ...)
CHECK crashes wi
emaxx
2017/05/09 17:11:46
Done.
| |
| 437 user->GetAccountId())) | |
| 438 << "Attempting to construct the profile before starting the user " | |
| 439 "session"; | |
| 440 } | |
| 441 #endif | |
| 442 | |
| 427 #if BUILDFLAG(ENABLE_SESSION_SERVICE) | 443 #if BUILDFLAG(ENABLE_SESSION_SERVICE) |
| 428 create_session_service_timer_.Start(FROM_HERE, | 444 create_session_service_timer_.Start(FROM_HERE, |
| 429 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, | 445 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
| 430 &ProfileImpl::EnsureSessionServiceCreated); | 446 &ProfileImpl::EnsureSessionServiceCreated); |
| 431 #endif | 447 #endif |
| 432 | 448 |
| 433 set_is_guest_profile(path == ProfileManager::GetGuestProfilePath()); | 449 set_is_guest_profile(path == ProfileManager::GetGuestProfilePath()); |
| 434 set_is_system_profile(path == ProfileManager::GetSystemProfilePath()); | 450 set_is_system_profile(path == ProfileManager::GetSystemProfilePath()); |
| 435 | 451 |
| 436 // If profile_manager is not present, it means we are in a unittest. | 452 // If profile_manager is not present, it means we are in a unittest. |
| (...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1361 return std::unique_ptr<domain_reliability::DomainReliabilityMonitor>(); | 1377 return std::unique_ptr<domain_reliability::DomainReliabilityMonitor>(); |
| 1362 | 1378 |
| 1363 return service->CreateMonitor( | 1379 return service->CreateMonitor( |
| 1364 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); | 1380 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); |
| 1365 } | 1381 } |
| 1366 | 1382 |
| 1367 std::unique_ptr<service_manager::Service> ProfileImpl::CreateIdentityService() { | 1383 std::unique_ptr<service_manager::Service> ProfileImpl::CreateIdentityService() { |
| 1368 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile(this); | 1384 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile(this); |
| 1369 return base::MakeUnique<identity::IdentityService>(signin_manager); | 1385 return base::MakeUnique<identity::IdentityService>(signin_manager); |
| 1370 } | 1386 } |
| OLD | NEW |