| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromeos/profiles/profile_helper.h" | 5 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 10 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 11 #include "chrome/browser/chromeos/login/oauth2_login_manager_factory.h" | 11 #include "chrome/browser/chromeos/login/oauth2_login_manager_factory.h" |
| 12 #include "chrome/browser/chromeos/login/user.h" | 12 #include "chrome/browser/chromeos/login/user.h" |
| 13 #include "chrome/browser/chromeos/login/user_manager.h" | 13 #include "chrome/browser/chromeos/login/user_manager.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/browser/profiles/profiles_state.h" |
| 16 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
| 17 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 18 #include "chromeos/chromeos_switches.h" | 19 #include "chromeos/chromeos_switches.h" |
| 19 | 20 |
| 20 namespace chromeos { | 21 namespace chromeos { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 bool ShouldAddProfileDirPrefix(const std::string& user_id_hash) { | 25 bool ShouldAddProfileDirPrefix(const std::string& user_id_hash) { |
| 25 // Do not add profile dir prefix for legacy profile dir and test | 26 // Do not add profile dir prefix for legacy profile dir and test |
| (...skipping 25 matching lines...) Expand all Loading... |
| 51 // static | 52 // static |
| 52 Profile* ProfileHelper::GetProfileByUserIdHash( | 53 Profile* ProfileHelper::GetProfileByUserIdHash( |
| 53 const std::string& user_id_hash) { | 54 const std::string& user_id_hash) { |
| 54 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 55 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 55 return profile_manager->GetProfile(GetProfilePathByUserIdHash(user_id_hash)); | 56 return profile_manager->GetProfile(GetProfilePathByUserIdHash(user_id_hash)); |
| 56 } | 57 } |
| 57 | 58 |
| 58 // static | 59 // static |
| 59 base::FilePath ProfileHelper::GetProfilePathByUserIdHash( | 60 base::FilePath ProfileHelper::GetProfilePathByUserIdHash( |
| 60 const std::string& user_id_hash) { | 61 const std::string& user_id_hash) { |
| 62 // Fails for KioskTest.InstallAndLaunchApp test - crbug.com/238985 |
| 63 // Will probably fail for Guest session / restart after a crash - |
| 64 // crbug.com/238998 |
| 65 // TODO(nkostylev): Remove this check once these bugs are fixed. |
| 66 DCHECK(!user_id_hash.empty()); |
| 61 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 67 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 62 base::FilePath profile_path = profile_manager->user_data_dir(); | 68 base::FilePath profile_path = profile_manager->user_data_dir(); |
| 63 | 69 |
| 64 return profile_path.Append(GetUserProfileDir(user_id_hash)); | 70 return profile_path.Append(GetUserProfileDir(user_id_hash)); |
| 65 } | 71 } |
| 66 | 72 |
| 67 // static | 73 // static |
| 68 base::FilePath ProfileHelper::GetProfileDirByLegacyLoginProfileSwitch() { | 74 base::FilePath ProfileHelper::GetProfileDirByLegacyLoginProfileSwitch() { |
| 69 const std::string login_profile_value = | 75 const std::string login_profile_value = |
| 70 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 76 CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 //////////////////////////////////////////////////////////////////////////////// | 218 //////////////////////////////////////////////////////////////////////////////// |
| 213 // ProfileHelper, UserManager::UserSessionStateObserver implementation: | 219 // ProfileHelper, UserManager::UserSessionStateObserver implementation: |
| 214 | 220 |
| 215 void ProfileHelper::ActiveUserHashChanged(const std::string& hash) { | 221 void ProfileHelper::ActiveUserHashChanged(const std::string& hash) { |
| 216 active_user_id_hash_ = hash; | 222 active_user_id_hash_ = hash; |
| 217 base::FilePath profile_path = GetProfilePathByUserIdHash(hash); | 223 base::FilePath profile_path = GetProfilePathByUserIdHash(hash); |
| 218 VLOG(1) << "Switching to profile path: " << profile_path.value(); | 224 VLOG(1) << "Switching to profile path: " << profile_path.value(); |
| 219 } | 225 } |
| 220 | 226 |
| 221 } // namespace chromeos | 227 } // namespace chromeos |
| OLD | NEW |