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 "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/prefs/testing_pref_store.h" | 12 #include "base/prefs/testing_pref_store.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
17 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" | 17 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
18 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" | 18 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" |
19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
21 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" | 21 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" |
22 #include "chrome/browser/favicon/favicon_service.h" | 22 #include "chrome/browser/favicon/favicon_service.h" |
23 #include "chrome/browser/favicon/favicon_service_factory.h" | 23 #include "chrome/browser/favicon/favicon_service_factory.h" |
24 #include "chrome/browser/history/chrome_history_client.h" | 24 #include "chrome/browser/history/chrome_history_client.h" |
25 #include "chrome/browser/history/chrome_history_client_factory.h" | 25 #include "chrome/browser/history/chrome_history_client_factory.h" |
26 #include "chrome/browser/history/history_backend.h" | 26 #include "chrome/browser/history/history_backend.h" |
27 #include "chrome/browser/history/history_db_task.h" | 27 #include "chrome/browser/history/history_db_task.h" |
28 #include "chrome/browser/history/history_service.h" | 28 #include "chrome/browser/history/history_service.h" |
29 #include "chrome/browser/history/history_service_factory.h" | 29 #include "chrome/browser/history/history_service_factory.h" |
30 #include "chrome/browser/history/top_sites.h" | 30 #include "chrome/browser/history/top_sites_provider.h" |
31 #include "chrome/browser/history/top_sites_service_factory.h" | |
31 #include "chrome/browser/history/web_history_service_factory.h" | 32 #include "chrome/browser/history/web_history_service_factory.h" |
32 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 33 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
33 #include "chrome/browser/net/proxy_service_factory.h" | 34 #include "chrome/browser/net/proxy_service_factory.h" |
34 #include "chrome/browser/notifications/desktop_notification_service.h" | 35 #include "chrome/browser/notifications/desktop_notification_service.h" |
35 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 36 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
36 #include "chrome/browser/policy/profile_policy_connector.h" | 37 #include "chrome/browser/policy/profile_policy_connector.h" |
37 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 38 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
38 #include "chrome/browser/prefs/browser_prefs.h" | 39 #include "chrome/browser/prefs/browser_prefs.h" |
39 #include "chrome/browser/prefs/pref_service_syncable.h" | 40 #include "chrome/browser/prefs/pref_service_syncable.h" |
40 #include "chrome/browser/prerender/prerender_manager.h" | 41 #include "chrome/browser/prerender/prerender_manager.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 using testing::NiceMock; | 110 using testing::NiceMock; |
110 using testing::Return; | 111 using testing::Return; |
111 | 112 |
112 namespace { | 113 namespace { |
113 | 114 |
114 // Used to make sure TopSites has finished loading | 115 // Used to make sure TopSites has finished loading |
115 class WaitTopSitesLoadedObserver : public history::TopSitesObserver { | 116 class WaitTopSitesLoadedObserver : public history::TopSitesObserver { |
116 public: | 117 public: |
117 explicit WaitTopSitesLoadedObserver(content::MessageLoopRunner* runner) | 118 explicit WaitTopSitesLoadedObserver(content::MessageLoopRunner* runner) |
118 : runner_(runner) {} | 119 : runner_(runner) {} |
119 void TopSitesLoaded(history::TopSites* top_sites) override { | 120 void TopSitesLoaded(history::TopSitesProvider* top_sites) override { |
120 runner_->Quit(); | 121 runner_->Quit(); |
121 } | 122 } |
122 void TopSitesChanged(history::TopSites* top_sites) override {} | 123 void TopSitesChanged(history::TopSitesProvider* top_sites) override {} |
123 | 124 |
124 private: | 125 private: |
125 // weak | 126 // weak |
126 content::MessageLoopRunner* runner_; | 127 content::MessageLoopRunner* runner_; |
127 }; | 128 }; |
128 | 129 |
129 // Task used to make sure history has finished processing a request. Intended | 130 // Task used to make sure history has finished processing a request. Intended |
130 // for use with BlockUntilHistoryProcessesPendingRequests. | 131 // for use with BlockUntilHistoryProcessesPendingRequests. |
131 | 132 |
132 class QuittingHistoryDBTask : public history::HistoryDBTask { | 133 class QuittingHistoryDBTask : public history::HistoryDBTask { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 } | 217 } |
217 | 218 |
218 KeyedService* BuildChromeBookmarkClient( | 219 KeyedService* BuildChromeBookmarkClient( |
219 content::BrowserContext* context) { | 220 content::BrowserContext* context) { |
220 return new ChromeBookmarkClient(static_cast<Profile*>(context)); | 221 return new ChromeBookmarkClient(static_cast<Profile*>(context)); |
221 } | 222 } |
222 | 223 |
223 KeyedService* BuildChromeHistoryClient( | 224 KeyedService* BuildChromeHistoryClient( |
224 content::BrowserContext* context) { | 225 content::BrowserContext* context) { |
225 Profile* profile = static_cast<Profile*>(context); | 226 Profile* profile = static_cast<Profile*>(context); |
226 return new ChromeHistoryClient(BookmarkModelFactory::GetForProfile(profile), | 227 return new ChromeHistoryClient( |
227 profile, | 228 BookmarkModelFactory::GetForProfile(profile), profile, |
228 profile->GetTopSites()); | 229 TopSitesServiceFactory::GetForProfile(profile)); |
229 } | 230 } |
230 | 231 |
231 void TestProfileErrorCallback(WebDataServiceWrapper::ErrorType error_type, | 232 void TestProfileErrorCallback(WebDataServiceWrapper::ErrorType error_type, |
232 sql::InitStatus status) { | 233 sql::InitStatus status) { |
233 NOTREACHED(); | 234 NOTREACHED(); |
234 } | 235 } |
235 | 236 |
236 KeyedService* BuildWebDataService(content::BrowserContext* context) { | 237 KeyedService* BuildWebDataService(content::BrowserContext* context) { |
237 const base::FilePath& context_path = context->GetPath(); | 238 const base::FilePath& context_path = context->GetPath(); |
238 return new WebDataServiceWrapper( | 239 return new WebDataServiceWrapper( |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
564 | 565 |
565 // Make sure we don't have any event pending that could disrupt the next | 566 // Make sure we don't have any event pending that could disrupt the next |
566 // test. | 567 // test. |
567 base::MessageLoop::current()->PostTask(FROM_HERE, | 568 base::MessageLoop::current()->PostTask(FROM_HERE, |
568 base::MessageLoop::QuitClosure()); | 569 base::MessageLoop::QuitClosure()); |
569 base::MessageLoop::current()->Run(); | 570 base::MessageLoop::current()->Run(); |
570 } | 571 } |
571 | 572 |
572 void TestingProfile::CreateTopSites() { | 573 void TestingProfile::CreateTopSites() { |
573 DestroyTopSites(); | 574 DestroyTopSites(); |
574 top_sites_ = history::TopSites::Create( | 575 top_sites_ = history::TopSitesProvider::Create( |
sdefresne
2014/12/19 15:11:42
Remove top_sites_ property from TestingProfile() a
Jitu( very slow this week)
2014/12/26 14:04:28
Done.
| |
575 this, GetPath().Append(chrome::kTopSitesFilename)); | 576 this, GetPath().Append(chrome::kTopSitesFilename)); |
576 } | 577 } |
577 | 578 |
578 void TestingProfile::SetTopSites(history::TopSites* top_sites) { | 579 void TestingProfile::SetTopSites(history::TopSitesProvider* top_sites) { |
sdefresne
2014/12/19 15:11:42
You'll have to remove this method and instead chan
Jitu( very slow this week)
2014/12/26 14:04:29
Done.
| |
579 DestroyTopSites(); | 580 DestroyTopSites(); |
580 top_sites_ = top_sites; | 581 top_sites_ = top_sites; |
581 } | 582 } |
582 | 583 |
583 void TestingProfile::DestroyTopSites() { | 584 void TestingProfile::DestroyTopSites() { |
584 if (top_sites_.get()) { | 585 if (top_sites_.get()) { |
585 top_sites_->Shutdown(); | 586 top_sites_->Shutdown(); |
586 top_sites_ = NULL; | 587 top_sites_ = NULL; |
587 // TopSitesImpl::Shutdown schedules some tasks (from TopSitesBackend) that | 588 // TopSitesImpl::Shutdown schedules some tasks (from TopSitesBackend) that |
588 // need to be run to properly shutdown. Run all pending tasks now. This is | 589 // need to be run to properly shutdown. Run all pending tasks now. This is |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
787 this, profile_policy_connector_.get()); | 788 this, profile_policy_connector_.get()); |
788 CHECK_EQ(profile_policy_connector_.get(), | 789 CHECK_EQ(profile_policy_connector_.get(), |
789 policy::ProfilePolicyConnectorFactory::GetForProfile(this)); | 790 policy::ProfilePolicyConnectorFactory::GetForProfile(this)); |
790 } | 791 } |
791 | 792 |
792 PrefService* TestingProfile::GetPrefs() { | 793 PrefService* TestingProfile::GetPrefs() { |
793 DCHECK(prefs_); | 794 DCHECK(prefs_); |
794 return prefs_.get(); | 795 return prefs_.get(); |
795 } | 796 } |
796 | 797 |
797 history::TopSites* TestingProfile::GetTopSites() { | 798 history::TopSitesProvider* TestingProfile::GetTopSites() { |
sdefresne
2014/12/19 15:11:42
Remove.
Jitu( very slow this week)
2014/12/26 14:04:29
Done.
| |
798 return top_sites_.get(); | 799 return top_sites_.get(); |
799 } | 800 } |
800 | 801 |
801 history::TopSites* TestingProfile::GetTopSitesWithoutCreating() { | 802 history::TopSitesProvider* TestingProfile::GetTopSitesWithoutCreating() { |
sdefresne
2014/12/19 15:11:42
Remove.
Jitu( very slow this week)
2014/12/26 14:04:28
Done.
| |
802 return top_sites_.get(); | 803 return top_sites_.get(); |
803 } | 804 } |
804 | 805 |
805 DownloadManagerDelegate* TestingProfile::GetDownloadManagerDelegate() { | 806 DownloadManagerDelegate* TestingProfile::GetDownloadManagerDelegate() { |
806 return NULL; | 807 return NULL; |
807 } | 808 } |
808 | 809 |
809 net::URLRequestContextGetter* TestingProfile::GetRequestContext() { | 810 net::URLRequestContextGetter* TestingProfile::GetRequestContext() { |
810 return GetDefaultStoragePartition(this)->GetURLRequestContext(); | 811 return GetDefaultStoragePartition(this)->GetURLRequestContext(); |
811 } | 812 } |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1064 #if defined(ENABLE_EXTENSIONS) | 1065 #if defined(ENABLE_EXTENSIONS) |
1065 extension_policy_, | 1066 extension_policy_, |
1066 #endif | 1067 #endif |
1067 pref_service_.Pass(), | 1068 pref_service_.Pass(), |
1068 original_profile, | 1069 original_profile, |
1069 guest_session_, | 1070 guest_session_, |
1070 supervised_user_id_, | 1071 supervised_user_id_, |
1071 policy_service_.Pass(), | 1072 policy_service_.Pass(), |
1072 testing_factories_); | 1073 testing_factories_); |
1073 } | 1074 } |
OLD | NEW |