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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 | 197 |
198 scoped_ptr<KeyedService> BuildInMemoryURLIndex( | 198 scoped_ptr<KeyedService> BuildInMemoryURLIndex( |
199 content::BrowserContext* context) { | 199 content::BrowserContext* context) { |
200 Profile* profile = Profile::FromBrowserContext(context); | 200 Profile* profile = Profile::FromBrowserContext(context); |
201 scoped_ptr<InMemoryURLIndex> in_memory_url_index(new InMemoryURLIndex( | 201 scoped_ptr<InMemoryURLIndex> in_memory_url_index(new InMemoryURLIndex( |
202 BookmarkModelFactory::GetForProfile(profile), | 202 BookmarkModelFactory::GetForProfile(profile), |
203 HistoryServiceFactory::GetForProfile(profile, | 203 HistoryServiceFactory::GetForProfile(profile, |
204 ServiceAccessType::IMPLICIT_ACCESS), | 204 ServiceAccessType::IMPLICIT_ACCESS), |
205 TemplateURLServiceFactory::GetForProfile(profile), | 205 TemplateURLServiceFactory::GetForProfile(profile), |
206 content::BrowserThread::GetBlockingPool(), profile->GetPath(), | 206 content::BrowserThread::GetBlockingPool(), profile->GetPath(), |
207 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), | |
208 SchemeSet())); | 207 SchemeSet())); |
209 in_memory_url_index->Init(); | 208 in_memory_url_index->Init(); |
210 return std::move(in_memory_url_index); | 209 return std::move(in_memory_url_index); |
211 } | 210 } |
212 | 211 |
213 scoped_ptr<KeyedService> BuildBookmarkModel(content::BrowserContext* context) { | 212 scoped_ptr<KeyedService> BuildBookmarkModel(content::BrowserContext* context) { |
214 Profile* profile = Profile::FromBrowserContext(context); | 213 Profile* profile = Profile::FromBrowserContext(context); |
215 scoped_ptr<BookmarkModel> bookmark_model( | 214 scoped_ptr<BookmarkModel> bookmark_model( |
216 new BookmarkModel(make_scoped_ptr(new ChromeBookmarkClient( | 215 new BookmarkModel(make_scoped_ptr(new ChromeBookmarkClient( |
217 profile, ManagedBookmarkServiceFactory::GetForProfile(profile))))); | 216 profile, ManagedBookmarkServiceFactory::GetForProfile(profile))))); |
218 bookmark_model->Load(profile->GetPrefs(), | 217 bookmark_model->Load(profile->GetPrefs(), |
219 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), | |
220 profile->GetPath(), | 218 profile->GetPath(), |
221 profile->GetIOTaskRunner(), | 219 profile->GetIOTaskRunner(), |
222 content::BrowserThread::GetMessageLoopProxyForThread( | 220 content::BrowserThread::GetMessageLoopProxyForThread( |
223 content::BrowserThread::UI)); | 221 content::BrowserThread::UI)); |
224 return std::move(bookmark_model); | 222 return std::move(bookmark_model); |
225 } | 223 } |
226 | 224 |
227 void TestProfileErrorCallback(WebDataServiceWrapper::ErrorType error_type, | 225 void TestProfileErrorCallback(WebDataServiceWrapper::ErrorType error_type, |
228 sql::InitStatus status) { | 226 sql::InitStatus status) { |
229 NOTREACHED(); | 227 NOTREACHED(); |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 path = path.Append(history::kHistoryFilename); | 538 path = path.Append(history::kHistoryFilename); |
541 if (!base::DeleteFile(path, false) || base::PathExists(path)) | 539 if (!base::DeleteFile(path, false) || base::PathExists(path)) |
542 return false; | 540 return false; |
543 } | 541 } |
544 // This will create and init the history service. | 542 // This will create and init the history service. |
545 history::HistoryService* history_service = | 543 history::HistoryService* history_service = |
546 static_cast<history::HistoryService*>( | 544 static_cast<history::HistoryService*>( |
547 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 545 HistoryServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
548 this, BuildHistoryService)); | 546 this, BuildHistoryService)); |
549 if (!history_service->Init( | 547 if (!history_service->Init( |
550 no_db, GetPrefs()->GetString(prefs::kAcceptLanguages), | 548 no_db, history::HistoryDatabaseParamsForPath(GetPath()))) { |
551 history::HistoryDatabaseParamsForPath(GetPath()))) { | |
552 HistoryServiceFactory::GetInstance()->SetTestingFactory(this, nullptr); | 549 HistoryServiceFactory::GetInstance()->SetTestingFactory(this, nullptr); |
553 return false; | 550 return false; |
554 } | 551 } |
555 // Some tests expect that CreateHistoryService() will also make the | 552 // Some tests expect that CreateHistoryService() will also make the |
556 // InMemoryURLIndex available. | 553 // InMemoryURLIndex available. |
557 InMemoryURLIndexFactory::GetInstance()->SetTestingFactory( | 554 InMemoryURLIndexFactory::GetInstance()->SetTestingFactory( |
558 this, BuildInMemoryURLIndex); | 555 this, BuildInMemoryURLIndex); |
559 // Disable WebHistoryService by default, since it makes network requests. | 556 // Disable WebHistoryService by default, since it makes network requests. |
560 WebHistoryServiceFactory::GetInstance()->SetTestingFactory(this, nullptr); | 557 WebHistoryServiceFactory::GetInstance()->SetTestingFactory(this, nullptr); |
561 return true; | 558 return true; |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 // Note: Owned by |original_profile|. | 1035 // Note: Owned by |original_profile|. |
1039 return new TestingProfile(path_, delegate_, | 1036 return new TestingProfile(path_, delegate_, |
1040 #if defined(ENABLE_EXTENSIONS) | 1037 #if defined(ENABLE_EXTENSIONS) |
1041 extension_policy_, | 1038 extension_policy_, |
1042 #endif | 1039 #endif |
1043 std::move(pref_service_), original_profile, | 1040 std::move(pref_service_), original_profile, |
1044 guest_session_, supervised_user_id_, | 1041 guest_session_, supervised_user_id_, |
1045 std::move(policy_service_), testing_factories_, | 1042 std::move(policy_service_), testing_factories_, |
1046 profile_name_); | 1043 profile_name_); |
1047 } | 1044 } |
OLD | NEW |