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