chrome_notifier_service_factory.cc revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
1// Copyright (c) 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/notifications/sync_notifier/chrome_notifier_service_factory.h" 6 7#include "base/command_line.h" 8#include "chrome/browser/browser_process.h" 9#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" 10#include "chrome/common/chrome_switches.h" 11#include "chrome/common/chrome_version_info.h" 12#include "components/browser_context_keyed_service/browser_context_dependency_manager.h" 13 14namespace notifier { 15 16// static 17ChromeNotifierService* ChromeNotifierServiceFactory::GetForProfile( 18 Profile* profile, Profile::ServiceAccessType sat) { 19 return static_cast<ChromeNotifierService*>( 20 GetInstance()->GetServiceForBrowserContext(profile, true)); 21} 22 23// static 24ChromeNotifierServiceFactory* ChromeNotifierServiceFactory::GetInstance() { 25 return Singleton<ChromeNotifierServiceFactory>::get(); 26} 27 28// static 29bool ChromeNotifierServiceFactory::UseSyncedNotifications( 30 CommandLine* command_line) { 31 if (command_line->HasSwitch(switches::kDisableSyncSyncedNotifications)) 32 return false; 33 if (command_line->HasSwitch(switches::kEnableSyncSyncedNotifications)) 34 return true; 35 36 // enable it by default for canary and dev 37 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); 38 if (channel == chrome::VersionInfo::CHANNEL_UNKNOWN || 39 channel == chrome::VersionInfo::CHANNEL_DEV || 40 channel == chrome::VersionInfo::CHANNEL_CANARY) 41 return true; 42 43 return false; 44} 45 46ChromeNotifierServiceFactory::ChromeNotifierServiceFactory() 47 : BrowserContextKeyedServiceFactory( 48 "ChromeNotifierService", 49 BrowserContextDependencyManager::GetInstance()) {} 50 51ChromeNotifierServiceFactory::~ChromeNotifierServiceFactory() { 52} 53 54BrowserContextKeyedService* 55ChromeNotifierServiceFactory::BuildServiceInstanceFor( 56 content::BrowserContext* profile) const { 57 NotificationUIManager* notification_manager = 58 g_browser_process->notification_ui_manager(); 59 ChromeNotifierService* chrome_notifier_service = 60 new ChromeNotifierService(static_cast<Profile*>(profile), 61 notification_manager); 62 return chrome_notifier_service; 63} 64 65} // namespace notifier 66