| 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 22 matching lines...) Expand all Loading... |
| 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 SELECTED_DESTINATION_EXTENSION_ID: 'selectedDestinationExtensionId', |
| 43 SELECTED_DESTINATION_EXTENSION_NAME: 'selectedDestinationExtensionName', |
| 43 IS_GCP_PROMO_DISMISSED: 'isGcpPromoDismissed', | 44 IS_GCP_PROMO_DISMISSED: 'isGcpPromoDismissed', |
| 44 DPI: 'dpi', | 45 DPI: 'dpi', |
| 45 MEDIA_SIZE: 'mediaSize', | 46 MEDIA_SIZE: 'mediaSize', |
| 46 MARGINS_TYPE: 'marginsType', | 47 MARGINS_TYPE: 'marginsType', |
| 47 CUSTOM_MARGINS: 'customMargins', | 48 CUSTOM_MARGINS: 'customMargins', |
| 48 IS_COLOR_ENABLED: 'isColorEnabled', | 49 IS_COLOR_ENABLED: 'isColorEnabled', |
| 49 IS_DUPLEX_ENABLED: 'isDuplexEnabled', | 50 IS_DUPLEX_ENABLED: 'isDuplexEnabled', |
| 50 IS_HEADER_FOOTER_ENABLED: 'isHeaderFooterEnabled', | 51 IS_HEADER_FOOTER_ENABLED: 'isHeaderFooterEnabled', |
| 51 IS_LANDSCAPE_ENABLED: 'isLandscapeEnabled', | 52 IS_LANDSCAPE_ENABLED: 'isLandscapeEnabled', |
| 52 IS_COLLATE_ENABLED: 'isCollateEnabled', | 53 IS_COLLATE_ENABLED: 'isCollateEnabled', |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 return this.state_[AppState.Field.SELECTED_DESTINATION_NAME]; | 101 return this.state_[AppState.Field.SELECTED_DESTINATION_NAME]; |
| 101 }, | 102 }, |
| 102 | 103 |
| 103 /** | 104 /** |
| 104 * @return {?string} Extension ID associated with the selected destination. | 105 * @return {?string} Extension ID associated with the selected destination. |
| 105 */ | 106 */ |
| 106 get selectedDestinationExtensionId() { | 107 get selectedDestinationExtensionId() { |
| 107 return this.state_[AppState.Field.SELECTED_DESTINATION_EXTENSION_ID]; | 108 return this.state_[AppState.Field.SELECTED_DESTINATION_EXTENSION_ID]; |
| 108 }, | 109 }, |
| 109 | 110 |
| 111 /** |
| 112 * @return {?string} Extension name associated with the selected |
| 113 * destination. |
| 114 */ |
| 115 get selectedDestinationExtensionName() { |
| 116 return this.state_[AppState.Field.SELECTED_DESTINATION_EXTENSION_NAME]; |
| 117 }, |
| 118 |
| 110 /** @return {boolean} Whether the GCP promotion has been dismissed. */ | 119 /** @return {boolean} Whether the GCP promotion has been dismissed. */ |
| 111 get isGcpPromoDismissed() { | 120 get isGcpPromoDismissed() { |
| 112 return this.state_[AppState.Field.IS_GCP_PROMO_DISMISSED]; | 121 return this.state_[AppState.Field.IS_GCP_PROMO_DISMISSED]; |
| 113 }, | 122 }, |
| 114 | 123 |
| 115 /** | 124 /** |
| 116 * @param {!print_preview.AppState.Field} field App state field to check if | 125 * @param {!print_preview.AppState.Field} field App state field to check if |
| 117 * set. | 126 * set. |
| 118 * @return {boolean} Whether a field has been set in the app state. | 127 * @return {boolean} Whether a field has been set in the app state. |
| 119 */ | 128 */ |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 if (!this.isInitialized_) | 205 if (!this.isInitialized_) |
| 197 return; | 206 return; |
| 198 this.state_[AppState.Field.SELECTED_DESTINATION_ID] = dest.id; | 207 this.state_[AppState.Field.SELECTED_DESTINATION_ID] = dest.id; |
| 199 this.state_[AppState.Field.SELECTED_DESTINATION_ACCOUNT] = dest.account; | 208 this.state_[AppState.Field.SELECTED_DESTINATION_ACCOUNT] = dest.account; |
| 200 this.state_[AppState.Field.SELECTED_DESTINATION_ORIGIN] = dest.origin; | 209 this.state_[AppState.Field.SELECTED_DESTINATION_ORIGIN] = dest.origin; |
| 201 this.state_[AppState.Field.SELECTED_DESTINATION_CAPABILITIES] = | 210 this.state_[AppState.Field.SELECTED_DESTINATION_CAPABILITIES] = |
| 202 dest.capabilities; | 211 dest.capabilities; |
| 203 this.state_[AppState.Field.SELECTED_DESTINATION_NAME] = dest.displayName; | 212 this.state_[AppState.Field.SELECTED_DESTINATION_NAME] = dest.displayName; |
| 204 this.state_[AppState.Field.SELECTED_DESTINATION_EXTENSION_ID] = | 213 this.state_[AppState.Field.SELECTED_DESTINATION_EXTENSION_ID] = |
| 205 dest.extensionId; | 214 dest.extensionId; |
| 215 this.state_[AppState.Field.SELECTED_DESTINATION_EXTENSION_NAME] = |
| 216 dest.extensionName; |
| 206 this.persist_(); | 217 this.persist_(); |
| 207 }, | 218 }, |
| 208 | 219 |
| 209 /** | 220 /** |
| 210 * Persists whether the GCP promotion has been dismissed. | 221 * Persists whether the GCP promotion has been dismissed. |
| 211 * @param {boolean} isGcpPromoDismissed Whether the GCP promotion has been | 222 * @param {boolean} isGcpPromoDismissed Whether the GCP promotion has been |
| 212 * dismissed. | 223 * dismissed. |
| 213 */ | 224 */ |
| 214 persistIsGcpPromoDismissed: function(isGcpPromoDismissed) { | 225 persistIsGcpPromoDismissed: function(isGcpPromoDismissed) { |
| 215 if (!this.isInitialized_) | 226 if (!this.isInitialized_) |
| 216 return; | 227 return; |
| 217 this.state_[AppState.Field.IS_GCP_PROMO_DISMISSED] = isGcpPromoDismissed; | 228 this.state_[AppState.Field.IS_GCP_PROMO_DISMISSED] = isGcpPromoDismissed; |
| 218 this.persist_(); | 229 this.persist_(); |
| 219 }, | 230 }, |
| 220 | 231 |
| 221 /** | 232 /** |
| 222 * Calls into the native layer to persist the application state. | 233 * Calls into the native layer to persist the application state. |
| 223 * @private | 234 * @private |
| 224 */ | 235 */ |
| 225 persist_: function() { | 236 persist_: function() { |
| 226 chrome.send(AppState.NATIVE_FUNCTION_NAME_, | 237 chrome.send(AppState.NATIVE_FUNCTION_NAME_, |
| 227 [JSON.stringify(this.state_)]); | 238 [JSON.stringify(this.state_)]); |
| 228 } | 239 } |
| 229 }; | 240 }; |
| 230 | 241 |
| 231 return { | 242 return { |
| 232 AppState: AppState | 243 AppState: AppState |
| 233 }; | 244 }; |
| 234 }); | 245 }); |
| OLD | NEW |