1// Copyright 2013 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "chrome/browser/ui/app_list/search/history_factory.h" 6 7#include "base/memory/ref_counted.h" 8#include "base/memory/singleton.h" 9#include "chrome/browser/ui/app_list/search/common/dictionary_data_store.h" 10#include "chrome/browser/ui/app_list/search/history.h" 11#include "chrome/browser/ui/app_list/search/history_data_store.h" 12#include "components/keyed_service/content/browser_context_dependency_manager.h" 13#include "content/public/browser/browser_context.h" 14 15namespace app_list { 16 17// static 18HistoryFactory* HistoryFactory::GetInstance() { 19 return Singleton<HistoryFactory>::get(); 20} 21 22// static 23History* HistoryFactory::GetForBrowserContext( 24 content::BrowserContext* context) { 25 return static_cast<History*>( 26 GetInstance()->GetServiceForBrowserContext(context, true)); 27} 28 29HistoryFactory::HistoryFactory() 30 : BrowserContextKeyedServiceFactory( 31 "app_list::History", 32 BrowserContextDependencyManager::GetInstance()) {} 33 34HistoryFactory::~HistoryFactory() {} 35 36KeyedService* HistoryFactory::BuildServiceInstanceFor( 37 content::BrowserContext* context) const { 38 const char kStoreDataFileName[] = "App Launcher Search"; 39 const base::FilePath data_file = 40 context->GetPath().AppendASCII(kStoreDataFileName); 41 scoped_refptr<DictionaryDataStore> dictionary_data_store( 42 new DictionaryDataStore(data_file)); 43 scoped_refptr<HistoryDataStore> history_data_store( 44 new HistoryDataStore(dictionary_data_store)); 45 return new History(history_data_store); 46} 47 48} // namespace app_list 49