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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 #include "chrome/browser/signin/oauth2_token_service_delegate_android.h" | 117 #include "chrome/browser/signin/oauth2_token_service_delegate_android.h" |
118 #endif | 118 #endif |
119 | 119 |
120 #if defined(ENABLE_SUPERVISED_USERS) | 120 #if defined(ENABLE_SUPERVISED_USERS) |
121 #include "chrome/browser/supervised_user/supervised_user_constants.h" | 121 #include "chrome/browser/supervised_user/supervised_user_constants.h" |
122 #include "chrome/browser/supervised_user/supervised_user_pref_store.h" | 122 #include "chrome/browser/supervised_user/supervised_user_pref_store.h" |
123 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" | 123 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
124 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor
y.h" | 124 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor
y.h" |
125 #endif | 125 #endif |
126 | 126 |
| 127 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 128 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
| 129 #include "components/offline_pages/stub_offline_page_model.h" |
| 130 #endif |
| 131 |
127 using base::Time; | 132 using base::Time; |
128 using bookmarks::BookmarkModel; | 133 using bookmarks::BookmarkModel; |
129 using content::BrowserThread; | 134 using content::BrowserThread; |
130 using content::DownloadManagerDelegate; | 135 using content::DownloadManagerDelegate; |
131 using testing::NiceMock; | 136 using testing::NiceMock; |
132 using testing::Return; | 137 using testing::Return; |
133 | 138 |
134 namespace { | 139 namespace { |
135 | 140 |
136 // Default profile name | 141 // Default profile name |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 content::BrowserContext* context) { | 242 content::BrowserContext* context) { |
238 const base::FilePath& context_path = context->GetPath(); | 243 const base::FilePath& context_path = context->GetPath(); |
239 return base::WrapUnique(new WebDataServiceWrapper( | 244 return base::WrapUnique(new WebDataServiceWrapper( |
240 context_path, g_browser_process->GetApplicationLocale(), | 245 context_path, g_browser_process->GetApplicationLocale(), |
241 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), | 246 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), |
242 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB), | 247 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB), |
243 sync_start_util::GetFlareForSyncableService(context_path), | 248 sync_start_util::GetFlareForSyncableService(context_path), |
244 &TestProfileErrorCallback)); | 249 &TestProfileErrorCallback)); |
245 } | 250 } |
246 | 251 |
| 252 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 253 std::unique_ptr<KeyedService> BuildOfflinePageModel( |
| 254 content::BrowserContext* context) { |
| 255 return base::MakeUnique<offline_pages::StubOfflinePageModel>(); |
| 256 } |
| 257 #endif |
| 258 |
247 } // namespace | 259 } // namespace |
248 | 260 |
249 // static | 261 // static |
250 #if defined(OS_CHROMEOS) | 262 #if defined(OS_CHROMEOS) |
251 // Must be kept in sync with | 263 // Must be kept in sync with |
252 // ChromeBrowserMainPartsChromeos::PreEarlyInitialization. | 264 // ChromeBrowserMainPartsChromeos::PreEarlyInitialization. |
253 const char TestingProfile::kTestUserProfileDir[] = "test-user"; | 265 const char TestingProfile::kTestUserProfileDir[] = "test-user"; |
254 #else | 266 #else |
255 const char TestingProfile::kTestUserProfileDir[] = "Default"; | 267 const char TestingProfile::kTestUserProfileDir[] = "Default"; |
256 #endif | 268 #endif |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 base::ThreadTaskRunnerHandle::Get()->PostTask( | 615 base::ThreadTaskRunnerHandle::Get()->PostTask( |
604 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 616 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
605 base::RunLoop().Run(); | 617 base::RunLoop().Run(); |
606 } | 618 } |
607 | 619 |
608 void TestingProfile::CreateBookmarkModel(bool delete_file) { | 620 void TestingProfile::CreateBookmarkModel(bool delete_file) { |
609 if (delete_file) { | 621 if (delete_file) { |
610 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); | 622 base::FilePath path = GetPath().Append(bookmarks::kBookmarksFileName); |
611 base::DeleteFile(path, false); | 623 base::DeleteFile(path, false); |
612 } | 624 } |
| 625 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 626 offline_pages::OfflinePageModelFactory::GetInstance()->SetTestingFactory( |
| 627 this, BuildOfflinePageModel); |
| 628 #endif |
613 ManagedBookmarkServiceFactory::GetInstance()->SetTestingFactory( | 629 ManagedBookmarkServiceFactory::GetInstance()->SetTestingFactory( |
614 this, ManagedBookmarkServiceFactory::GetDefaultFactory()); | 630 this, ManagedBookmarkServiceFactory::GetDefaultFactory()); |
615 // This creates the BookmarkModel. | 631 // This creates the BookmarkModel. |
616 ignore_result(BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( | 632 ignore_result(BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( |
617 this, BuildBookmarkModel)); | 633 this, BuildBookmarkModel)); |
618 } | 634 } |
619 | 635 |
620 void TestingProfile::CreateWebDataService() { | 636 void TestingProfile::CreateWebDataService() { |
621 WebDataServiceFactory::GetInstance()->SetTestingFactory( | 637 WebDataServiceFactory::GetInstance()->SetTestingFactory( |
622 this, BuildWebDataService); | 638 this, BuildWebDataService); |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 // Note: Owned by |original_profile|. | 1089 // Note: Owned by |original_profile|. |
1074 return new TestingProfile(path_, delegate_, | 1090 return new TestingProfile(path_, delegate_, |
1075 #if defined(ENABLE_EXTENSIONS) | 1091 #if defined(ENABLE_EXTENSIONS) |
1076 extension_policy_, | 1092 extension_policy_, |
1077 #endif | 1093 #endif |
1078 std::move(pref_service_), original_profile, | 1094 std::move(pref_service_), original_profile, |
1079 guest_session_, supervised_user_id_, | 1095 guest_session_, supervised_user_id_, |
1080 std::move(policy_service_), testing_factories_, | 1096 std::move(policy_service_), testing_factories_, |
1081 profile_name_); | 1097 profile_name_); |
1082 } | 1098 } |
OLD | NEW |