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 19 matching lines...) Expand all Loading... |
30 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_facto
ry.h" | 30 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_facto
ry.h" |
31 #include "chrome/browser/history/history.h" | 31 #include "chrome/browser/history/history.h" |
32 #include "chrome/browser/history/history_backend.h" | 32 #include "chrome/browser/history/history_backend.h" |
33 #include "chrome/browser/history/history_service_factory.h" | 33 #include "chrome/browser/history/history_service_factory.h" |
34 #include "chrome/browser/history/shortcuts_backend.h" | 34 #include "chrome/browser/history/shortcuts_backend.h" |
35 #include "chrome/browser/history/shortcuts_backend_factory.h" | 35 #include "chrome/browser/history/shortcuts_backend_factory.h" |
36 #include "chrome/browser/history/top_sites.h" | 36 #include "chrome/browser/history/top_sites.h" |
37 #include "chrome/browser/net/proxy_service_factory.h" | 37 #include "chrome/browser/net/proxy_service_factory.h" |
38 #include "chrome/browser/notifications/desktop_notification_service.h" | 38 #include "chrome/browser/notifications/desktop_notification_service.h" |
39 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 39 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
40 #include "chrome/browser/policy/user_cloud_policy_manager.h" | |
41 #include "chrome/browser/prefs/browser_prefs.h" | 40 #include "chrome/browser/prefs/browser_prefs.h" |
42 #include "chrome/browser/prerender/prerender_manager.h" | 41 #include "chrome/browser/prerender/prerender_manager.h" |
43 #include "chrome/browser/profiles/profile_dependency_manager.h" | 42 #include "chrome/browser/profiles/profile_dependency_manager.h" |
44 #include "chrome/browser/profiles/storage_partition_descriptor.h" | 43 #include "chrome/browser/profiles/storage_partition_descriptor.h" |
45 #include "chrome/browser/protector/protector_service_factory.h" | 44 #include "chrome/browser/protector/protector_service_factory.h" |
46 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" | 45 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" |
47 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" | 46 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" |
48 #include "chrome/browser/webdata/web_data_service.h" | 47 #include "chrome/browser/webdata/web_data_service.h" |
49 #include "chrome/browser/webdata/web_data_service_factory.h" | 48 #include "chrome/browser/webdata/web_data_service_factory.h" |
50 #include "chrome/common/chrome_constants.h" | 49 #include "chrome/common/chrome_constants.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 base::Unretained(this))); | 200 base::Unretained(this))); |
202 } else { | 201 } else { |
203 FinishInit(); | 202 FinishInit(); |
204 } | 203 } |
205 } | 204 } |
206 | 205 |
207 TestingProfile::TestingProfile( | 206 TestingProfile::TestingProfile( |
208 const FilePath& path, | 207 const FilePath& path, |
209 Delegate* delegate, | 208 Delegate* delegate, |
210 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, | 209 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, |
211 scoped_ptr<PrefService> prefs, | 210 scoped_ptr<PrefService> prefs) |
212 scoped_ptr<policy::UserCloudPolicyManager> user_cloud_policy_manager) | |
213 : start_time_(Time::Now()), | 211 : start_time_(Time::Now()), |
214 prefs_(prefs.release()), | 212 prefs_(prefs.release()), |
215 testing_prefs_(NULL), | 213 testing_prefs_(NULL), |
216 incognito_(false), | 214 incognito_(false), |
217 last_session_exited_cleanly_(true), | 215 last_session_exited_cleanly_(true), |
218 extension_special_storage_policy_(extension_policy), | 216 extension_special_storage_policy_(extension_policy), |
219 user_cloud_policy_manager_(user_cloud_policy_manager.release()), | |
220 profile_path_(path), | 217 profile_path_(path), |
221 profile_dependency_manager_(ProfileDependencyManager::GetInstance()), | 218 profile_dependency_manager_(ProfileDependencyManager::GetInstance()), |
222 delegate_(delegate) { | 219 delegate_(delegate) { |
223 | 220 |
224 // If no profile path was supplied, create one. | 221 // If no profile path was supplied, create one. |
225 if (profile_path_.empty()) { | 222 if (profile_path_.empty()) { |
226 CreateTempProfileDir(); | 223 CreateTempProfileDir(); |
227 profile_path_ = temp_dir_.path(); | 224 profile_path_ = temp_dir_.path(); |
228 } | 225 } |
229 | 226 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 TestingProfile::~TestingProfile() { | 294 TestingProfile::~TestingProfile() { |
298 MaybeSendDestroyedNotification(); | 295 MaybeSendDestroyedNotification(); |
299 | 296 |
300 profile_dependency_manager_->DestroyProfileServices(this); | 297 profile_dependency_manager_->DestroyProfileServices(this); |
301 | 298 |
302 if (host_content_settings_map_) | 299 if (host_content_settings_map_) |
303 host_content_settings_map_->ShutdownOnUIThread(); | 300 host_content_settings_map_->ShutdownOnUIThread(); |
304 | 301 |
305 DestroyTopSites(); | 302 DestroyTopSites(); |
306 | 303 |
307 #if defined(ENABLE_CONFIGURATION_POLICY) | |
308 if (user_cloud_policy_manager_) | |
309 user_cloud_policy_manager_->Shutdown(); | |
310 #endif | |
311 | |
312 if (pref_proxy_config_tracker_.get()) | 304 if (pref_proxy_config_tracker_.get()) |
313 pref_proxy_config_tracker_->DetachFromPrefService(); | 305 pref_proxy_config_tracker_->DetachFromPrefService(); |
314 } | 306 } |
315 | 307 |
316 static ProfileKeyedService* BuildFaviconService(Profile* profile) { | 308 static ProfileKeyedService* BuildFaviconService(Profile* profile) { |
317 return new FaviconService( | 309 return new FaviconService( |
318 HistoryServiceFactory::GetForProfileWithoutCreating(profile)); | 310 HistoryServiceFactory::GetForProfileWithoutCreating(profile)); |
319 } | 311 } |
320 | 312 |
321 void TestingProfile::CreateFaviconService() { | 313 void TestingProfile::CreateFaviconService() { |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 return extension_special_storage_policy_.get(); | 530 return extension_special_storage_policy_.get(); |
539 } | 531 } |
540 | 532 |
541 net::CookieMonster* TestingProfile::GetCookieMonster() { | 533 net::CookieMonster* TestingProfile::GetCookieMonster() { |
542 if (!GetRequestContext()) | 534 if (!GetRequestContext()) |
543 return NULL; | 535 return NULL; |
544 return GetRequestContext()->GetURLRequestContext()->cookie_store()-> | 536 return GetRequestContext()->GetURLRequestContext()->cookie_store()-> |
545 GetCookieMonster(); | 537 GetCookieMonster(); |
546 } | 538 } |
547 | 539 |
548 policy::UserCloudPolicyManager* TestingProfile::GetUserCloudPolicyManager() { | |
549 return user_cloud_policy_manager_.get(); | |
550 } | |
551 | |
552 policy::ManagedModePolicyProvider* | 540 policy::ManagedModePolicyProvider* |
553 TestingProfile::GetManagedModePolicyProvider() { | 541 TestingProfile::GetManagedModePolicyProvider() { |
554 return NULL; | 542 return NULL; |
555 } | 543 } |
556 | 544 |
557 policy::PolicyService* TestingProfile::GetPolicyService() { | 545 policy::PolicyService* TestingProfile::GetPolicyService() { |
558 if (!policy_service_.get()) { | 546 if (!policy_service_.get()) { |
559 #if defined(ENABLE_CONFIGURATION_POLICY) | 547 #if defined(ENABLE_CONFIGURATION_POLICY) |
560 policy::PolicyServiceImpl::Providers providers; | 548 policy::PolicyServiceImpl::Providers providers; |
561 policy_service_.reset(new policy::PolicyServiceImpl(providers)); | 549 policy_service_.reset(new policy::PolicyServiceImpl(providers)); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 | 797 |
810 void TestingProfile::Builder::SetExtensionSpecialStoragePolicy( | 798 void TestingProfile::Builder::SetExtensionSpecialStoragePolicy( |
811 scoped_refptr<ExtensionSpecialStoragePolicy> policy) { | 799 scoped_refptr<ExtensionSpecialStoragePolicy> policy) { |
812 extension_policy_ = policy; | 800 extension_policy_ = policy; |
813 } | 801 } |
814 | 802 |
815 void TestingProfile::Builder::SetPrefService(scoped_ptr<PrefService> prefs) { | 803 void TestingProfile::Builder::SetPrefService(scoped_ptr<PrefService> prefs) { |
816 pref_service_ = prefs.Pass(); | 804 pref_service_ = prefs.Pass(); |
817 } | 805 } |
818 | 806 |
819 void TestingProfile::Builder::SetUserCloudPolicyManager( | |
820 scoped_ptr<policy::UserCloudPolicyManager> manager) { | |
821 user_cloud_policy_manager_ = manager.Pass(); | |
822 } | |
823 | |
824 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { | 807 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { |
825 DCHECK(!build_called_); | 808 DCHECK(!build_called_); |
826 build_called_ = true; | 809 build_called_ = true; |
827 return scoped_ptr<TestingProfile>(new TestingProfile( | 810 return scoped_ptr<TestingProfile>(new TestingProfile( |
828 path_, | 811 path_, |
829 delegate_, | 812 delegate_, |
830 extension_policy_, | 813 extension_policy_, |
831 pref_service_.Pass(), | 814 pref_service_.Pass())); |
832 user_cloud_policy_manager_.Pass())); | |
833 } | 815 } |
OLD | NEW |