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.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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 239 } |
240 } | 240 } |
241 | 241 |
242 TestingProfile::TestingProfile( | 242 TestingProfile::TestingProfile( |
243 const base::FilePath& path, | 243 const base::FilePath& path, |
244 Delegate* delegate, | 244 Delegate* delegate, |
245 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, | 245 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, |
246 scoped_ptr<PrefServiceSyncable> prefs, | 246 scoped_ptr<PrefServiceSyncable> prefs, |
247 bool incognito, | 247 bool incognito, |
248 bool guest_session, | 248 bool guest_session, |
249 const std::string& managed_user_id, | 249 const std::string& supervised_user_id, |
250 scoped_ptr<policy::PolicyService> policy_service, | 250 scoped_ptr<policy::PolicyService> policy_service, |
251 const TestingFactories& factories) | 251 const TestingFactories& factories) |
252 : start_time_(Time::Now()), | 252 : start_time_(Time::Now()), |
253 prefs_(prefs.release()), | 253 prefs_(prefs.release()), |
254 testing_prefs_(NULL), | 254 testing_prefs_(NULL), |
255 incognito_(incognito), | 255 incognito_(incognito), |
256 force_incognito_(false), | 256 force_incognito_(false), |
257 original_profile_(NULL), | 257 original_profile_(NULL), |
258 guest_session_(guest_session), | 258 guest_session_(guest_session), |
259 managed_user_id_(managed_user_id), | 259 supervised_user_id_(supervised_user_id), |
260 last_session_exited_cleanly_(true), | 260 last_session_exited_cleanly_(true), |
261 extension_special_storage_policy_(extension_policy), | 261 extension_special_storage_policy_(extension_policy), |
262 profile_path_(path), | 262 profile_path_(path), |
263 browser_context_dependency_manager_( | 263 browser_context_dependency_manager_( |
264 BrowserContextDependencyManager::GetInstance()), | 264 BrowserContextDependencyManager::GetInstance()), |
265 resource_context_(NULL), | 265 resource_context_(NULL), |
266 delegate_(delegate), | 266 delegate_(delegate), |
267 policy_service_(policy_service.release()) { | 267 policy_service_(policy_service.release()) { |
268 // If no profile path was supplied, create one. | 268 // If no profile path was supplied, create one. |
269 if (profile_path_.empty()) { | 269 if (profile_path_.empty()) { |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 bool TestingProfile::HasOffTheRecordProfile() { | 630 bool TestingProfile::HasOffTheRecordProfile() { |
631 return incognito_profile_.get() != NULL; | 631 return incognito_profile_.get() != NULL; |
632 } | 632 } |
633 | 633 |
634 Profile* TestingProfile::GetOriginalProfile() { | 634 Profile* TestingProfile::GetOriginalProfile() { |
635 if (original_profile_) | 635 if (original_profile_) |
636 return original_profile_; | 636 return original_profile_; |
637 return this; | 637 return this; |
638 } | 638 } |
639 | 639 |
640 bool TestingProfile::IsManaged() { | 640 bool TestingProfile::IsSupervised() { |
641 return !managed_user_id_.empty(); | 641 return !supervised_user_id_.empty(); |
642 } | 642 } |
643 | 643 |
644 ExtensionService* TestingProfile::GetExtensionService() { | 644 ExtensionService* TestingProfile::GetExtensionService() { |
645 return extensions::ExtensionSystem::Get(this)->extension_service(); | 645 return extensions::ExtensionSystem::Get(this)->extension_service(); |
646 } | 646 } |
647 | 647 |
648 void TestingProfile::SetExtensionSpecialStoragePolicy( | 648 void TestingProfile::SetExtensionSpecialStoragePolicy( |
649 ExtensionSpecialStoragePolicy* extension_special_storage_policy) { | 649 ExtensionSpecialStoragePolicy* extension_special_storage_policy) { |
650 extension_special_storage_policy_ = extension_special_storage_policy; | 650 extension_special_storage_policy_ = extension_special_storage_policy; |
651 } | 651 } |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 } | 952 } |
953 | 953 |
954 void TestingProfile::Builder::SetIncognito() { | 954 void TestingProfile::Builder::SetIncognito() { |
955 incognito_ = true; | 955 incognito_ = true; |
956 } | 956 } |
957 | 957 |
958 void TestingProfile::Builder::SetGuestSession() { | 958 void TestingProfile::Builder::SetGuestSession() { |
959 guest_session_ = true; | 959 guest_session_ = true; |
960 } | 960 } |
961 | 961 |
962 void TestingProfile::Builder::SetManagedUserId( | 962 void TestingProfile::Builder::SetSupervisedUserId( |
963 const std::string& managed_user_id) { | 963 const std::string& supervised_user_id) { |
964 managed_user_id_ = managed_user_id; | 964 supervised_user_id_ = supervised_user_id; |
965 } | 965 } |
966 | 966 |
967 void TestingProfile::Builder::SetPolicyService( | 967 void TestingProfile::Builder::SetPolicyService( |
968 scoped_ptr<policy::PolicyService> policy_service) { | 968 scoped_ptr<policy::PolicyService> policy_service) { |
969 policy_service_ = policy_service.Pass(); | 969 policy_service_ = policy_service.Pass(); |
970 } | 970 } |
971 | 971 |
972 void TestingProfile::Builder::AddTestingFactory( | 972 void TestingProfile::Builder::AddTestingFactory( |
973 BrowserContextKeyedServiceFactory* service_factory, | 973 BrowserContextKeyedServiceFactory* service_factory, |
974 BrowserContextKeyedServiceFactory::TestingFactoryFunction callback) { | 974 BrowserContextKeyedServiceFactory::TestingFactoryFunction callback) { |
975 testing_factories_.push_back(std::make_pair(service_factory, callback)); | 975 testing_factories_.push_back(std::make_pair(service_factory, callback)); |
976 } | 976 } |
977 | 977 |
978 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { | 978 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { |
979 DCHECK(!build_called_); | 979 DCHECK(!build_called_); |
980 build_called_ = true; | 980 build_called_ = true; |
981 | 981 |
982 return scoped_ptr<TestingProfile>(new TestingProfile( | 982 return scoped_ptr<TestingProfile>(new TestingProfile( |
983 path_, | 983 path_, |
984 delegate_, | 984 delegate_, |
985 extension_policy_, | 985 extension_policy_, |
986 pref_service_.Pass(), | 986 pref_service_.Pass(), |
987 incognito_, | 987 incognito_, |
988 guest_session_, | 988 guest_session_, |
989 managed_user_id_, | 989 supervised_user_id_, |
990 policy_service_.Pass(), | 990 policy_service_.Pass(), |
991 testing_factories_)); | 991 testing_factories_)); |
992 } | 992 } |
OLD | NEW |