| 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 const std::string& name) { | 111 const std::string& name) { |
| 112 DCHECK(called_set_up_); | 112 DCHECK(called_set_up_); |
| 113 return CreateTestingProfile(name, scoped_ptr<PrefServiceSyncable>(), | 113 return CreateTestingProfile(name, scoped_ptr<PrefServiceSyncable>(), |
| 114 base::UTF8ToUTF16(name), 0, std::string(), | 114 base::UTF8ToUTF16(name), 0, std::string(), |
| 115 TestingProfile::TestingFactories()); | 115 TestingProfile::TestingFactories()); |
| 116 } | 116 } |
| 117 | 117 |
| 118 TestingProfile* TestingProfileManager::CreateGuestProfile() { | 118 TestingProfile* TestingProfileManager::CreateGuestProfile() { |
| 119 DCHECK(called_set_up_); | 119 DCHECK(called_set_up_); |
| 120 | 120 |
| 121 // Set up a profile with an off the record profile. | |
| 122 TestingProfile::Builder otr_builder; | |
| 123 otr_builder.SetIncognito(); | |
| 124 scoped_ptr<TestingProfile> otr_profile(otr_builder.Build()); | |
| 125 | |
| 126 // Create the profile and register it. | 121 // Create the profile and register it. |
| 127 TestingProfile::Builder builder; | 122 TestingProfile::Builder builder; |
| 128 builder.SetGuestSession(); | 123 builder.SetGuestSession(); |
| 129 builder.SetPath(ProfileManager::GetGuestProfilePath()); | 124 builder.SetPath(ProfileManager::GetGuestProfilePath()); |
| 130 | 125 |
| 131 // Add the guest profile to the profile manager, but not to the info cache. | 126 // Add the guest profile to the profile manager, but not to the info cache. |
| 132 TestingProfile* profile = builder.Build().release(); | 127 TestingProfile* profile = builder.Build().release(); |
| 133 profile->set_profile_name(kGuestProfileName); | 128 profile->set_profile_name(kGuestProfileName); |
| 134 | 129 |
| 135 otr_profile->SetOriginalProfile(profile); | 130 // Set up a profile with an off the record profile. |
| 136 profile->SetOffTheRecordProfile(otr_profile.PassAs<Profile>()); | 131 TestingProfile::Builder().BuildIncognito(profile); |
| 132 |
| 137 profile_manager_->AddProfile(profile); // Takes ownership. | 133 profile_manager_->AddProfile(profile); // Takes ownership. |
| 138 profile_manager_->SetGuestProfilePrefs(profile); | 134 profile_manager_->SetGuestProfilePrefs(profile); |
| 139 | 135 |
| 140 testing_profiles_.insert(std::make_pair(kGuestProfileName, profile)); | 136 testing_profiles_.insert(std::make_pair(kGuestProfileName, profile)); |
| 141 | 137 |
| 142 return profile; | 138 return profile; |
| 143 } | 139 } |
| 144 | 140 |
| 145 void TestingProfileManager::DeleteTestingProfile(const std::string& name) { | 141 void TestingProfileManager::DeleteTestingProfile(const std::string& name) { |
| 146 DCHECK(called_set_up_); | 142 DCHECK(called_set_up_); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 << "ProfileManager already exists"; | 200 << "ProfileManager already exists"; |
| 205 | 201 |
| 206 // Set up the directory for profiles. | 202 // Set up the directory for profiles. |
| 207 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); | 203 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); |
| 208 | 204 |
| 209 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); | 205 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); |
| 210 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. | 206 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. |
| 211 | 207 |
| 212 called_set_up_ = true; | 208 called_set_up_ = true; |
| 213 } | 209 } |
| OLD | NEW |