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

Unified Diff: ui/file_manager/file_manager/foreground/js/app_state_controller.js

Issue 2578863003: Files app: Handle chrome.runtime.lastError for chrome.storage API calls. (Closed)
Patch Set: Append chrome.runtime.lastError.message for error messages. Created 4 years 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: ui/file_manager/file_manager/foreground/js/app_state_controller.js
diff --git a/ui/file_manager/file_manager/foreground/js/app_state_controller.js b/ui/file_manager/file_manager/foreground/js/app_state_controller.js
index 5bcb4f3217f305f60de7839fe0026887a1057602..a38d14373d31ea2fd0502b54278f81b76b1f3029 100644
--- a/ui/file_manager/file_manager/foreground/js/app_state_controller.js
+++ b/ui/file_manager/file_manager/foreground/js/app_state_controller.js
@@ -35,8 +35,15 @@ function AppStateController(dialogType) {
*/
AppStateController.prototype.loadInitialViewOptions = function() {
// Load initial view option.
- return new Promise(function(fulfill) {
- chrome.storage.local.get(this.viewOptionStorageKey_, fulfill);
+ return new Promise(function(fulfill, reject) {
+ chrome.storage.local.get(this.viewOptionStorageKey_, function(values) {
+ if (chrome.runtime.lastError) {
+ reject('Failed to load view options: ' +
+ chrome.runtime.lastError.message);
+ } else {
+ fulfill(values);
+ }
+ });
}.bind(this)).then(function(values) {
this.viewOptions_ = {};
var value = values[this.viewOptionStorageKey_];
@@ -55,6 +62,9 @@ AppStateController.prototype.loadInitialViewOptions = function() {
this.viewOptions_[key] = window.appState.viewOptions[key];
}
}
+ }.bind(this)).catch(function(error) {
+ this.viewOptions_ = {};
+ console.error(error);
}.bind(this));
};
@@ -104,7 +114,11 @@ AppStateController.prototype.saveViewOptions = function() {
// Save the global default.
var items = {};
items[this.viewOptionStorageKey_] = JSON.stringify(prefs);
- chrome.storage.local.set(items);
+ chrome.storage.local.set(items, function() {
+ if (chrome.runtime.lastError)
+ console.error('Failed to save view options: ' +
+ chrome.runtime.lastError.message);
+ });
// Save the window-specific preference.
if (window.appState) {

Powered by Google App Engine
This is Rietveld 408576698