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

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

Issue 12088040: Add a SigninAllowed policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT, another try to upload. Created 7 years, 10 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 | Annotate | Revision Log
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.h" 5 #include "chrome/test/base/testing_profile.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // ChromeBrowserMainPartsChromeos::PreEarlyInitialization. 154 // ChromeBrowserMainPartsChromeos::PreEarlyInitialization.
155 const char TestingProfile::kTestUserProfileDir[] = "test-user"; 155 const char TestingProfile::kTestUserProfileDir[] = "test-user";
156 #else 156 #else
157 const char TestingProfile::kTestUserProfileDir[] = "Default"; 157 const char TestingProfile::kTestUserProfileDir[] = "Default";
158 #endif 158 #endif
159 159
160 TestingProfile::TestingProfile() 160 TestingProfile::TestingProfile()
161 : start_time_(Time::Now()), 161 : start_time_(Time::Now()),
162 testing_prefs_(NULL), 162 testing_prefs_(NULL),
163 incognito_(false), 163 incognito_(false),
164 original_profile_(NULL),
164 last_session_exited_cleanly_(true), 165 last_session_exited_cleanly_(true),
165 profile_dependency_manager_(ProfileDependencyManager::GetInstance()), 166 profile_dependency_manager_(ProfileDependencyManager::GetInstance()),
166 delegate_(NULL) { 167 delegate_(NULL) {
167 CreateTempProfileDir(); 168 CreateTempProfileDir();
168 profile_path_ = temp_dir_.path(); 169 profile_path_ = temp_dir_.path();
169 170
170 Init(); 171 Init();
171 FinishInit(); 172 FinishInit();
172 } 173 }
173 174
174 TestingProfile::TestingProfile(const FilePath& path) 175 TestingProfile::TestingProfile(const FilePath& path)
175 : start_time_(Time::Now()), 176 : start_time_(Time::Now()),
176 testing_prefs_(NULL), 177 testing_prefs_(NULL),
177 incognito_(false), 178 incognito_(false),
179 original_profile_(NULL),
178 last_session_exited_cleanly_(true), 180 last_session_exited_cleanly_(true),
179 profile_path_(path), 181 profile_path_(path),
180 profile_dependency_manager_(ProfileDependencyManager::GetInstance()), 182 profile_dependency_manager_(ProfileDependencyManager::GetInstance()),
181 delegate_(NULL) { 183 delegate_(NULL) {
182 Init(); 184 Init();
183 FinishInit(); 185 FinishInit();
184 } 186 }
185 187
186 TestingProfile::TestingProfile(const FilePath& path, 188 TestingProfile::TestingProfile(const FilePath& path,
187 Delegate* delegate) 189 Delegate* delegate)
188 : start_time_(Time::Now()), 190 : start_time_(Time::Now()),
189 testing_prefs_(NULL), 191 testing_prefs_(NULL),
190 incognito_(false), 192 incognito_(false),
193 original_profile_(NULL),
191 last_session_exited_cleanly_(true), 194 last_session_exited_cleanly_(true),
192 profile_path_(path), 195 profile_path_(path),
193 profile_dependency_manager_(ProfileDependencyManager::GetInstance()), 196 profile_dependency_manager_(ProfileDependencyManager::GetInstance()),
194 delegate_(delegate) { 197 delegate_(delegate) {
195 Init(); 198 Init();
196 if (delegate_) { 199 if (delegate_) {
197 MessageLoop::current()->PostTask(FROM_HERE, 200 MessageLoop::current()->PostTask(FROM_HERE,
198 base::Bind(&TestingProfile::FinishInit, 201 base::Bind(&TestingProfile::FinishInit,
199 base::Unretained(this))); 202 base::Unretained(this)));
200 } else { 203 } else {
201 FinishInit(); 204 FinishInit();
202 } 205 }
203 } 206 }
204 207
205 TestingProfile::TestingProfile( 208 TestingProfile::TestingProfile(
206 const FilePath& path, 209 const FilePath& path,
207 Delegate* delegate, 210 Delegate* delegate,
208 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, 211 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy,
209 scoped_ptr<PrefServiceSyncable> prefs, 212 scoped_ptr<PrefServiceSyncable> prefs,
210 bool off_the_record) 213 bool off_the_record)
211 : start_time_(Time::Now()), 214 : start_time_(Time::Now()),
212 prefs_(prefs.release()), 215 prefs_(prefs.release()),
213 testing_prefs_(NULL), 216 testing_prefs_(NULL),
214 incognito_(off_the_record), 217 incognito_(off_the_record),
218 original_profile_(NULL),
215 last_session_exited_cleanly_(true), 219 last_session_exited_cleanly_(true),
216 extension_special_storage_policy_(extension_policy), 220 extension_special_storage_policy_(extension_policy),
217 profile_path_(path), 221 profile_path_(path),
218 profile_dependency_manager_(ProfileDependencyManager::GetInstance()), 222 profile_dependency_manager_(ProfileDependencyManager::GetInstance()),
219 delegate_(delegate) { 223 delegate_(delegate) {
220 224
221 // If no profile path was supplied, create one. 225 // If no profile path was supplied, create one.
222 if (profile_path_.empty()) { 226 if (profile_path_.empty()) {
223 CreateTempProfileDir(); 227 CreateTempProfileDir();
224 profile_path_ = temp_dir_.path(); 228 profile_path_ = temp_dir_.path();
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 } 495 }
492 496
493 bool TestingProfile::IsOffTheRecord() const { 497 bool TestingProfile::IsOffTheRecord() const {
494 return incognito_; 498 return incognito_;
495 } 499 }
496 500
497 void TestingProfile::SetOffTheRecordProfile(Profile* profile) { 501 void TestingProfile::SetOffTheRecordProfile(Profile* profile) {
498 incognito_profile_.reset(profile); 502 incognito_profile_.reset(profile);
499 } 503 }
500 504
505 void TestingProfile::SetOriginalProfile(Profile* profile) {
506 original_profile_ = profile;
507 }
508
501 Profile* TestingProfile::GetOffTheRecordProfile() { 509 Profile* TestingProfile::GetOffTheRecordProfile() {
502 return incognito_profile_.get(); 510 return incognito_profile_.get();
503 } 511 }
504 512
505 bool TestingProfile::HasOffTheRecordProfile() { 513 bool TestingProfile::HasOffTheRecordProfile() {
506 return incognito_profile_.get() != NULL; 514 return incognito_profile_.get() != NULL;
507 } 515 }
508 516
509 Profile* TestingProfile::GetOriginalProfile() { 517 Profile* TestingProfile::GetOriginalProfile() {
518 if (original_profile_)
519 return original_profile_;
510 return this; 520 return this;
511 } 521 }
512 522
513 ExtensionService* TestingProfile::GetExtensionService() { 523 ExtensionService* TestingProfile::GetExtensionService() {
514 return extensions::ExtensionSystem::Get(this)->extension_service(); 524 return extensions::ExtensionSystem::Get(this)->extension_service();
515 } 525 }
516 526
517 void TestingProfile::SetExtensionSpecialStoragePolicy( 527 void TestingProfile::SetExtensionSpecialStoragePolicy(
518 ExtensionSpecialStoragePolicy* extension_special_storage_policy) { 528 ExtensionSpecialStoragePolicy* extension_special_storage_policy) {
519 extension_special_storage_policy_ = extension_special_storage_policy; 529 extension_special_storage_policy_ = extension_special_storage_policy;
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { 804 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() {
795 DCHECK(!build_called_); 805 DCHECK(!build_called_);
796 build_called_ = true; 806 build_called_ = true;
797 return scoped_ptr<TestingProfile>(new TestingProfile( 807 return scoped_ptr<TestingProfile>(new TestingProfile(
798 path_, 808 path_,
799 delegate_, 809 delegate_,
800 extension_policy_, 810 extension_policy_,
801 pref_service_.Pass(), 811 pref_service_.Pass(),
802 off_the_record_)); 812 off_the_record_));
803 } 813 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698