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

Side by Side Diff: chrome/browser/resources/google_now/background.js

Issue 1131933005: Sign in Now to GCM, only when user is signed in. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gcm
Patch Set: Created 5 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @fileoverview The event page for Google Now for Chrome implementation. 8 * @fileoverview The event page for Google Now for Chrome implementation.
9 * The Google Now event page gets Google Now cards from the server and shows 9 * The Google Now event page gets Google Now cards from the server and shows
10 * them as Chrome notifications. 10 * them as Chrome notifications.
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 // We don't clear localStorage since those values are still relevant 1021 // We don't clear localStorage since those values are still relevant
1022 // across Google Now start-stop events. 1022 // across Google Now start-stop events.
1023 chrome.storage.local.clear(); 1023 chrome.storage.local.clear();
1024 } 1024 }
1025 1025
1026 /** 1026 /**
1027 * Initializes the event page on install or on browser startup. 1027 * Initializes the event page on install or on browser startup.
1028 */ 1028 */
1029 function initialize() { 1029 function initialize() {
1030 recordEvent(GoogleNowEvent.EXTENSION_START); 1030 recordEvent(GoogleNowEvent.EXTENSION_START);
1031 // TODO(skare): Reenable, after signin.
1032 unregisterFromGcm();
1033 onStateChange(); 1031 onStateChange();
1034 } 1032 }
1035 1033
1036 /** 1034 /**
1037 * Starts or stops the main pipeline for polling cards. 1035 * Starts or stops the main pipeline for polling cards.
1038 * @param {boolean} shouldPollCardsRequest true to start and 1036 * @param {boolean} shouldPollCardsRequest true to start and
1039 * false to stop polling cards. 1037 * false to stop polling cards.
1040 */ 1038 */
1041 function setShouldPollCards(shouldPollCardsRequest) { 1039 function setShouldPollCards(shouldPollCardsRequest) {
1042 updateCardsAttempts.isRunning(function(currentValue) { 1040 updateCardsAttempts.isRunning(function(currentValue) {
1043 if (shouldPollCardsRequest != currentValue) { 1041 if (shouldPollCardsRequest != currentValue) {
1044 console.log('Action Taken setShouldPollCards=' + shouldPollCardsRequest); 1042 console.log('Action Taken setShouldPollCards=' + shouldPollCardsRequest);
1045 if (shouldPollCardsRequest) 1043 if (shouldPollCardsRequest)
1046 startPollingCards(); 1044 startPollingCards();
1047 else 1045 else
1048 stopPollingCards(); 1046 stopPollingCards();
1049 } else { 1047 } else {
1050 console.log( 1048 console.log(
1051 'Action Ignored setShouldPollCards=' + shouldPollCardsRequest); 1049 'Action Ignored setShouldPollCards=' + shouldPollCardsRequest);
1052 } 1050 }
1053 }); 1051 });
1054 } 1052 }
1055 1053
1056 /** 1054 /**
1057 * Starts or stops the optin check. 1055 * Starts or stops the optin check and GCM channel to receive optin
1056 * notifications.
1058 * @param {boolean} shouldPollOptInStatus true to start and false to stop 1057 * @param {boolean} shouldPollOptInStatus true to start and false to stop
1059 * polling the optin status. 1058 * polling the optin status.
1060 */ 1059 */
1061 function setShouldPollOptInStatus(shouldPollOptInStatus) { 1060 function setShouldPollOptInStatus(shouldPollOptInStatus) {
1062 optInPollAttempts.isRunning(function(currentValue) { 1061 optInPollAttempts.isRunning(function(currentValue) {
1063 if (shouldPollOptInStatus != currentValue) { 1062 if (shouldPollOptInStatus != currentValue) {
1064 console.log( 1063 console.log(
1065 'Action Taken setShouldPollOptInStatus=' + shouldPollOptInStatus); 1064 'Action Taken setShouldPollOptInStatus=' + shouldPollOptInStatus);
1066 if (shouldPollOptInStatus) { 1065 if (shouldPollOptInStatus) {
1067 pollOptedInNoImmediateRecheck(); 1066 pollOptedInNoImmediateRecheck();
1068 } else { 1067 } else {
1069 optInPollAttempts.stop(); 1068 optInPollAttempts.stop();
1070 } 1069 }
1071 } else { 1070 } else {
1072 console.log( 1071 console.log(
1073 'Action Ignored setShouldPollOptInStatus=' + shouldPollOptInStatus); 1072 'Action Ignored setShouldPollOptInStatus=' + shouldPollOptInStatus);
1074 } 1073 }
1075 }); 1074 });
1075
1076 if (shouldPollOptInStatus) {
1077 registerForGcm();
1078 } else {
1079 unregisterFromGcm();
1080 }
1076 } 1081 }
1077 1082
1078 /** 1083 /**
1079 * Enables or disables the Google Now background permission. 1084 * Enables or disables the Google Now background permission.
1080 * @param {boolean} backgroundEnable true to run in the background. 1085 * @param {boolean} backgroundEnable true to run in the background.
1081 * false to not run in the background. 1086 * false to not run in the background.
1082 */ 1087 */
1083 function setBackgroundEnable(backgroundEnable) { 1088 function setBackgroundEnable(backgroundEnable) {
1084 instrumented.permissions.contains({permissions: ['background']}, 1089 instrumented.permissions.contains({permissions: ['background']},
1085 function(hasPermission) { 1090 function(hasPermission) {
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 lastPollNowPayloads: items.lastPollNowPayloads, 1495 lastPollNowPayloads: items.lastPollNowPayloads,
1491 notificationGroups: items.notificationGroups 1496 notificationGroups: items.notificationGroups
1492 }); 1497 });
1493 1498
1494 pollOptedInWithRecheck(); 1499 pollOptedInWithRecheck();
1495 } 1500 }
1496 }); 1501 });
1497 }); 1502 });
1498 } 1503 }
1499 }); 1504 });
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698