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" |
11 #include "chrome/browser/profiles/profile_info_cache.h" | 11 #include "chrome/browser/profiles/profile_info_cache.h" |
12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 13 #include "chrome/common/chrome_constants.h" |
13 #include "chrome/test/base/testing_browser_process.h" | 14 #include "chrome/test/base/testing_browser_process.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
| 17 #if defined(OS_CHROMEOS) |
| 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 19 #endif |
| 20 |
16 const std::string kGuestProfileName = "Guest"; | 21 const std::string kGuestProfileName = "Guest"; |
17 | 22 |
18 namespace testing { | 23 namespace testing { |
19 | 24 |
20 class ProfileManager : public ::ProfileManagerWithoutInit { | 25 class ProfileManager : public ::ProfileManagerWithoutInit { |
21 public: | 26 public: |
22 explicit ProfileManager(const base::FilePath& user_data_dir) | 27 explicit ProfileManager(const base::FilePath& user_data_dir) |
23 : ::ProfileManagerWithoutInit(user_data_dir) {} | 28 : ::ProfileManagerWithoutInit(user_data_dir) {} |
24 | 29 |
25 protected: | 30 protected: |
(...skipping 26 matching lines...) Expand all Loading... |
52 const std::string& profile_name, | 57 const std::string& profile_name, |
53 scoped_ptr<PrefServiceSyncable> prefs, | 58 scoped_ptr<PrefServiceSyncable> prefs, |
54 const base::string16& user_name, | 59 const base::string16& user_name, |
55 int avatar_id, | 60 int avatar_id, |
56 const std::string& supervised_user_id, | 61 const std::string& supervised_user_id, |
57 const TestingProfile::TestingFactories& factories) { | 62 const TestingProfile::TestingFactories& factories) { |
58 DCHECK(called_set_up_); | 63 DCHECK(called_set_up_); |
59 | 64 |
60 // Create a path for the profile based on the name. | 65 // Create a path for the profile based on the name. |
61 base::FilePath profile_path(profiles_dir_.path()); | 66 base::FilePath profile_path(profiles_dir_.path()); |
| 67 #if defined(OS_CHROMEOS) |
| 68 if (profile_name != chrome::kInitialProfile) { |
| 69 profile_path = |
| 70 profile_path.Append(chromeos::ProfileHelper::Get()->GetUserProfileDir( |
| 71 chromeos::ProfileHelper::Get()->GetUserIdHashByUserIdForTests( |
| 72 profile_name))); |
| 73 } else { |
| 74 profile_path = profile_path.AppendASCII(profile_name); |
| 75 } |
| 76 #else |
62 profile_path = profile_path.AppendASCII(profile_name); | 77 profile_path = profile_path.AppendASCII(profile_name); |
| 78 #endif |
63 | 79 |
64 // Create the profile and register it. | 80 // Create the profile and register it. |
65 TestingProfile::Builder builder; | 81 TestingProfile::Builder builder; |
66 builder.SetPath(profile_path); | 82 builder.SetPath(profile_path); |
67 builder.SetPrefService(prefs.Pass()); | 83 builder.SetPrefService(prefs.Pass()); |
68 builder.SetSupervisedUserId(supervised_user_id); | 84 builder.SetSupervisedUserId(supervised_user_id); |
69 | 85 |
70 for (TestingProfile::TestingFactories::const_iterator it = factories.begin(); | 86 for (TestingProfile::TestingFactories::const_iterator it = factories.begin(); |
71 it != factories.end(); ++it) { | 87 it != factories.end(); ++it) { |
72 builder.AddTestingFactory(it->first, it->second); | 88 builder.AddTestingFactory(it->first, it->second); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 << "ProfileManager already exists"; | 203 << "ProfileManager already exists"; |
188 | 204 |
189 // Set up the directory for profiles. | 205 // Set up the directory for profiles. |
190 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); | 206 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); |
191 | 207 |
192 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); | 208 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); |
193 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. | 209 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. |
194 | 210 |
195 called_set_up_ = true; | 211 called_set_up_ = true; |
196 } | 212 } |
OLD | NEW |