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

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

Issue 23868042: Mark supervised profiles as such immediately when they're created. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 7 years, 2 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
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | chrome/test/base/testing_profile_manager.cc » ('j') | 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.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 29 matching lines...) Expand all
40 #include "chrome/browser/net/pref_proxy_config_tracker.h" 40 #include "chrome/browser/net/pref_proxy_config_tracker.h"
41 #include "chrome/browser/net/proxy_service_factory.h" 41 #include "chrome/browser/net/proxy_service_factory.h"
42 #include "chrome/browser/notifications/desktop_notification_service.h" 42 #include "chrome/browser/notifications/desktop_notification_service.h"
43 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 43 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
44 #include "chrome/browser/policy/profile_policy_connector.h" 44 #include "chrome/browser/policy/profile_policy_connector.h"
45 #include "chrome/browser/policy/profile_policy_connector_factory.h" 45 #include "chrome/browser/policy/profile_policy_connector_factory.h"
46 #include "chrome/browser/prefs/browser_prefs.h" 46 #include "chrome/browser/prefs/browser_prefs.h"
47 #include "chrome/browser/prefs/pref_service_syncable.h" 47 #include "chrome/browser/prefs/pref_service_syncable.h"
48 #include "chrome/browser/prerender/prerender_manager.h" 48 #include "chrome/browser/prerender/prerender_manager.h"
49 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" 49 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h"
50 #include "chrome/browser/profiles/profile_manager.h"
50 #include "chrome/browser/profiles/storage_partition_descriptor.h" 51 #include "chrome/browser/profiles/storage_partition_descriptor.h"
51 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" 52 #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
52 #include "chrome/browser/webdata/web_data_service.h" 53 #include "chrome/browser/webdata/web_data_service.h"
53 #include "chrome/browser/webdata/web_data_service_factory.h" 54 #include "chrome/browser/webdata/web_data_service_factory.h"
54 #include "chrome/common/chrome_constants.h" 55 #include "chrome/common/chrome_constants.h"
55 #include "chrome/common/chrome_switches.h" 56 #include "chrome/common/chrome_switches.h"
56 #include "chrome/common/pref_names.h" 57 #include "chrome/common/pref_names.h"
57 #include "chrome/common/url_constants.h" 58 #include "chrome/common/url_constants.h"
58 #include "chrome/test/base/history_index_restore_observer.h" 59 #include "chrome/test/base/history_index_restore_observer.h"
59 #include "chrome/test/base/testing_pref_service_syncable.h" 60 #include "chrome/test/base/testing_pref_service_syncable.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 FinishInit(); 224 FinishInit();
224 } 225 }
225 } 226 }
226 227
227 TestingProfile::TestingProfile( 228 TestingProfile::TestingProfile(
228 const base::FilePath& path, 229 const base::FilePath& path,
229 Delegate* delegate, 230 Delegate* delegate,
230 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, 231 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy,
231 scoped_ptr<PrefServiceSyncable> prefs, 232 scoped_ptr<PrefServiceSyncable> prefs,
232 bool incognito, 233 bool incognito,
234 const std::string& managed_user_id,
233 const TestingFactories& factories) 235 const TestingFactories& factories)
234 : start_time_(Time::Now()), 236 : start_time_(Time::Now()),
235 prefs_(prefs.release()), 237 prefs_(prefs.release()),
236 testing_prefs_(NULL), 238 testing_prefs_(NULL),
237 incognito_(incognito), 239 incognito_(incognito),
238 force_incognito_(false), 240 force_incognito_(false),
239 original_profile_(NULL), 241 original_profile_(NULL),
242 managed_user_id_(managed_user_id),
240 last_session_exited_cleanly_(true), 243 last_session_exited_cleanly_(true),
241 extension_special_storage_policy_(extension_policy), 244 extension_special_storage_policy_(extension_policy),
242 profile_path_(path), 245 profile_path_(path),
243 browser_context_dependency_manager_( 246 browser_context_dependency_manager_(
244 BrowserContextDependencyManager::GetInstance()), 247 BrowserContextDependencyManager::GetInstance()),
245 resource_context_(NULL), 248 resource_context_(NULL),
246 delegate_(delegate) { 249 delegate_(delegate) {
247 250
248 // If no profile path was supplied, create one. 251 // If no profile path was supplied, create one.
249 if (profile_path_.empty()) { 252 if (profile_path_.empty()) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 profile_name_ = "testing_profile"; 351 profile_name_ = "testing_profile";
349 } 352 }
350 353
351 void TestingProfile::FinishInit() { 354 void TestingProfile::FinishInit() {
352 DCHECK(content::NotificationService::current()); 355 DCHECK(content::NotificationService::current());
353 content::NotificationService::current()->Notify( 356 content::NotificationService::current()->Notify(
354 chrome::NOTIFICATION_PROFILE_CREATED, 357 chrome::NOTIFICATION_PROFILE_CREATED,
355 content::Source<Profile>(static_cast<Profile*>(this)), 358 content::Source<Profile>(static_cast<Profile*>(this)),
356 content::NotificationService::NoDetails()); 359 content::NotificationService::NoDetails());
357 360
361 ProfileManager* profile_manager = g_browser_process->profile_manager();
362 if (profile_manager)
363 profile_manager->InitProfileUserPrefs(this);
364
358 if (delegate_) 365 if (delegate_)
359 delegate_->OnProfileCreated(this, true, false); 366 delegate_->OnProfileCreated(this, true, false);
360 } 367 }
361 368
362 TestingProfile::~TestingProfile() { 369 TestingProfile::~TestingProfile() {
363 // Revert to non-incognito mode before shutdown. 370 // Revert to non-incognito mode before shutdown.
364 force_incognito_ = false; 371 force_incognito_ = false;
365 372
366 // Any objects holding live URLFetchers should be deleted before teardown. 373 // Any objects holding live URLFetchers should be deleted before teardown.
367 TemplateURLFetcherFactory::ShutdownForProfile(this); 374 TemplateURLFetcherFactory::ShutdownForProfile(this);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 return incognito_profile_.get() != NULL; 586 return incognito_profile_.get() != NULL;
580 } 587 }
581 588
582 Profile* TestingProfile::GetOriginalProfile() { 589 Profile* TestingProfile::GetOriginalProfile() {
583 if (original_profile_) 590 if (original_profile_)
584 return original_profile_; 591 return original_profile_;
585 return this; 592 return this;
586 } 593 }
587 594
588 bool TestingProfile::IsManaged() { 595 bool TestingProfile::IsManaged() {
589 return !GetPrefs()->GetString(prefs::kManagedUserId).empty(); 596 return !managed_user_id_.empty();
590 } 597 }
591 598
592 ExtensionService* TestingProfile::GetExtensionService() { 599 ExtensionService* TestingProfile::GetExtensionService() {
593 return extensions::ExtensionSystem::Get(this)->extension_service(); 600 return extensions::ExtensionSystem::Get(this)->extension_service();
594 } 601 }
595 602
596 void TestingProfile::SetExtensionSpecialStoragePolicy( 603 void TestingProfile::SetExtensionSpecialStoragePolicy(
597 ExtensionSpecialStoragePolicy* extension_special_storage_policy) { 604 ExtensionSpecialStoragePolicy* extension_special_storage_policy) {
598 extension_special_storage_policy_ = extension_special_storage_policy; 605 extension_special_storage_policy_ = extension_special_storage_policy;
599 } 606 }
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 866
860 void TestingProfile::Builder::SetPrefService( 867 void TestingProfile::Builder::SetPrefService(
861 scoped_ptr<PrefServiceSyncable> prefs) { 868 scoped_ptr<PrefServiceSyncable> prefs) {
862 pref_service_ = prefs.Pass(); 869 pref_service_ = prefs.Pass();
863 } 870 }
864 871
865 void TestingProfile::Builder::SetIncognito() { 872 void TestingProfile::Builder::SetIncognito() {
866 incognito_ = true; 873 incognito_ = true;
867 } 874 }
868 875
876 void TestingProfile::Builder::SetManagedUserId(
877 const std::string& managed_user_id) {
878 managed_user_id_ = managed_user_id;
879 }
880
869 void TestingProfile::Builder::AddTestingFactory( 881 void TestingProfile::Builder::AddTestingFactory(
870 BrowserContextKeyedServiceFactory* service_factory, 882 BrowserContextKeyedServiceFactory* service_factory,
871 BrowserContextKeyedServiceFactory::FactoryFunction callback) { 883 BrowserContextKeyedServiceFactory::FactoryFunction callback) {
872 testing_factories_.push_back(std::make_pair(service_factory, callback)); 884 testing_factories_.push_back(std::make_pair(service_factory, callback));
873 } 885 }
874 886
875 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { 887 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() {
876 DCHECK(!build_called_); 888 DCHECK(!build_called_);
877 build_called_ = true; 889 build_called_ = true;
890
878 return scoped_ptr<TestingProfile>(new TestingProfile( 891 return scoped_ptr<TestingProfile>(new TestingProfile(
879 path_, 892 path_,
880 delegate_, 893 delegate_,
881 extension_policy_, 894 extension_policy_,
882 pref_service_.Pass(), 895 pref_service_.Pass(),
883 incognito_, 896 incognito_,
897 managed_user_id_,
884 testing_factories_)); 898 testing_factories_));
885 } 899 }
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | chrome/test/base/testing_profile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698