| Index: trunk/src/chrome/browser/resources/google_now/background.js
|
| ===================================================================
|
| --- trunk/src/chrome/browser/resources/google_now/background.js (revision 252133)
|
| +++ trunk/src/chrome/browser/resources/google_now/background.js (working copy)
|
| @@ -265,7 +265,12 @@
|
| * parameter.
|
| */
|
| function setAuthorization(request, callbackBoolean) {
|
| - authenticationManager.getAuthToken().then(function(token) {
|
| + authenticationManager.getAuthToken(function(token) {
|
| + if (!token) {
|
| + callbackBoolean(false);
|
| + return;
|
| + }
|
| +
|
| request.setRequestHeader('Authorization', 'Bearer ' + token);
|
|
|
| // Instrument onloadend to remove stale auth tokens.
|
| @@ -273,7 +278,7 @@
|
| request.onloadend = wrapper.wrapCallback(function(event) {
|
| if (request.status == HTTP_FORBIDDEN ||
|
| request.status == HTTP_UNAUTHORIZED) {
|
| - authenticationManager.removeToken(token).then(function() {
|
| + authenticationManager.removeToken(token, function() {
|
| originalOnLoadEnd(event);
|
| });
|
| } else {
|
| @@ -282,8 +287,6 @@
|
| });
|
|
|
| callbackBoolean(true);
|
| - }).catch(function() {
|
| - callbackBoolean(false);
|
| });
|
| }
|
|
|
| @@ -1085,7 +1088,7 @@
|
| function onStateChange() {
|
| tasks.add(STATE_CHANGED_TASK_NAME, function() {
|
| Promise.all([
|
| - authenticationManager.isSignedIn(),
|
| + isSignedIn(),
|
| isGeolocationEnabled(),
|
| canEnableBackground(),
|
| isNotificationsEnabled(),
|
| @@ -1097,6 +1100,18 @@
|
| }
|
|
|
| /**
|
| + * Determines if the user is signed in.
|
| + * @return {Promise} A promise to evaluate the signed in state.
|
| + */
|
| +function isSignedIn() {
|
| + return new Promise(function(resolve) {
|
| + authenticationManager.isSignedIn(function(signedIn) {
|
| + resolve(signedIn);
|
| + });
|
| + });
|
| +}
|
| +
|
| +/**
|
| * Gets the geolocation enabled preference.
|
| * @return {Promise} A promise to get the geolocation enabled preference.
|
| */
|
|
|