| 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 "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 9 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 10 #include "chrome/browser/prefs/pref_service_syncable.h" | 10 #include "chrome/browser/prefs/pref_service_syncable.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 const string16& user_name, | 50 const string16& user_name, |
| 51 int avatar_id, | 51 int avatar_id, |
| 52 const std::string& managed_user_id) { | 52 const std::string& managed_user_id) { |
| 53 DCHECK(called_set_up_); | 53 DCHECK(called_set_up_); |
| 54 | 54 |
| 55 // Create a path for the profile based on the name. | 55 // Create a path for the profile based on the name. |
| 56 base::FilePath profile_path(profiles_dir_.path()); | 56 base::FilePath profile_path(profiles_dir_.path()); |
| 57 profile_path = profile_path.AppendASCII(profile_name); | 57 profile_path = profile_path.AppendASCII(profile_name); |
| 58 | 58 |
| 59 // Create the profile and register it. | 59 // Create the profile and register it. |
| 60 TestingProfile* profile = new TestingProfile( | 60 TestingProfile::Builder builder; |
| 61 profile_path, | 61 builder.SetPath(profile_path); |
| 62 NULL, | 62 builder.SetPrefService(prefs.Pass()); |
| 63 scoped_refptr<ExtensionSpecialStoragePolicy>(), | 63 TestingProfile* profile = builder.Build().release(); |
| 64 prefs.Pass()); | |
| 65 profile_manager_->AddProfile(profile); // Takes ownership. | 64 profile_manager_->AddProfile(profile); // Takes ownership. |
| 66 | 65 |
| 67 // Update the user metadata. | 66 // Update the user metadata. |
| 68 ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); | 67 ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); |
| 69 size_t index = cache.GetIndexOfProfileWithPath(profile_path); | 68 size_t index = cache.GetIndexOfProfileWithPath(profile_path); |
| 70 cache.SetAvatarIconOfProfileAtIndex(index, avatar_id); | 69 cache.SetAvatarIconOfProfileAtIndex(index, avatar_id); |
| 71 cache.SetManagedUserIdOfProfileAtIndex(index, managed_user_id); | 70 cache.SetManagedUserIdOfProfileAtIndex(index, managed_user_id); |
| 72 // SetNameOfProfileAtIndex may reshuffle the list of profiles, so we do it | 71 // SetNameOfProfileAtIndex may reshuffle the list of profiles, so we do it |
| 73 // last. | 72 // last. |
| 74 cache.SetNameOfProfileAtIndex(index, user_name); | 73 cache.SetNameOfProfileAtIndex(index, user_name); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 << "ProfileManager already exists"; | 126 << "ProfileManager already exists"; |
| 128 | 127 |
| 129 // Set up the directory for profiles. | 128 // Set up the directory for profiles. |
| 130 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); | 129 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); |
| 131 | 130 |
| 132 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); | 131 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); |
| 133 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. | 132 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. |
| 134 | 133 |
| 135 called_set_up_ = true; | 134 called_set_up_ = true; |
| 136 } | 135 } |
| OLD | NEW |