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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 } | 80 } |
81 #else | 81 #else |
82 profile_path = profile_path.AppendASCII(profile_name); | 82 profile_path = profile_path.AppendASCII(profile_name); |
83 #endif | 83 #endif |
84 | 84 |
85 // Create the profile and register it. | 85 // Create the profile and register it. |
86 TestingProfile::Builder builder; | 86 TestingProfile::Builder builder; |
87 builder.SetPath(profile_path); | 87 builder.SetPath(profile_path); |
88 builder.SetPrefService(std::move(prefs)); | 88 builder.SetPrefService(std::move(prefs)); |
89 builder.SetSupervisedUserId(supervised_user_id); | 89 builder.SetSupervisedUserId(supervised_user_id); |
| 90 builder.SetProfileName(profile_name); |
90 | 91 |
91 for (TestingProfile::TestingFactories::const_iterator it = factories.begin(); | 92 for (TestingProfile::TestingFactories::const_iterator it = factories.begin(); |
92 it != factories.end(); ++it) { | 93 it != factories.end(); ++it) { |
93 builder.AddTestingFactory(it->first, it->second); | 94 builder.AddTestingFactory(it->first, it->second); |
94 } | 95 } |
95 | 96 |
96 TestingProfile* profile = builder.Build().release(); | 97 TestingProfile* profile = builder.Build().release(); |
97 profile->set_profile_name(profile_name); | |
98 profile_manager_->AddProfile(profile); // Takes ownership. | 98 profile_manager_->AddProfile(profile); // Takes ownership. |
99 | 99 |
100 // Update the user metadata. | 100 // Update the user metadata. |
101 ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); | 101 ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); |
102 size_t index = cache.GetIndexOfProfileWithPath(profile_path); | 102 size_t index = cache.GetIndexOfProfileWithPath(profile_path); |
103 cache.SetAvatarIconOfProfileAtIndex(index, avatar_id); | 103 cache.SetAvatarIconOfProfileAtIndex(index, avatar_id); |
104 cache.SetSupervisedUserIdOfProfileAtIndex(index, supervised_user_id); | 104 cache.SetSupervisedUserIdOfProfileAtIndex(index, supervised_user_id); |
105 // SetNameOfProfileAtIndex may reshuffle the list of profiles, so we do it | 105 // SetNameOfProfileAtIndex may reshuffle the list of profiles, so we do it |
106 // last. | 106 // last. |
107 cache.SetNameOfProfileAtIndex(index, user_name); | 107 cache.SetNameOfProfileAtIndex(index, user_name); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_.path()); |
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 |