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
3 // found in the LICENSE file.
5 #include "chrome/browser/thumbnails/thumbnail_service_factory.h"
7 #include "base/logging.h"
8 #include "chrome/browser/history/top_sites_factory.h"
9 #include "chrome/browser/thumbnails/thumbnail_service.h"
10 #include "chrome/browser/thumbnails/thumbnail_service_impl.h"
11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
13 using thumbnails::ThumbnailService
;
14 using thumbnails::ThumbnailServiceImpl
;
16 ThumbnailServiceFactory::ThumbnailServiceFactory()
17 : RefcountedBrowserContextKeyedServiceFactory(
19 BrowserContextDependencyManager::GetInstance()) {
20 DependsOn(TopSitesFactory::GetInstance());
23 ThumbnailServiceFactory::~ThumbnailServiceFactory() {
27 scoped_refptr
<ThumbnailService
> ThumbnailServiceFactory::GetForProfile(
29 return static_cast<ThumbnailService
*>(
30 GetInstance()->GetServiceForBrowserContext(profile
, true).get());
34 ThumbnailServiceFactory
* ThumbnailServiceFactory::GetInstance() {
35 return Singleton
<ThumbnailServiceFactory
>::get();
38 scoped_refptr
<RefcountedKeyedService
>
39 ThumbnailServiceFactory::BuildServiceInstanceFor(
40 content::BrowserContext
* profile
) const {
41 return scoped_refptr
<RefcountedKeyedService
>(
42 new ThumbnailServiceImpl(static_cast<Profile
*>(profile
)));