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

Unified Diff: chrome/browser/extensions/api/gcm/gcm_api.cc

Issue 167063004: [GCM] Move the manifest key checking logic to gcm.register function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/gcm/gcm_apitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/gcm/gcm_api.cc
diff --git a/chrome/browser/extensions/api/gcm/gcm_api.cc b/chrome/browser/extensions/api/gcm/gcm_api.cc
index 79af39233dc668efb4ccad5263d61cdf3b007200..a8a5be20d4d07d333fbb44ceb1b196262f64d172 100644
--- a/chrome/browser/extensions/api/gcm/gcm_api.cc
+++ b/chrome/browser/extensions/api/gcm/gcm_api.cc
@@ -31,6 +31,7 @@ const char kGoogleRestrictedPrefix[] = "google";
const char kInvalidParameter[] =
"Function was called with invalid parameters.";
const char kNotSignedIn[] = "Profile was not signed in.";
+const char kCertificateMissing[] = "Manifest key was missing.";
const char kAsyncOperationPending[] =
"Asynchronous operation is pending.";
const char kNetworkError[] = "Network error occurred.";
@@ -51,6 +52,8 @@ const char* GcmResultToError(gcm::GCMClient::Result result) {
return kInvalidParameter;
case gcm::GCMClient::NOT_SIGNED_IN:
return kNotSignedIn;
+ case gcm::GCMClient::CERTIFICATE_MISSING:
+ return kCertificateMissing;
case gcm::GCMClient::ASYNC_OPERATION_PENDING:
return kAsyncOperationPending;
case gcm::GCMClient::NETWORK_ERROR:
@@ -95,8 +98,7 @@ bool GcmApiFunction::RunImpl() {
bool GcmApiFunction::IsGcmApiEnabled() const {
return gcm::GCMProfileService::IsGCMEnabled(
- Profile::FromBrowserContext(context())) &&
- !GetExtension()->public_key().empty();
+ Profile::FromBrowserContext(context()));
}
gcm::GCMProfileService* GcmApiFunction::GCMProfileService() const {
@@ -113,6 +115,12 @@ bool GcmRegisterFunction::DoWork() {
api::gcm::Register::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params.get());
+ if (GetExtension()->public_key().empty()) {
+ CompleteFunctionWithResult(std::string(),
+ gcm::GCMClient::CERTIFICATE_MISSING);
+ return false;
+ }
+
GCMProfileService()->Register(
GetExtension()->id(),
params->sender_ids,
« no previous file with comments | « no previous file | chrome/browser/extensions/api/gcm/gcm_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698