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

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: 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
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..3822d7938ae21431c08b104adae27008950ac1c9 100644
--- a/chrome/browser/resources/google_now/utility.js
+++ b/chrome/browser/resources/google_now/utility.js
@@ -648,9 +648,20 @@ 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.
+ 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 {

Powered by Google App Engine
This is Rietveld 408576698