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

Unified Diff: chrome/browser/resources/google_now/background.js

Issue 55123002: Requesting background permission only when user is opted in to GN (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/resources/google_now/background_unittest.gtestjs » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b914e14dc28991bd2f7488cc25b688c0255d230c..9d6154066f991e7e08e71f733e6d6ac8b99fe096 100644
--- a/chrome/browser/resources/google_now/background.js
+++ b/chrome/browser/resources/google_now/background.js
@@ -485,6 +485,7 @@ function parseAndShowNotificationCards(response) {
// TODO(vadimt): Remove the line below once the server stops sending groups
// with 'googleNowDisabled' responses.
parsedResponse.groups = {};
+ onStateChange();
robliao 2013/10/31 18:29:41 Comment that if we make it here, Google Now was pr
vadimt 2013/10/31 20:14:08 Done.
}
var receivedGroups = parsedResponse.groups;
@@ -604,6 +605,7 @@ function requestOptedIn(optedInCallback) {
if (parsedResponse.value) {
chrome.storage.local.set({googleNowEnabled: true});
optedInCallback();
+ onStateChange();
robliao 2013/10/31 18:29:41 Same here. If we're here, Google Now was previousl
vadimt 2013/10/31 20:14:08 Done.
} else {
scheduleNextPoll({});
}
@@ -925,10 +927,9 @@ function startPollingCards() {
*/
function stopPollingCards() {
stopRequestLocation();
-
updateCardsAttempts.stop();
-
removeAllCards();
+ chrome.storage.local.set({googleNowEnabled: false});
robliao 2013/10/31 18:29:41 Semantically, this isn't necessarily correct if th
vadimt 2013/10/31 20:14:08 When the user checks us again in NC, we should sta
robliao 2013/10/31 23:05:01 This would be an excellent place for a comment. On
vadimt 2013/11/01 00:49:47 Done.
}
/**
@@ -985,21 +986,25 @@ function setBackgroundEnable(backgroundEnable) {
* @param {boolean} signedIn true if the user is signed in.
* @param {boolean} geolocationEnabled true if
* the geolocation option is enabled.
- * @param {boolean} enableBackground true if
- * the background permission should be requested.
+ * @param {boolean} canEnableBackground true if
+ * the background permission can be requested.
* @param {boolean} notificationEnabled true if
* Google Now for Chrome is allowed to show notifications.
+ * @param {boolean} googleNowEnabled true if
+ * the Google Now is enabled for the user.
*/
function updateRunningState(
signedIn,
geolocationEnabled,
- enableBackground,
- notificationEnabled) {
+ canEnableBackground,
+ notificationEnabled,
+ googleNowEnabled) {
console.log(
'State Update signedIn=' + signedIn + ' ' +
'geolocationEnabled=' + geolocationEnabled + ' ' +
- 'enableBackground=' + enableBackground + ' ' +
- 'notificationEnabled=' + notificationEnabled);
+ 'canEnableBackground=' + canEnableBackground + ' ' +
+ 'notificationEnabled=' + notificationEnabled + ' ' +
+ 'googleNowEnabled=' + googleNowEnabled);
// TODO(vadimt): Remove this line once state machine design is finalized.
geolocationEnabled = true;
@@ -1009,7 +1014,7 @@ function updateRunningState(
if (signedIn && notificationEnabled) {
if (geolocationEnabled) {
- if (enableBackground)
+ if (canEnableBackground && googleNowEnabled)
shouldSetBackground = true;
shouldPollCards = true;
@@ -1037,8 +1042,8 @@ function onStateChange() {
instrumented.metricsPrivate.getVariationParams(
'GoogleNow',
function(response) {
- var enableBackground =
- (!response || (response.enableBackground != 'false'));
+ var canEnableBackground =
+ (!response || (response.canEnableBackground != 'false'));
instrumented.notifications.getPermissionLevel(function(level) {
var notificationEnabled = (level == 'granted');
instrumented.
@@ -1046,11 +1051,18 @@ function onStateChange() {
googleGeolocationAccessEnabled.
get({}, function(prefValue) {
var geolocationEnabled = !!prefValue.value;
- updateRunningState(
- signedIn,
- geolocationEnabled,
- enableBackground,
- notificationEnabled);
+ instrumented.storage.local.get(
+ 'googleNowEnabled',
+ function(items) {
+ var googleNowEnabled =
+ items && !!items.googleNowEnabled;
+ updateRunningState(
+ signedIn,
+ geolocationEnabled,
+ canEnableBackground,
+ notificationEnabled,
+ googleNowEnabled);
+ });
});
});
});
« no previous file with comments | « no previous file | chrome/browser/resources/google_now/background_unittest.gtestjs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698