Commit e5499dde authored by skare's avatar skare Committed by Commit bot

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}
parent e63d52e7
......@@ -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();
}
......@@ -1310,6 +1312,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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment