1ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Use of this source code is governed by a BSD-style license that can be
3ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// found in the LICENSE file.
4ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
5ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "chrome/browser/notifications/desktop_notification_service_factory.h"
6ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
7ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "chrome/browser/browser_process.h"
8ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "chrome/browser/notifications/desktop_notification_service.h"
9ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "chrome/browser/profiles/profile.h"
10ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "chrome/browser/profiles/profile_dependency_manager.h"
11ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "content/browser/browser_thread.h"
12ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
13ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// static
14ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian MonsenDesktopNotificationService* DesktopNotificationServiceFactory::GetForProfile(
15ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen    Profile* profile) {
16ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
17ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  return static_cast<DesktopNotificationService*>(
18ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen      GetInstance()->GetServiceForProfile(profile));
19ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen}
20ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
21ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// static
22ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian MonsenDesktopNotificationServiceFactory* DesktopNotificationServiceFactory::
23ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen    GetInstance() {
24ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  return Singleton<DesktopNotificationServiceFactory>::get();
25ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen}
26ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
27ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian MonsenDesktopNotificationServiceFactory::DesktopNotificationServiceFactory()
28ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen    : ProfileKeyedServiceFactory(ProfileDependencyManager::GetInstance()) {
29ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen}
30ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
31ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian MonsenDesktopNotificationServiceFactory::~DesktopNotificationServiceFactory() {
32ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen}
33ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
34ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian MonsenProfileKeyedService* DesktopNotificationServiceFactory::BuildServiceInstanceFor(
35ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen    Profile* profile) const {
36ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  DesktopNotificationService* service = new DesktopNotificationService(profile,
37ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen      g_browser_process->notification_ui_manager());
38ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
39ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  return service;
40ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen}
41ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
42ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenbool DesktopNotificationServiceFactory::ServiceHasOwnInstanceInIncognito() {
43ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  return true;
44ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen}
45