| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Object used to get and persist the print preview application state. | 9 * Object used to get and persist the print preview application state. |
| 10 * @constructor | 10 * @constructor |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 * Enumeration of field names for serialized app state. | 32 * Enumeration of field names for serialized app state. |
| 33 * @enum {string} | 33 * @enum {string} |
| 34 */ | 34 */ |
| 35 AppState.Field = { | 35 AppState.Field = { |
| 36 VERSION: 'version', | 36 VERSION: 'version', |
| 37 SELECTED_DESTINATION_ID: 'selectedDestinationId', | 37 SELECTED_DESTINATION_ID: 'selectedDestinationId', |
| 38 SELECTED_DESTINATION_ACCOUNT: 'selectedDestinationAccount', | 38 SELECTED_DESTINATION_ACCOUNT: 'selectedDestinationAccount', |
| 39 SELECTED_DESTINATION_ORIGIN: 'selectedDestinationOrigin', | 39 SELECTED_DESTINATION_ORIGIN: 'selectedDestinationOrigin', |
| 40 SELECTED_DESTINATION_CAPABILITIES: 'selectedDestinationCapabilities', | 40 SELECTED_DESTINATION_CAPABILITIES: 'selectedDestinationCapabilities', |
| 41 SELECTED_DESTINATION_NAME: 'selectedDestinationName', | 41 SELECTED_DESTINATION_NAME: 'selectedDestinationName', |
| 42 SELECTED_DESTINATION_EXTENSION_ID: 'selectedDestinationExtensionId', |
| 42 IS_GCP_PROMO_DISMISSED: 'isGcpPromoDismissed', | 43 IS_GCP_PROMO_DISMISSED: 'isGcpPromoDismissed', |
| 43 DPI: 'dpi', | 44 DPI: 'dpi', |
| 44 MEDIA_SIZE: 'mediaSize', | 45 MEDIA_SIZE: 'mediaSize', |
| 45 MARGINS_TYPE: 'marginsType', | 46 MARGINS_TYPE: 'marginsType', |
| 46 CUSTOM_MARGINS: 'customMargins', | 47 CUSTOM_MARGINS: 'customMargins', |
| 47 IS_COLOR_ENABLED: 'isColorEnabled', | 48 IS_COLOR_ENABLED: 'isColorEnabled', |
| 48 IS_DUPLEX_ENABLED: 'isDuplexEnabled', | 49 IS_DUPLEX_ENABLED: 'isDuplexEnabled', |
| 49 IS_HEADER_FOOTER_ENABLED: 'isHeaderFooterEnabled', | 50 IS_HEADER_FOOTER_ENABLED: 'isHeaderFooterEnabled', |
| 50 IS_LANDSCAPE_ENABLED: 'isLandscapeEnabled', | 51 IS_LANDSCAPE_ENABLED: 'isLandscapeEnabled', |
| 51 IS_COLLATE_ENABLED: 'isCollateEnabled', | 52 IS_COLLATE_ENABLED: 'isCollateEnabled', |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 /** @return {?print_preview.Cdd} CDD of the selected destination. */ | 93 /** @return {?print_preview.Cdd} CDD of the selected destination. */ |
| 93 get selectedDestinationCapabilities() { | 94 get selectedDestinationCapabilities() { |
| 94 return this.state_[AppState.Field.SELECTED_DESTINATION_CAPABILITIES]; | 95 return this.state_[AppState.Field.SELECTED_DESTINATION_CAPABILITIES]; |
| 95 }, | 96 }, |
| 96 | 97 |
| 97 /** @return {?string} Name of the selected destination. */ | 98 /** @return {?string} Name of the selected destination. */ |
| 98 get selectedDestinationName() { | 99 get selectedDestinationName() { |
| 99 return this.state_[AppState.Field.SELECTED_DESTINATION_NAME]; | 100 return this.state_[AppState.Field.SELECTED_DESTINATION_NAME]; |
| 100 }, | 101 }, |
| 101 | 102 |
| 103 /** |
| 104 * @return {?string} Extension ID associated with the selected destination. |
| 105 */ |
| 106 get selectedDestinationExtensionId() { |
| 107 return this.state_[AppState.Field.SELECTED_DESTINATION_EXTENSION_ID]; |
| 108 }, |
| 109 |
| 102 /** @return {boolean} Whether the GCP promotion has been dismissed. */ | 110 /** @return {boolean} Whether the GCP promotion has been dismissed. */ |
| 103 get isGcpPromoDismissed() { | 111 get isGcpPromoDismissed() { |
| 104 return this.state_[AppState.Field.IS_GCP_PROMO_DISMISSED]; | 112 return this.state_[AppState.Field.IS_GCP_PROMO_DISMISSED]; |
| 105 }, | 113 }, |
| 106 | 114 |
| 107 /** | 115 /** |
| 108 * @param {!print_preview.AppState.Field} field App state field to check if | 116 * @param {!print_preview.AppState.Field} field App state field to check if |
| 109 * set. | 117 * set. |
| 110 * @return {boolean} Whether a field has been set in the app state. | 118 * @return {boolean} Whether a field has been set in the app state. |
| 111 */ | 119 */ |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 */ | 194 */ |
| 187 persistSelectedDestination: function(dest) { | 195 persistSelectedDestination: function(dest) { |
| 188 if (!this.isInitialized_) | 196 if (!this.isInitialized_) |
| 189 return; | 197 return; |
| 190 this.state_[AppState.Field.SELECTED_DESTINATION_ID] = dest.id; | 198 this.state_[AppState.Field.SELECTED_DESTINATION_ID] = dest.id; |
| 191 this.state_[AppState.Field.SELECTED_DESTINATION_ACCOUNT] = dest.account; | 199 this.state_[AppState.Field.SELECTED_DESTINATION_ACCOUNT] = dest.account; |
| 192 this.state_[AppState.Field.SELECTED_DESTINATION_ORIGIN] = dest.origin; | 200 this.state_[AppState.Field.SELECTED_DESTINATION_ORIGIN] = dest.origin; |
| 193 this.state_[AppState.Field.SELECTED_DESTINATION_CAPABILITIES] = | 201 this.state_[AppState.Field.SELECTED_DESTINATION_CAPABILITIES] = |
| 194 dest.capabilities; | 202 dest.capabilities; |
| 195 this.state_[AppState.Field.SELECTED_DESTINATION_NAME] = dest.displayName; | 203 this.state_[AppState.Field.SELECTED_DESTINATION_NAME] = dest.displayName; |
| 204 this.state_[AppState.Field.SELECTED_DESTINATION_EXTENSION_ID] = |
| 205 dest.extensionId; |
| 196 this.persist_(); | 206 this.persist_(); |
| 197 }, | 207 }, |
| 198 | 208 |
| 199 /** | 209 /** |
| 200 * Persists whether the GCP promotion has been dismissed. | 210 * Persists whether the GCP promotion has been dismissed. |
| 201 * @param {boolean} isGcpPromoDismissed Whether the GCP promotion has been | 211 * @param {boolean} isGcpPromoDismissed Whether the GCP promotion has been |
| 202 * dismissed. | 212 * dismissed. |
| 203 */ | 213 */ |
| 204 persistIsGcpPromoDismissed: function(isGcpPromoDismissed) { | 214 persistIsGcpPromoDismissed: function(isGcpPromoDismissed) { |
| 205 if (!this.isInitialized_) | 215 if (!this.isInitialized_) |
| 206 return; | 216 return; |
| 207 this.state_[AppState.Field.IS_GCP_PROMO_DISMISSED] = isGcpPromoDismissed; | 217 this.state_[AppState.Field.IS_GCP_PROMO_DISMISSED] = isGcpPromoDismissed; |
| 208 this.persist_(); | 218 this.persist_(); |
| 209 }, | 219 }, |
| 210 | 220 |
| 211 /** | 221 /** |
| 212 * Calls into the native layer to persist the application state. | 222 * Calls into the native layer to persist the application state. |
| 213 * @private | 223 * @private |
| 214 */ | 224 */ |
| 215 persist_: function() { | 225 persist_: function() { |
| 216 chrome.send(AppState.NATIVE_FUNCTION_NAME_, | 226 chrome.send(AppState.NATIVE_FUNCTION_NAME_, |
| 217 [JSON.stringify(this.state_)]); | 227 [JSON.stringify(this.state_)]); |
| 218 } | 228 } |
| 219 }; | 229 }; |
| 220 | 230 |
| 221 return { | 231 return { |
| 222 AppState: AppState | 232 AppState: AppState |
| 223 }; | 233 }; |
| 224 }); | 234 }); |
| OLD | NEW |