This source file includes following definitions.
- GetForProfile
- GetInstance
- UseSyncedNotifications
- BuildServiceInstanceFor
#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h"
#include "base/command_line.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
#include "chrome/browser/notifications/sync_notifier/synced_notification_app_info_service_factory.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
namespace notifier {
ChromeNotifierService* ChromeNotifierServiceFactory::GetForProfile(
Profile* profile, Profile::ServiceAccessType service_access_type) {
return static_cast<ChromeNotifierService*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
ChromeNotifierServiceFactory* ChromeNotifierServiceFactory::GetInstance() {
return Singleton<ChromeNotifierServiceFactory>::get();
}
bool ChromeNotifierServiceFactory::UseSyncedNotifications(
CommandLine* command_line) {
if (command_line->HasSwitch(switches::kDisableSyncSyncedNotifications))
return false;
if (command_line->HasSwitch(switches::kEnableSyncSyncedNotifications))
return true;
chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
if (channel == chrome::VersionInfo::CHANNEL_UNKNOWN ||
channel == chrome::VersionInfo::CHANNEL_DEV ||
channel == chrome::VersionInfo::CHANNEL_CANARY)
return true;
return false;
}
ChromeNotifierServiceFactory::ChromeNotifierServiceFactory()
: BrowserContextKeyedServiceFactory(
"ChromeNotifierService",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(SyncedNotificationAppInfoServiceFactory::GetInstance());
}
ChromeNotifierServiceFactory::~ChromeNotifierServiceFactory() {
}
KeyedService* ChromeNotifierServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const {
NotificationUIManager* notification_manager =
g_browser_process->notification_ui_manager();
ChromeNotifierService* chrome_notifier_service =
new ChromeNotifierService(static_cast<Profile*>(profile),
notification_manager);
return chrome_notifier_service;
}
}