Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Unified Diff: ios/chrome/browser/autocomplete/in_memory_url_index_factory.cc

Issue 1405093012: [iOS] Add InMemoryURLIndexFactory::GetDefaultFactory() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Format Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/autocomplete/in_memory_url_index_factory.cc
diff --git a/ios/chrome/browser/autocomplete/in_memory_url_index_factory.cc b/ios/chrome/browser/autocomplete/in_memory_url_index_factory.cc
index da2d26b67b0babce099bc63b35f5acfc049a6c27..232f9d064e9f74d1fc6ab5d14800ea4eab7d308a 100644
--- a/ios/chrome/browser/autocomplete/in_memory_url_index_factory.cc
+++ b/ios/chrome/browser/autocomplete/in_memory_url_index_factory.cc
@@ -19,6 +19,29 @@
namespace ios {
+namespace {
+
+scoped_ptr<KeyedService> BuildInMemoryURLIndex(web::BrowserState* context) {
+ ios::ChromeBrowserState* browser_state =
+ ios::ChromeBrowserState::FromBrowserState(context);
+
+ SchemeSet schemes_to_whilelist;
+ schemes_to_whilelist.insert(kChromeUIScheme);
+
+ // Do not force creation of the HistoryService if saving history is disabled.
+ scoped_ptr<InMemoryURLIndex> in_memory_url_index(new InMemoryURLIndex(
+ ios::BookmarkModelFactory::GetForBrowserState(browser_state),
+ ios::HistoryServiceFactory::GetForBrowserState(
+ browser_state, ServiceAccessType::IMPLICIT_ACCESS),
+ web::WebThread::GetBlockingPool(), browser_state->GetStatePath(),
+ browser_state->GetPrefs()->GetString(ios::prefs::kAcceptLanguages),
+ schemes_to_whilelist));
+ in_memory_url_index->Init();
+ return in_memory_url_index.Pass();
+}
+
+} // namespace
+
// static
InMemoryURLIndex* InMemoryURLIndexFactory::GetForBrowserState(
ios::ChromeBrowserState* browser_state) {
@@ -41,24 +64,15 @@ InMemoryURLIndexFactory::InMemoryURLIndexFactory()
InMemoryURLIndexFactory::~InMemoryURLIndexFactory() {}
+// static
+BrowserStateKeyedServiceFactory::TestingFactoryFunction
+InMemoryURLIndexFactory::GetDefaultFactory() {
+ return &BuildInMemoryURLIndex;
+}
+
scoped_ptr<KeyedService> InMemoryURLIndexFactory::BuildServiceInstanceFor(
web::BrowserState* context) const {
- ios::ChromeBrowserState* browser_state =
- ios::ChromeBrowserState::FromBrowserState(context);
-
- SchemeSet schemes_to_whilelist;
- schemes_to_whilelist.insert(kChromeUIScheme);
-
- // Do not force creation of the HistoryService if saving history is disabled.
- scoped_ptr<InMemoryURLIndex> in_memory_url_index(new InMemoryURLIndex(
- ios::BookmarkModelFactory::GetForBrowserState(browser_state),
- ios::HistoryServiceFactory::GetForBrowserState(
- browser_state, ServiceAccessType::IMPLICIT_ACCESS),
- web::WebThread::GetBlockingPool(), browser_state->GetStatePath(),
- browser_state->GetPrefs()->GetString(ios::prefs::kAcceptLanguages),
- schemes_to_whilelist));
- in_memory_url_index->Init();
- return in_memory_url_index.Pass();
+ return BuildInMemoryURLIndex(context);
}
web::BrowserState* InMemoryURLIndexFactory::GetBrowserStateToUse(

Powered by Google App Engine
This is Rietveld 408576698