OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "chrome/common/chrome_notification_types.h" | 44 #include "chrome/common/chrome_notification_types.h" |
45 #include "chrome/common/chrome_switches.h" | 45 #include "chrome/common/chrome_switches.h" |
46 #include "chrome/common/url_constants.h" | 46 #include "chrome/common/url_constants.h" |
47 #include "chrome/test/base/bookmark_load_observer.h" | 47 #include "chrome/test/base/bookmark_load_observer.h" |
48 #include "chrome/test/base/test_url_request_context_getter.h" | 48 #include "chrome/test/base/test_url_request_context_getter.h" |
49 #include "chrome/test/base/testing_pref_service.h" | 49 #include "chrome/test/base/testing_pref_service.h" |
50 #include "chrome/test/base/ui_test_utils.h" | 50 #include "chrome/test/base/ui_test_utils.h" |
51 #include "content/browser/browser_thread.h" | 51 #include "content/browser/browser_thread.h" |
52 #include "content/browser/in_process_webkit/webkit_context.h" | 52 #include "content/browser/in_process_webkit/webkit_context.h" |
53 #include "content/browser/mock_resource_context.h" | 53 #include "content/browser/mock_resource_context.h" |
54 #include "content/common/notification_service.h" | 54 #include "content/public/browser/notification_service.h" |
55 #include "net/base/cookie_monster.h" | 55 #include "net/base/cookie_monster.h" |
56 #include "net/url_request/url_request_context.h" | 56 #include "net/url_request/url_request_context.h" |
57 #include "net/url_request/url_request_context_getter.h" | 57 #include "net/url_request/url_request_context_getter.h" |
58 #include "net/url_request/url_request_test_util.h" | 58 #include "net/url_request/url_request_test_util.h" |
59 #include "testing/gmock/include/gmock/gmock.h" | 59 #include "testing/gmock/include/gmock/gmock.h" |
60 #include "webkit/database/database_tracker.h" | 60 #include "webkit/database/database_tracker.h" |
61 #include "webkit/fileapi/file_system_context.h" | 61 #include "webkit/fileapi/file_system_context.h" |
62 #include "webkit/quota/quota_manager.h" | 62 #include "webkit/quota/quota_manager.h" |
63 #include "webkit/quota/mock_quota_manager.h" | 63 #include "webkit/quota/mock_quota_manager.h" |
64 | 64 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 Init(); | 167 Init(); |
168 } | 168 } |
169 | 169 |
170 void TestingProfile::Init() { | 170 void TestingProfile::Init() { |
171 profile_dependency_manager_->CreateProfileServices(this, true); | 171 profile_dependency_manager_->CreateProfileServices(this, true); |
172 | 172 |
173 // Install profile keyed service factory hooks for dummy/test services | 173 // Install profile keyed service factory hooks for dummy/test services |
174 DesktopNotificationServiceFactory::GetInstance()->SetTestingFactory( | 174 DesktopNotificationServiceFactory::GetInstance()->SetTestingFactory( |
175 this, CreateTestDesktopNotificationService); | 175 this, CreateTestDesktopNotificationService); |
176 | 176 |
177 NotificationService::current()->Notify( | 177 content::NotificationService::current()->Notify( |
178 chrome::NOTIFICATION_PROFILE_CREATED, | 178 chrome::NOTIFICATION_PROFILE_CREATED, |
179 content::Source<Profile>(static_cast<Profile*>(this)), | 179 content::Source<Profile>(static_cast<Profile*>(this)), |
180 NotificationService::NoDetails()); | 180 content::NotificationService::NoDetails()); |
181 } | 181 } |
182 | 182 |
183 TestingProfile::~TestingProfile() { | 183 TestingProfile::~TestingProfile() { |
184 NotificationService::current()->Notify( | 184 content::NotificationService::current()->Notify( |
185 chrome::NOTIFICATION_PROFILE_DESTROYED, | 185 chrome::NOTIFICATION_PROFILE_DESTROYED, |
186 content::Source<Profile>(static_cast<Profile*>(this)), | 186 content::Source<Profile>(static_cast<Profile*>(this)), |
187 NotificationService::NoDetails()); | 187 content::NotificationService::NoDetails()); |
188 | 188 |
189 profile_dependency_manager_->DestroyProfileServices(this); | 189 profile_dependency_manager_->DestroyProfileServices(this); |
190 | 190 |
191 if (host_content_settings_map_) | 191 if (host_content_settings_map_) |
192 host_content_settings_map_->ShutdownOnUIThread(); | 192 host_content_settings_map_->ShutdownOnUIThread(); |
193 | 193 |
194 DestroyTopSites(); | 194 DestroyTopSites(); |
195 DestroyHistoryService(); | 195 DestroyHistoryService(); |
196 // FaviconService depends on HistoryServce so destroying it later. | 196 // FaviconService depends on HistoryServce so destroying it later. |
197 DestroyFaviconService(); | 197 DestroyFaviconService(); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 bookmark_bar_model_->AddObserver(&observer); | 311 bookmark_bar_model_->AddObserver(&observer); |
312 MessageLoop::current()->Run(); | 312 MessageLoop::current()->Run(); |
313 bookmark_bar_model_->RemoveObserver(&observer); | 313 bookmark_bar_model_->RemoveObserver(&observer); |
314 DCHECK(bookmark_bar_model_->IsLoaded()); | 314 DCHECK(bookmark_bar_model_->IsLoaded()); |
315 } | 315 } |
316 | 316 |
317 // TODO(phajdan.jr): Doesn't this hang if Top Sites are already loaded? | 317 // TODO(phajdan.jr): Doesn't this hang if Top Sites are already loaded? |
318 void TestingProfile::BlockUntilTopSitesLoaded() { | 318 void TestingProfile::BlockUntilTopSitesLoaded() { |
319 ui_test_utils::WindowedNotificationObserver top_sites_loaded_observer( | 319 ui_test_utils::WindowedNotificationObserver top_sites_loaded_observer( |
320 chrome::NOTIFICATION_TOP_SITES_LOADED, | 320 chrome::NOTIFICATION_TOP_SITES_LOADED, |
321 NotificationService::AllSources()); | 321 content::NotificationService::AllSources()); |
322 if (!GetHistoryService(Profile::EXPLICIT_ACCESS)) | 322 if (!GetHistoryService(Profile::EXPLICIT_ACCESS)) |
323 GetTopSites()->HistoryLoaded(); | 323 GetTopSites()->HistoryLoaded(); |
324 top_sites_loaded_observer.Wait(); | 324 top_sites_loaded_observer.Wait(); |
325 } | 325 } |
326 | 326 |
327 void TestingProfile::CreateTemplateURLFetcher() { | 327 void TestingProfile::CreateTemplateURLFetcher() { |
328 template_url_fetcher_.reset(new TemplateURLFetcher(this)); | 328 template_url_fetcher_.reset(new TemplateURLFetcher(this)); |
329 } | 329 } |
330 | 330 |
331 static ProfileKeyedService* BuildTemplateURLService(Profile* profile) { | 331 static ProfileKeyedService* BuildTemplateURLService(Profile* profile) { |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { | 788 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { |
789 return GetExtensionSpecialStoragePolicy(); | 789 return GetExtensionSpecialStoragePolicy(); |
790 } | 790 } |
791 | 791 |
792 void TestingProfile::DestroyWebDataService() { | 792 void TestingProfile::DestroyWebDataService() { |
793 if (!web_data_service_.get()) | 793 if (!web_data_service_.get()) |
794 return; | 794 return; |
795 | 795 |
796 web_data_service_->Shutdown(); | 796 web_data_service_->Shutdown(); |
797 } | 797 } |
OLD | NEW |