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 fc487cf10cf2ff0f18fc88031dc66cefdd52639f..377d3f12fbb4b1695b1be288f36420ac22835e0d 100644 |
--- a/chrome/browser/resources/google_now/background.js |
+++ b/chrome/browser/resources/google_now/background.js |
@@ -265,12 +265,7 @@ function recordEvent(event) { |
* parameter. |
*/ |
function setAuthorization(request, callbackBoolean) { |
- authenticationManager.getAuthToken(function(token) { |
- if (!token) { |
- callbackBoolean(false); |
- return; |
- } |
- |
+ authenticationManager.getAuthToken().then(function(token) { |
request.setRequestHeader('Authorization', 'Bearer ' + token); |
// Instrument onloadend to remove stale auth tokens. |
@@ -287,6 +282,8 @@ function setAuthorization(request, callbackBoolean) { |
}); |
callbackBoolean(true); |
+ }).catch(function() { |
+ callbackBoolean(false); |
}); |
} |
@@ -1088,7 +1085,7 @@ function updateRunningState( |
function onStateChange() { |
tasks.add(STATE_CHANGED_TASK_NAME, function() { |
Promise.all([ |
- isSignedIn(), |
+ authenticationManager.isSignedIn(), |
isGeolocationEnabled(), |
canEnableBackground(), |
isNotificationsEnabled(), |
@@ -1100,18 +1097,6 @@ function onStateChange() { |
} |
/** |
- * 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. |
*/ |