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 { |