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 <utility> | 7 #include <utility> |
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" | 42 #include "chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.h" |
43 #include "chrome/browser/profiles/profile_manager.h" | 43 #include "chrome/browser/profiles/profile_manager.h" |
44 #include "chrome/browser/profiles/storage_partition_descriptor.h" | 44 #include "chrome/browser/profiles/storage_partition_descriptor.h" |
45 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" | 45 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" |
46 #include "chrome/browser/search_engines/template_url_service_factory.h" | 46 #include "chrome/browser/search_engines/template_url_service_factory.h" |
47 #include "chrome/browser/sync/glue/sync_start_util.h" | 47 #include "chrome/browser/sync/glue/sync_start_util.h" |
48 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" | 48 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" |
49 #include "chrome/browser/web_data_service_factory.h" | 49 #include "chrome/browser/web_data_service_factory.h" |
50 #include "chrome/common/chrome_constants.h" | 50 #include "chrome/common/chrome_constants.h" |
51 #include "chrome/common/chrome_switches.h" | 51 #include "chrome/common/chrome_switches.h" |
52 #include "chrome/common/features.h" | |
Lei Zhang
2016/09/08 19:12:11
Is this needed?
| |
52 #include "chrome/common/pref_names.h" | 53 #include "chrome/common/pref_names.h" |
53 #include "chrome/common/url_constants.h" | 54 #include "chrome/common/url_constants.h" |
54 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 55 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
55 #include "components/bookmarks/browser/bookmark_model.h" | 56 #include "components/bookmarks/browser/bookmark_model.h" |
56 #include "components/bookmarks/common/bookmark_constants.h" | 57 #include "components/bookmarks/common/bookmark_constants.h" |
57 #include "components/content_settings/core/browser/host_content_settings_map.h" | 58 #include "components/content_settings/core/browser/host_content_settings_map.h" |
58 #include "components/favicon/core/fallback_icon_service.h" | 59 #include "components/favicon/core/fallback_icon_service.h" |
59 #include "components/favicon/core/favicon_service.h" | 60 #include "components/favicon/core/favicon_service.h" |
60 #include "components/history/content/browser/content_visit_delegate.h" | 61 #include "components/history/content/browser/content_visit_delegate.h" |
61 #include "components/history/content/browser/history_database_helper.h" | 62 #include "components/history/content/browser/history_database_helper.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 #include "chrome/browser/signin/oauth2_token_service_delegate_android.h" | 118 #include "chrome/browser/signin/oauth2_token_service_delegate_android.h" |
118 #endif | 119 #endif |
119 | 120 |
120 #if defined(ENABLE_SUPERVISED_USERS) | 121 #if defined(ENABLE_SUPERVISED_USERS) |
121 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 122 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
122 #include "chrome/browser/supervised_user/supervised_user_pref_store.h" | 123 #include "chrome/browser/supervised_user/supervised_user_pref_store.h" |
123 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" | 124 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
124 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor y.h" | 125 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor y.h" |
125 #endif | 126 #endif |
126 | 127 |
128 #if BUILDFLAG(ANDROID_JAVA_UI) | |
129 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | |
130 #include "components/offline_pages/stub_offline_page_model.h" | |
131 #endif | |
132 | |
127 using base::Time; | 133 using base::Time; |
128 using bookmarks::BookmarkModel; | 134 using bookmarks::BookmarkModel; |
129 using content::BrowserThread; | 135 using content::BrowserThread; |
130 using content::DownloadManagerDelegate; | 136 using content::DownloadManagerDelegate; |
131 using testing::NiceMock; | 137 using testing::NiceMock; |
132 using testing::Return; | 138 using testing::Return; |
133 | 139 |
134 namespace { | 140 namespace { |
135 | 141 |
136 // Default profile name | 142 // Default profile name |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 content::BrowserContext* context) { | 243 content::BrowserContext* context) { |
238 const base::FilePath& context_path = context->GetPath(); | 244 const base::FilePath& context_path = context->GetPath(); |
239 return base::WrapUnique(new WebDataServiceWrapper( | 245 return base::WrapUnique(new WebDataServiceWrapper( |
240 context_path, g_browser_process->GetApplicationLocale(), | 246 context_path, g_browser_process->GetApplicationLocale(), |
241 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), | 247 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), |
242 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB), | 248 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB), |
243 sync_start_util::GetFlareForSyncableService(context_path), | 249 sync_start_util::GetFlareForSyncableService(context_path), |
244 &TestProfileErrorCallback)); | 250 &TestProfileErrorCallback)); |
245 } | 251 } |
246 | 252 |
253 #if BUILDFLAG(ANDROID_JAVA_UI) | |
254 std::unique_ptr<KeyedService> BuildOfflinePageModel( | |
255 content::BrowserContext* context) { | |
256 return base::MakeUnique<offline_pages::StubOfflinePageModel>(); | |
257 } | |
258 #endif | |
259 | |
247 } // namespace | 260 } // namespace |
248 | 261 |
249 // static | 262 // static |
250 #if defined(OS_CHROMEOS) | 263 #if defined(OS_CHROMEOS) |
251 // Must be kept in sync with | 264 // Must be kept in sync with |
252 // ChromeBrowserMainPartsChromeos::PreEarlyInitialization. | 265 // ChromeBrowserMainPartsChromeos::PreEarlyInitialization. |
253 const char TestingProfile::kTestUserProfileDir[] = "test-user"; | 266 const char TestingProfile::kTestUserProfileDir[] = "test-user"; |
254 #else | 267 #else |
255 const char TestingProfile::kTestUserProfileDir[] = "Default"; | 268 const char TestingProfile::kTestUserProfileDir[] = "Default"; |
256 #endif | 269 #endif |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
603 base::ThreadTaskRunnerHandle::Get()->PostTask( | 616 base::ThreadTaskRunnerHandle::Get()->PostTask( |
604 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 617 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
605 base::RunLoop().Run(); | 618 base::RunLoop().Run(); |
606 } | 619 } |
607 | 620 |
608 void TestingProfile::CreateBookmarkModel(bool delete_file) { | 621 void TestingProfile::CreateBookmarkModel(bool delete_file) { |
609 if (delete_file) { | 622 if (delete_file) { |
610 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); | 623 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); |
611 base::DeleteFile(path, false); | 624 base::DeleteFile(path, false); |
612 } | 625 } |
626 #if BUILDFLAG(ANDROID_JAVA_UI) | |
627 offline_pages::OfflinePageModelFactory::GetInstance()->SetTestingFactory( | |
628 this, BuildOfflinePageModel); | |
629 #endif | |
613 ManagedBookmarkServiceFactory::GetInstance()->SetTestingFactory( | 630 ManagedBookmarkServiceFactory::GetInstance()->SetTestingFactory( |
614 this, ManagedBookmarkServiceFactory::GetDefaultFactory()); | 631 this, ManagedBookmarkServiceFactory::GetDefaultFactory()); |
615 // This creates the BookmarkModel. | 632 // This creates the BookmarkModel. |
616 ignore_result(BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( | 633 ignore_result(BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( |
617 this, BuildBookmarkModel)); | 634 this, BuildBookmarkModel)); |
618 } | 635 } |
619 | 636 |
620 void TestingProfile::CreateWebDataService() { | 637 void TestingProfile::CreateWebDataService() { |
621 WebDataServiceFactory::GetInstance()->SetTestingFactory( | 638 WebDataServiceFactory::GetInstance()->SetTestingFactory( |
622 this, BuildWebDataService); | 639 this, BuildWebDataService); |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1073 // Note: Owned by |original_profile|. | 1090 // Note: Owned by |original_profile|. |
1074 return new TestingProfile(path_, delegate_, | 1091 return new TestingProfile(path_, delegate_, |
1075 #if defined(ENABLE_EXTENSIONS) | 1092 #if defined(ENABLE_EXTENSIONS) |
1076 extension_policy_, | 1093 extension_policy_, |
1077 #endif | 1094 #endif |
1078 std::move(pref_service_), original_profile, | 1095 std::move(pref_service_), original_profile, |
1079 guest_session_, supervised_user_id_, | 1096 guest_session_, supervised_user_id_, |
1080 std::move(policy_service_), testing_factories_, | 1097 std::move(policy_service_), testing_factories_, |
1081 profile_name_); | 1098 profile_name_); |
1082 } | 1099 } |
OLD | NEW |