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

Side by Side Diff: chrome/browser/extensions/api/gcm/gcm_api.cc

Issue 165993005: [GCM] Make sure GCM checkout logic is invoked when the profile is signed out (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix test Created 6 years, 9 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/gcm/gcm_api.h" 5 #include "chrome/browser/extensions/api/gcm/gcm_api.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 namespace extensions { 90 namespace extensions {
91 91
92 bool GcmApiFunction::RunImpl() { 92 bool GcmApiFunction::RunImpl() {
93 if (!IsGcmApiEnabled()) 93 if (!IsGcmApiEnabled())
94 return false; 94 return false;
95 95
96 return DoWork(); 96 return DoWork();
97 } 97 }
98 98
99 bool GcmApiFunction::IsGcmApiEnabled() const { 99 bool GcmApiFunction::IsGcmApiEnabled() const {
100 return gcm::GCMProfileService::IsGCMEnabled( 100 Profile* profile = Profile::FromBrowserContext(context());
101 Profile::FromBrowserContext(context())); 101
102 // GCM is not supported in incognito mode.
103 if (profile->IsOffTheRecord())
104 return false;
105
106 return gcm::GCMProfileService::GetGCMEnabledState(profile) !=
107 gcm::GCMProfileService::ALWAYS_DISABLED;
102 } 108 }
103 109
104 gcm::GCMProfileService* GcmApiFunction::GCMProfileService() const { 110 gcm::GCMProfileService* GcmApiFunction::GCMProfileService() const {
105 return gcm::GCMProfileServiceFactory::GetForProfile( 111 return gcm::GCMProfileServiceFactory::GetForProfile(
106 Profile::FromBrowserContext(context())); 112 Profile::FromBrowserContext(context()));
107 } 113 }
108 114
109 GcmRegisterFunction::GcmRegisterFunction() {} 115 GcmRegisterFunction::GcmRegisterFunction() {}
110 116
111 GcmRegisterFunction::~GcmRegisterFunction() {} 117 GcmRegisterFunction::~GcmRegisterFunction() {}
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 231
226 scoped_ptr<Event> event(new Event( 232 scoped_ptr<Event> event(new Event(
227 api::gcm::OnSendError::kEventName, 233 api::gcm::OnSendError::kEventName,
228 api::gcm::OnSendError::Create(error).Pass(), 234 api::gcm::OnSendError::Create(error).Pass(),
229 profile_)); 235 profile_));
230 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( 236 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension(
231 app_id, event.Pass()); 237 app_id, event.Pass());
232 } 238 }
233 239
234 } // namespace extensions 240 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/gcm/gcm_apitest.cc » ('j') | chrome/browser/services/gcm/gcm_profile_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698