1// Copyright (c) 2011 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/themes/theme_service_factory.h"
6
7#include "base/logging.h"
8#include "chrome/browser/extensions/extension_service.h"
9#include "chrome/browser/profiles/profile.h"
10#include "chrome/browser/profiles/profile_dependency_manager.h"
11#include "chrome/browser/themes/theme_service.h"
12#include "content/common/notification_service.h"
13
14#if defined(TOOLKIT_USES_GTK)
15#include "chrome/browser/ui/gtk/gtk_theme_service.h"
16#endif
17
18// static
19ThemeService* ThemeServiceFactory::GetForProfile(Profile* profile) {
20  return static_cast<ThemeService*>(
21      GetInstance()->GetServiceForProfile(profile));
22}
23
24// static
25const Extension* ThemeServiceFactory::GetThemeForProfile(Profile* profile) {
26  std::string id = GetForProfile(profile)->GetThemeID();
27  if (id == ThemeService::kDefaultThemeID)
28    return NULL;
29
30  return profile->GetExtensionService()->GetExtensionById(id, false);
31}
32
33// static
34ThemeServiceFactory* ThemeServiceFactory::GetInstance() {
35  return Singleton<ThemeServiceFactory>::get();
36}
37
38ThemeServiceFactory::ThemeServiceFactory()
39    : ProfileKeyedServiceFactory(
40        ProfileDependencyManager::GetInstance())
41{}
42
43ThemeServiceFactory::~ThemeServiceFactory() {}
44
45ProfileKeyedService* ThemeServiceFactory::BuildServiceInstanceFor(
46    Profile* profile) const {
47  ThemeService* provider = NULL;
48#if defined(TOOLKIT_USES_GTK)
49  provider = new GtkThemeService;
50#else
51  provider = new ThemeService;
52#endif
53  provider->Init(profile);
54
55  return provider;
56}
57
58bool ThemeServiceFactory::ServiceRedirectedInIncognito() {
59  return true;
60}
61