Index: chrome/browser/resources/google_now/background.js |
diff --git a/chrome/browser/resources/google_now/background.js b/chrome/browser/resources/google_now/background.js |
index e24f70b499b482ea73d0a51204315cb4d34bcb2f..2db2d1e6f8c2b094265dcf2992fdc4e7edba8f56 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. |