diff options
author | alekseys@chromium.org <alekseys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-11 13:34:37 +0000 |
---|---|---|
committer | alekseys@chromium.org <alekseys@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-11 13:34:37 +0000 |
commit | 390712fe5a030a8b7b43f711b8a67ab92a4de2bc (patch) | |
tree | 3d29f95c32519909a7395c02301f637d9f002ffe | |
parent | 43afe1b4adf74df59e52ed97f67d5ed8b905aecf (diff) | |
download | chromium_src-390712fe5a030a8b7b43f711b8a67ab92a4de2bc.zip chromium_src-390712fe5a030a8b7b43f711b8a67ab92a4de2bc.tar.gz chromium_src-390712fe5a030a8b7b43f711b8a67ab92a4de2bc.tar.bz2 |
- Remove deprecated IS_SELECTED_DESTINATION_LOCAL setting;
- Fix typo in AppState.Field.SELECTED_DESTINATION_CAPABILITIES;
- Move initial default destination decision to more appropriate place (AppState);
BUG=139170
Review URL: https://codereview.chromium.org/228763010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263223 0039d316-1c4b-4281-b951-d872f2087c98
3 files changed, 20 insertions, 20 deletions
diff --git a/chrome/browser/resources/print_preview/data/app_state.js b/chrome/browser/resources/print_preview/data/app_state.js index 9f424d6..d706c74 100644 --- a/chrome/browser/resources/print_preview/data/app_state.js +++ b/chrome/browser/resources/print_preview/data/app_state.js @@ -38,7 +38,6 @@ cr.define('print_preview', function() { SELECTED_DESTINATION_ORIGIN: 'selectedDestinationOrigin', SELECTED_DESTINATION_CAPABILITIES: 'selectedDestinationCapabilities', SELECTED_DESTINATION_NAME: 'selectedDestinationName', - IS_SELECTED_DESTINATION_LOCAL: 'isSelectedDestinationLocal', // Deprecated IS_GCP_PROMO_DISMISSED: 'isGcpPromoDismissed', MARGINS_TYPE: 'marginsType', CUSTOM_MARGINS: 'customMargins', @@ -80,7 +79,7 @@ cr.define('print_preview', function() { /** @return {?print_preview.Cdd} CDD of the selected destination. */ get selectedDestinationCapabilities() { - return this.state_[AppState.Field.SELECTED_DESTINATION_CAPBILITIES]; + return this.state_[AppState.Field.SELECTED_DESTINATION_CAPABILITIES]; }, /** @return {?string} Name of the selected destination. */ @@ -120,25 +119,29 @@ cr.define('print_preview', function() { * layer. * @param {?string} serializedAppStateStr Serialized string representation * of the app state. + * @param {?string} systemDefaultDestinationId ID of the system default + * destination. */ - init: function(serializedAppStateStr) { + init: function(serializedAppStateStr, systemDefaultDestinationId) { if (serializedAppStateStr) { var state = JSON.parse(serializedAppStateStr); if (state[AppState.Field.VERSION] == AppState.VERSION_) { - if (state.hasOwnProperty( - AppState.Field.IS_SELECTED_DESTINATION_LOCAL)) { - state[AppState.Field.SELECTED_DESTINATION_ORIGIN] = - state[AppState.Field.IS_SELECTED_DESTINATION_LOCAL] ? - print_preview.Destination.Origin.LOCAL : - print_preview.Destination.Origin.COOKIES; - delete state[AppState.Field.IS_SELECTED_DESTINATION_LOCAL]; - } this.state_ = state; } } else { // Set some state defaults. this.state_[AppState.Field.IS_GCP_PROMO_DISMISSED] = false; } + // Default to system destination, if no destination was selected. + if (!this.state_[AppState.Field.SELECTED_DESTINATION_ID] || + !this.state_[AppState.Field.SELECTED_DESTINATION_ORIGIN]) { + if (systemDefaultDestinationId) { + this.state_[AppState.Field.SELECTED_DESTINATION_ID] = + systemDefaultDestinationId; + this.state_[AppState.Field.SELECTED_DESTINATION_ORIGIN] = + print_preview.Destination.Origin.LOCAL; + } + } }, /** @@ -173,7 +176,7 @@ cr.define('print_preview', function() { return; this.state_[AppState.Field.SELECTED_DESTINATION_ID] = dest.id; this.state_[AppState.Field.SELECTED_DESTINATION_ORIGIN] = dest.origin; - this.state_[AppState.Field.SELECTED_DESTINATION_CAPBILITIES] = + this.state_[AppState.Field.SELECTED_DESTINATION_CAPABILITIES] = dest.capabilities; this.state_[AppState.Field.SELECTED_DESTINATION_NAME] = dest.displayName; this.persist_(); diff --git a/chrome/browser/resources/print_preview/data/destination_store.js b/chrome/browser/resources/print_preview/data/destination_store.js index b3739d7..06d227b 100644 --- a/chrome/browser/resources/print_preview/data/destination_store.js +++ b/chrome/browser/resources/print_preview/data/destination_store.js @@ -278,19 +278,14 @@ cr.define('print_preview', function() { * destination. If any inserted destinations match this ID, that destination * will be automatically selected. This method must be called after the * print_preview.AppState has been initialized. - * @param {?string} systemDefaultDestinationId ID of the system default - * destination. * @private */ - init: function(systemDefaultDestinationId) { + init: function() { if (this.appState_.selectedDestinationId && this.appState_.selectedDestinationOrigin) { this.initialDestinationId_ = this.appState_.selectedDestinationId; this.initialDestinationOrigin_ = this.appState_.selectedDestinationOrigin; - } else if (systemDefaultDestinationId) { - this.initialDestinationId_ = systemDefaultDestinationId; - this.initialDestinationOrigin_ = print_preview.Destination.Origin.LOCAL; } this.isInAutoSelectMode_ = true; if (!this.initialDestinationId_ || !this.initialDestinationOrigin_) { diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js index 3f728ac..ee2f46d 100644 --- a/chrome/browser/resources/print_preview/print_preview.js +++ b/chrome/browser/resources/print_preview/print_preview.js @@ -521,7 +521,9 @@ cr.define('print_preview', function() { this.isInKioskAutoPrintMode_ = settings.isInKioskAutoPrintMode; // The following components must be initialized in this order. - this.appState_.init(settings.serializedAppStateStr); + this.appState_.init( + settings.serializedAppStateStr, + settings.systemDefaultDestinationId); this.documentInfo_.init( settings.isDocumentModifiable, settings.documentTitle, @@ -531,7 +533,7 @@ cr.define('print_preview', function() { settings.decimalDelimeter, settings.unitType, settings.selectionOnly); - this.destinationStore_.init(settings.systemDefaultDestinationId); + this.destinationStore_.init(); this.appState_.setInitialized(); $('document-title').innerText = settings.documentTitle; |