Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1277)

Unified Diff: chrome/browser/services/gcm/gcm_profile_service_factory.cc

Issue 60673002: Create services/gcm directory and add some initial files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch to land Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/services/gcm/gcm_profile_service_factory.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/services/gcm/gcm_profile_service_factory.cc
diff --git a/chrome/browser/services/gcm/gcm_profile_service_factory.cc b/chrome/browser/services/gcm/gcm_profile_service_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..489feea77f89822858b5d5a86d6598928f37c559
--- /dev/null
+++ b/chrome/browser/services/gcm/gcm_profile_service_factory.cc
@@ -0,0 +1,48 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
+
+#include "chrome/browser/profiles/incognito_helpers.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/services/gcm/gcm_profile_service.h"
+#include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
+
+namespace gcm {
+
+// static
+GCMProfileService* GCMProfileServiceFactory::GetForProfile(Profile* profile) {
+ if (!gcm::GCMProfileService::IsGCMEnabled())
+ return NULL;
+
+ return static_cast<GCMProfileService*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true));
+}
+
+// static
+GCMProfileServiceFactory* GCMProfileServiceFactory::GetInstance() {
+ return Singleton<GCMProfileServiceFactory>::get();
+}
+
+GCMProfileServiceFactory::GCMProfileServiceFactory()
+ : BrowserContextKeyedServiceFactory(
+ "GCMProfileService",
+ BrowserContextDependencyManager::GetInstance()) {
+}
+
+GCMProfileServiceFactory::~GCMProfileServiceFactory() {
+}
+
+BrowserContextKeyedService* GCMProfileServiceFactory::BuildServiceInstanceFor(
+ content::BrowserContext* profile) const {
+ return gcm::GCMProfileService::IsGCMEnabled() ?
+ new GCMProfileService(static_cast<Profile*>(profile)) : NULL;
+}
+
+content::BrowserContext* GCMProfileServiceFactory::GetBrowserContextToUse(
+ content::BrowserContext* context) const {
+ return chrome::GetBrowserContextOwnInstanceInIncognito(context);
+}
+
+} // namespace gcm
« no previous file with comments | « chrome/browser/services/gcm/gcm_profile_service_factory.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698