Chromium Code Reviews| Index: chrome/browser/resources/print_preview/data/app_state.js |
| diff --git a/chrome/browser/resources/print_preview/data/app_state.js b/chrome/browser/resources/print_preview/data/app_state.js |
| index 9f424d631d6fcbe1b9eb15c4cdb90db8f2a6e09f..360b77124bd49c97289b3155a44b8fe293b4b9b4 100644 |
| --- a/chrome/browser/resources/print_preview/data/app_state.js |
| +++ b/chrome/browser/resources/print_preview/data/app_state.js |
| @@ -35,10 +35,10 @@ cr.define('print_preview', function() { |
| AppState.Field = { |
| VERSION: 'version', |
| SELECTED_DESTINATION_ID: 'selectedDestinationId', |
| + SELECTED_DESTINATION_ACCOUNT: 'selectedDestinationAccount', |
| 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', |
| @@ -73,6 +73,11 @@ cr.define('print_preview', function() { |
| return this.state_[AppState.Field.SELECTED_DESTINATION_ID]; |
| }, |
| + /** @return {?string} Account the selected destination is registered for. */ |
| + get selectedDestinationAccount() { |
| + return this.state_[AppState.Field.SELECTED_DESTINATION_ACCOUNT]; |
| + }, |
| + |
| /** @return {?string} Origin of the selected destination. */ |
| get selectedDestinationOrigin() { |
| return this.state_[AppState.Field.SELECTED_DESTINATION_ORIGIN]; |
| @@ -80,7 +85,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 +125,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] = |
|
Vitaly Buka (NO REVIEWS)
2014/04/11 02:32:57
this could be separate CL
Toscano
2014/04/11 04:24:00
agreed
Aleksey Shlyapnikov
2014/04/11 19:09:29
Done.
Aleksey Shlyapnikov
2014/04/11 19:09:29
Done.
|
| + systemDefaultDestinationId; |
| + this.state_[AppState.Field.SELECTED_DESTINATION_ORIGIN] = |
| + print_preview.Destination.Origin.LOCAL; |
| + } |
| + } |
| }, |
| /** |
| @@ -172,8 +181,9 @@ cr.define('print_preview', function() { |
| if (!this.isInitialized_) |
| return; |
| this.state_[AppState.Field.SELECTED_DESTINATION_ID] = dest.id; |
| + this.state_[AppState.Field.SELECTED_DESTINATION_ACCOUNT] = dest.account; |
| 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_(); |