| 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/test/base/testing_profile_manager.h" | 5 #include "chrome/test/base/testing_profile_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 TestingProfile* TestingProfileManager::CreateTestingProfile( | 61 TestingProfile* TestingProfileManager::CreateTestingProfile( |
| 62 const std::string& profile_name, | 62 const std::string& profile_name, |
| 63 std::unique_ptr<syncable_prefs::PrefServiceSyncable> prefs, | 63 std::unique_ptr<syncable_prefs::PrefServiceSyncable> prefs, |
| 64 const base::string16& user_name, | 64 const base::string16& user_name, |
| 65 int avatar_id, | 65 int avatar_id, |
| 66 const std::string& supervised_user_id, | 66 const std::string& supervised_user_id, |
| 67 const TestingProfile::TestingFactories& factories) { | 67 const TestingProfile::TestingFactories& factories) { |
| 68 DCHECK(called_set_up_); | 68 DCHECK(called_set_up_); |
| 69 | 69 |
| 70 // Create a path for the profile based on the name. | 70 // Create a path for the profile based on the name. |
| 71 base::FilePath profile_path(profiles_dir_.path()); | 71 base::FilePath profile_path(profiles_dir_.GetPath()); |
| 72 #if defined(OS_CHROMEOS) | 72 #if defined(OS_CHROMEOS) |
| 73 if (profile_name != chrome::kInitialProfile) { | 73 if (profile_name != chrome::kInitialProfile) { |
| 74 profile_path = | 74 profile_path = |
| 75 profile_path.Append(chromeos::ProfileHelper::Get()->GetUserProfileDir( | 75 profile_path.Append(chromeos::ProfileHelper::Get()->GetUserProfileDir( |
| 76 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting( | 76 chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting( |
| 77 profile_name))); | 77 profile_name))); |
| 78 } else { | 78 } else { |
| 79 profile_path = profile_path.AppendASCII(profile_name); | 79 profile_path = profile_path.AppendASCII(profile_name); |
| 80 } | 80 } |
| 81 #else | 81 #else |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 } | 216 } |
| 217 | 217 |
| 218 void TestingProfileManager::UpdateLastUser(Profile* last_active) { | 218 void TestingProfileManager::UpdateLastUser(Profile* last_active) { |
| 219 #if !defined(OS_ANDROID) | 219 #if !defined(OS_ANDROID) |
| 220 profile_manager_->UpdateLastUser(last_active); | 220 profile_manager_->UpdateLastUser(last_active); |
| 221 #endif | 221 #endif |
| 222 } | 222 } |
| 223 | 223 |
| 224 const base::FilePath& TestingProfileManager::profiles_dir() { | 224 const base::FilePath& TestingProfileManager::profiles_dir() { |
| 225 DCHECK(called_set_up_); | 225 DCHECK(called_set_up_); |
| 226 return profiles_dir_.path(); | 226 return profiles_dir_.GetPath(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 ProfileManager* TestingProfileManager::profile_manager() { | 229 ProfileManager* TestingProfileManager::profile_manager() { |
| 230 DCHECK(called_set_up_); | 230 DCHECK(called_set_up_); |
| 231 return profile_manager_; | 231 return profile_manager_; |
| 232 } | 232 } |
| 233 | 233 |
| 234 ProfileInfoCache* TestingProfileManager::profile_info_cache() { | 234 ProfileInfoCache* TestingProfileManager::profile_info_cache() { |
| 235 DCHECK(called_set_up_); | 235 DCHECK(called_set_up_); |
| 236 return &profile_manager_->GetProfileInfoCache(); | 236 return &profile_manager_->GetProfileInfoCache(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 ProfileAttributesStorage* TestingProfileManager::profile_attributes_storage() { | 239 ProfileAttributesStorage* TestingProfileManager::profile_attributes_storage() { |
| 240 return profile_info_cache(); | 240 return profile_info_cache(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 void TestingProfileManager::SetUpInternal() { | 243 void TestingProfileManager::SetUpInternal() { |
| 244 ASSERT_FALSE(browser_process_->profile_manager()) | 244 ASSERT_FALSE(browser_process_->profile_manager()) |
| 245 << "ProfileManager already exists"; | 245 << "ProfileManager already exists"; |
| 246 | 246 |
| 247 // Set up the directory for profiles. | 247 // Set up the directory for profiles. |
| 248 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); | 248 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); |
| 249 | 249 |
| 250 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); | 250 profile_manager_ = new testing::ProfileManager(profiles_dir_.GetPath()); |
| 251 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. | 251 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. |
| 252 | 252 |
| 253 profile_manager_->GetProfileInfoCache(). | 253 profile_manager_->GetProfileInfoCache(). |
| 254 set_disable_avatar_download_for_testing(true); | 254 set_disable_avatar_download_for_testing(true); |
| 255 called_set_up_ = true; | 255 called_set_up_ = true; |
| 256 } | 256 } |
| OLD | NEW |