diff options
author | Anthony Laforge <laforge@chromium.org> | 2015-06-03 14:52:18 -0700 |
---|---|---|
committer | Anthony Laforge <laforge@chromium.org> | 2015-06-03 21:53:36 +0000 |
commit | 88e40c301897b34b6b72e4ae4110218d4741b0fc (patch) | |
tree | 553f73d2829fae7a2b05bcbb4b741528c9048f4f | |
parent | 4549bef962595a15c2a5aae53003db69015997f6 (diff) | |
download | chromium_src-88e40c301897b34b6b72e4ae4110218d4741b0fc.zip chromium_src-88e40c301897b34b6b72e4ae4110218d4741b0fc.tar.gz chromium_src-88e40c301897b34b6b72e4ae4110218d4741b0fc.tar.bz2 |
Now component extension (v1): unregister from GCM on startup
BUG=479274
Review URL: https://codereview.chromium.org/1079163004
Cr-Commit-Position: refs/heads/master@{#326696}
(cherry picked from commit e5499ddebc7499f765ef3688d8c4c293ee3138cf)
Review URL: https://codereview.chromium.org/1165903003
Cr-Commit-Position: refs/branch-heads/2357@{#460}
Cr-Branched-From: 59d4494849b405682265ed5d3f5164573b9a939b-refs/heads/master@{#323860}
-rw-r--r-- | chrome/browser/resources/google_now/background.js | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/chrome/browser/resources/google_now/background.js b/chrome/browser/resources/google_now/background.js index e24f70b..2db2d1e 100644 --- a/chrome/browser/resources/google_now/background.js +++ b/chrome/browser/resources/google_now/background.js @@ -202,6 +202,7 @@ var tasks = buildTaskManager(areTasksConflicting); // Add error processing to API calls. wrapper.instrumentChromeApiFunction('gcm.onMessage.addListener', 0); wrapper.instrumentChromeApiFunction('gcm.register', 1); +wrapper.instrumentChromeApiFunction('gcm.unregister', 0); wrapper.instrumentChromeApiFunction('metricsPrivate.getVariationParams', 1); wrapper.instrumentChromeApiFunction('notifications.clear', 1); wrapper.instrumentChromeApiFunction('notifications.create', 2); @@ -1027,7 +1028,8 @@ function stopPollingCards() { */ function initialize() { recordEvent(GoogleNowEvent.EXTENSION_START); - registerForGcm(); + // TODO(skare): Reenable, after signin. + unregisterFromGcm(); onStateChange(); } @@ -1311,6 +1313,24 @@ function getGcmRegistrationId() { } /** + * Unregisters from GCM if previously registered. + */ +function unregisterFromGcm() { + fillFromChromeLocalStorage({gcmRegistrationId: undefined}) + .then(function(items) { + if (items.gcmRegistrationId) { + console.log('Unregistering from gcm.'); + instrumented.gcm.unregister(function() { + if (!chrome.runtime.lastError) { + chrome.storage.local.remove( + ['gcmNotificationKey', 'gcmRegistrationId']); + } + }); + } + }); +} + +/** * Polls the optin state. * Sometimes we get the response to the opted in result too soon during * push messaging. We'll recheck the optin state a few times before giving up. |