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 9f7d55e1f02e481997ebc46b2b4e5573c5aa5b3d..fc487cf10cf2ff0f18fc88031dc66cefdd52639f 100644 |
--- a/chrome/browser/resources/google_now/background.js |
+++ b/chrome/browser/resources/google_now/background.js |
@@ -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(), |
@@ -1093,6 +1096,18 @@ |
.then(function(results) { |
updateRunningState.apply(null, results); |
}); |
+ }); |
+} |
+ |
+/** |
+ * 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); |
+ }); |
}); |
} |