| Index: chrome/browser/history/top_sites_service_factory.cc
|
| diff --git a/chrome/browser/history/top_sites_service_factory.cc b/chrome/browser/history/top_sites_service_factory.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..62c44427a9179471ae15528f3591943233310bf2
|
| --- /dev/null
|
| +++ b/chrome/browser/history/top_sites_service_factory.cc
|
| @@ -0,0 +1,67 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/history/top_sites_service_factory.h"
|
| +
|
| +#include "chrome/browser/history/top_sites_impl.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/common/chrome_constants.h"
|
| +#include "components/keyed_service/content/browser_context_dependency_manager.h"
|
| +
|
| +using namespace history;
|
| +
|
| +// static
|
| +scoped_refptr<history::TopSites> TopSitesServiceFactory::GetForProfile(
|
| + Profile* profile) {
|
| + return static_cast<history::TopSites*>(
|
| + GetInstance()->GetServiceForBrowserContext(profile, true).get());
|
| +}
|
| +
|
| +// static
|
| +scoped_refptr<history::TopSites> TopSitesServiceFactory::GetForProfileIfExists(
|
| + Profile* profile) {
|
| + return static_cast<history::TopSites*>(
|
| + GetInstance()->GetServiceForBrowserContext(profile, false).get());
|
| +}
|
| +
|
| +// static
|
| +TopSitesServiceFactory* TopSitesServiceFactory::GetInstance() {
|
| + return Singleton<TopSitesServiceFactory>::get();
|
| +}
|
| +
|
| +// static
|
| +scoped_refptr<RefcountedKeyedService>
|
| +TopSitesServiceFactory::BuildProfileForTesting(
|
| + content::BrowserContext* profile) {
|
| + scoped_refptr<TopSitesImpl> provider(
|
| + new TopSitesImpl(static_cast<Profile*>(profile)));
|
| + provider->Init(profile->GetPath().Append(chrome::kTopSitesFilename));
|
| + return provider;
|
| +}
|
| +
|
| +// static
|
| +scoped_refptr<RefcountedKeyedService>
|
| +TopSitesServiceFactory::CreateCustomTopSitesServiceFactory(
|
| + history::TopSites* top_sites) {
|
| + scoped_refptr<history::TopSites> provider(top_sites);
|
| + return provider;
|
| +}
|
| +
|
| +TopSitesServiceFactory::TopSitesServiceFactory()
|
| + : RefcountedBrowserContextKeyedServiceFactory(
|
| + "TopSitesService",
|
| + BrowserContextDependencyManager::GetInstance()) {
|
| +}
|
| +
|
| +TopSitesServiceFactory::~TopSitesServiceFactory() {
|
| +}
|
| +
|
| +scoped_refptr<RefcountedKeyedService>
|
| +TopSitesServiceFactory::BuildServiceInstanceFor(
|
| + content::BrowserContext* profile) const {
|
| + scoped_refptr<TopSitesImpl> provider(
|
| + new TopSitesImpl(static_cast<Profile*>(profile)));
|
| + provider->Init(profile->GetPath().Append(chrome::kTopSitesFilename));
|
| + return provider;
|
| +}
|
|
|