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

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

Issue 177003015: Pull AsyncApiFunction out of src/chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase for storage_api 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 Profile* profile = Profile::FromBrowserContext(context()); 100 Profile* profile = Profile::FromBrowserContext(browser_context());
101 101
102 // GCM is not supported in incognito mode. 102 // GCM is not supported in incognito mode.
103 if (profile->IsOffTheRecord()) 103 if (profile->IsOffTheRecord())
104 return false; 104 return false;
105 105
106 return gcm::GCMProfileService::GetGCMEnabledState(profile) != 106 return gcm::GCMProfileService::GetGCMEnabledState(profile) !=
107 gcm::GCMProfileService::ALWAYS_DISABLED; 107 gcm::GCMProfileService::ALWAYS_DISABLED;
108 } 108 }
109 109
110 gcm::GCMProfileService* GcmApiFunction::GCMProfileService() const { 110 gcm::GCMProfileService* GcmApiFunction::GCMProfileService() const {
111 return gcm::GCMProfileServiceFactory::GetForProfile( 111 return gcm::GCMProfileServiceFactory::GetForProfile(
112 Profile::FromBrowserContext(context())); 112 Profile::FromBrowserContext(browser_context()));
113 } 113 }
114 114
115 GcmRegisterFunction::GcmRegisterFunction() {} 115 GcmRegisterFunction::GcmRegisterFunction() {}
116 116
117 GcmRegisterFunction::~GcmRegisterFunction() {} 117 GcmRegisterFunction::~GcmRegisterFunction() {}
118 118
119 bool GcmRegisterFunction::DoWork() { 119 bool GcmRegisterFunction::DoWork() {
120 scoped_ptr<api::gcm::Register::Params> params( 120 scoped_ptr<api::gcm::Register::Params> params(
121 api::gcm::Register::Params::Create(*args_)); 121 api::gcm::Register::Params::Create(*args_));
122 EXTENSION_FUNCTION_VALIDATE(params.get()); 122 EXTENSION_FUNCTION_VALIDATE(params.get());
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 scoped_ptr<Event> event(new Event( 232 scoped_ptr<Event> event(new Event(
233 api::gcm::OnSendError::kEventName, 233 api::gcm::OnSendError::kEventName,
234 api::gcm::OnSendError::Create(error).Pass(), 234 api::gcm::OnSendError::Create(error).Pass(),
235 profile_)); 235 profile_));
236 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( 236 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension(
237 app_id, event.Pass()); 237 app_id, event.Pass());
238 } 238 }
239 239
240 } // namespace extensions 240 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/dial/dial_apitest.cc ('k') | chrome/browser/extensions/api/hid/hid_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698