| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 const std::string& name) { | 94 const std::string& name) { |
| 95 DCHECK(called_set_up_); | 95 DCHECK(called_set_up_); |
| 96 return CreateTestingProfile(name, scoped_ptr<PrefServiceSyncable>(), | 96 return CreateTestingProfile(name, scoped_ptr<PrefServiceSyncable>(), |
| 97 base::UTF8ToUTF16(name), 0, std::string(), | 97 base::UTF8ToUTF16(name), 0, std::string(), |
| 98 TestingProfile::TestingFactories()); | 98 TestingProfile::TestingFactories()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 TestingProfile* TestingProfileManager::CreateGuestProfile() { | 101 TestingProfile* TestingProfileManager::CreateGuestProfile() { |
| 102 DCHECK(called_set_up_); | 102 DCHECK(called_set_up_); |
| 103 | 103 |
| 104 // Set up a profile with an off the record profile. |
| 105 TestingProfile::Builder otr_builder; |
| 106 otr_builder.SetIncognito(); |
| 107 scoped_ptr<TestingProfile> otr_profile(otr_builder.Build()); |
| 108 |
| 104 // Create the profile and register it. | 109 // Create the profile and register it. |
| 105 TestingProfile::Builder builder; | 110 TestingProfile::Builder builder; |
| 106 builder.SetGuestSession(); | 111 builder.SetGuestSession(); |
| 107 builder.SetPath(ProfileManager::GetGuestProfilePath()); | 112 builder.SetPath(ProfileManager::GetGuestProfilePath()); |
| 108 | 113 |
| 109 // Add the guest profile to the profile manager, but not to the info cache. | 114 // Add the guest profile to the profile manager, but not to the info cache. |
| 110 TestingProfile* profile = builder.Build().release(); | 115 TestingProfile* profile = builder.Build().release(); |
| 111 profile->set_profile_name(kGuestProfileName); | 116 profile->set_profile_name(kGuestProfileName); |
| 117 |
| 118 otr_profile->SetOriginalProfile(profile); |
| 119 profile->SetOffTheRecordProfile(otr_profile.PassAs<Profile>()); |
| 112 profile_manager_->AddProfile(profile); // Takes ownership. | 120 profile_manager_->AddProfile(profile); // Takes ownership. |
| 113 profile_manager_->SetGuestProfilePrefs(profile); | 121 profile_manager_->SetGuestProfilePrefs(profile); |
| 114 | 122 |
| 115 testing_profiles_.insert(std::make_pair(kGuestProfileName, profile)); | 123 testing_profiles_.insert(std::make_pair(kGuestProfileName, profile)); |
| 116 | 124 |
| 117 return profile; | 125 return profile; |
| 118 } | 126 } |
| 119 | 127 |
| 120 void TestingProfileManager::DeleteTestingProfile(const std::string& name) { | 128 void TestingProfileManager::DeleteTestingProfile(const std::string& name) { |
| 121 DCHECK(called_set_up_); | 129 DCHECK(called_set_up_); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 << "ProfileManager already exists"; | 176 << "ProfileManager already exists"; |
| 169 | 177 |
| 170 // Set up the directory for profiles. | 178 // Set up the directory for profiles. |
| 171 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); | 179 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); |
| 172 | 180 |
| 173 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); | 181 profile_manager_ = new testing::ProfileManager(profiles_dir_.path()); |
| 174 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. | 182 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. |
| 175 | 183 |
| 176 called_set_up_ = true; | 184 called_set_up_ = true; |
| 177 } | 185 } |
| OLD | NEW |