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

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

Issue 217263005: Add Optin Retry Logic to Google Now (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Word change Created 6 years, 9 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 | « chrome/browser/resources/google_now/background.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/google_now/utility.js
diff --git a/chrome/browser/resources/google_now/utility.js b/chrome/browser/resources/google_now/utility.js
index d91bd680d0274efa82538feb8d2201f7cd37a4d7..c67a370c10a886154aed796824dd6cc04f7113b8 100644
--- a/chrome/browser/resources/google_now/utility.js
+++ b/chrome/browser/resources/google_now/utility.js
@@ -648,9 +648,22 @@ function fillFromChromeLocalStorage(
defaultStorageObject,
opt_allowPromiseRejection) {
return new Promise(function(resolve, reject) {
- instrumented.storage.local.get(defaultStorageObject, function(items) {
+ // We have to create a keys array because keys with a default value
+ // of undefined will cause that key to not be looked up!
+ var keysToGet = [];
+ for (var key in defaultStorageObject) {
+ keysToGet.push(key);
+ }
+ instrumented.storage.local.get(keysToGet, function(items) {
if (items) {
- resolve(items);
+ // Merge the result with the default storage object to ensure all keys
+ // requested have either the default value or the retrieved storage
+ // value.
+ var result = {};
+ for (var key in defaultStorageObject) {
+ result[key] = (key in items) ? items[key] : defaultStorageObject[key];
+ }
+ resolve(result);
} else if (opt_allowPromiseRejection === PromiseRejection.ALLOW) {
reject();
} else {
« no previous file with comments | « chrome/browser/resources/google_now/background.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698