Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Side by Side Diff: chrome/test/base/testing_profile_manager.cc

Issue 556173002: Ensure incognito TestingProfiles are incognito for their whole lifetime. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: respond to comments Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/base/testing_profile.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698