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

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: 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
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..87e31c3fc3f5151c9a1f27315d7c6848b221d38b 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 kManifestKeyMissing[] = "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::MANIFEST_KEY_MISSING:
+ return kManifestKeyMissing;
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::MANIFEST_KEY_MISSING);
+ return false;
+ }
+
GCMProfileService()->Register(
GetExtension()->id(),
params->sender_ids,

Powered by Google App Engine
This is Rietveld 408576698