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 17 matching lines...) Expand all Loading... |
28 this.isInitialized_ = false; | 28 this.isInitialized_ = false; |
29 }; | 29 }; |
30 | 30 |
31 /** | 31 /** |
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_ORIGIN: 'selectedDestinationOrigin', | 39 SELECTED_DESTINATION_ORIGIN: 'selectedDestinationOrigin', |
39 SELECTED_DESTINATION_CAPABILITIES: 'selectedDestinationCapabilities', | 40 SELECTED_DESTINATION_CAPABILITIES: 'selectedDestinationCapabilities', |
40 SELECTED_DESTINATION_NAME: 'selectedDestinationName', | 41 SELECTED_DESTINATION_NAME: 'selectedDestinationName', |
41 IS_GCP_PROMO_DISMISSED: 'isGcpPromoDismissed', | 42 IS_GCP_PROMO_DISMISSED: 'isGcpPromoDismissed', |
42 MARGINS_TYPE: 'marginsType', | 43 MARGINS_TYPE: 'marginsType', |
43 CUSTOM_MARGINS: 'customMargins', | 44 CUSTOM_MARGINS: 'customMargins', |
44 IS_COLOR_ENABLED: 'isColorEnabled', | 45 IS_COLOR_ENABLED: 'isColorEnabled', |
45 IS_DUPLEX_ENABLED: 'isDuplexEnabled', | 46 IS_DUPLEX_ENABLED: 'isDuplexEnabled', |
46 IS_HEADER_FOOTER_ENABLED: 'isHeaderFooterEnabled', | 47 IS_HEADER_FOOTER_ENABLED: 'isHeaderFooterEnabled', |
47 IS_LANDSCAPE_ENABLED: 'isLandscapeEnabled', | 48 IS_LANDSCAPE_ENABLED: 'isLandscapeEnabled', |
(...skipping 17 matching lines...) Expand all Loading... |
65 * @private | 66 * @private |
66 */ | 67 */ |
67 AppState.NATIVE_FUNCTION_NAME_ = 'saveAppState'; | 68 AppState.NATIVE_FUNCTION_NAME_ = 'saveAppState'; |
68 | 69 |
69 AppState.prototype = { | 70 AppState.prototype = { |
70 /** @return {?string} ID of the selected destination. */ | 71 /** @return {?string} ID of the selected destination. */ |
71 get selectedDestinationId() { | 72 get selectedDestinationId() { |
72 return this.state_[AppState.Field.SELECTED_DESTINATION_ID]; | 73 return this.state_[AppState.Field.SELECTED_DESTINATION_ID]; |
73 }, | 74 }, |
74 | 75 |
| 76 /** @return {?string} Account the selected destination is registered for. */ |
| 77 get selectedDestinationAccount() { |
| 78 return this.state_[AppState.Field.SELECTED_DESTINATION_ACCOUNT]; |
| 79 }, |
| 80 |
75 /** @return {?string} Origin of the selected destination. */ | 81 /** @return {?string} Origin of the selected destination. */ |
76 get selectedDestinationOrigin() { | 82 get selectedDestinationOrigin() { |
77 return this.state_[AppState.Field.SELECTED_DESTINATION_ORIGIN]; | 83 return this.state_[AppState.Field.SELECTED_DESTINATION_ORIGIN]; |
78 }, | 84 }, |
79 | 85 |
80 /** @return {?print_preview.Cdd} CDD of the selected destination. */ | 86 /** @return {?print_preview.Cdd} CDD of the selected destination. */ |
81 get selectedDestinationCapabilities() { | 87 get selectedDestinationCapabilities() { |
82 return this.state_[AppState.Field.SELECTED_DESTINATION_CAPABILITIES]; | 88 return this.state_[AppState.Field.SELECTED_DESTINATION_CAPABILITIES]; |
83 }, | 89 }, |
84 | 90 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 }, | 174 }, |
169 | 175 |
170 /** | 176 /** |
171 * Persists the selected destination. | 177 * Persists the selected destination. |
172 * @param {!print_preview.Destination} dest Destination to persist. | 178 * @param {!print_preview.Destination} dest Destination to persist. |
173 */ | 179 */ |
174 persistSelectedDestination: function(dest) { | 180 persistSelectedDestination: function(dest) { |
175 if (!this.isInitialized_) | 181 if (!this.isInitialized_) |
176 return; | 182 return; |
177 this.state_[AppState.Field.SELECTED_DESTINATION_ID] = dest.id; | 183 this.state_[AppState.Field.SELECTED_DESTINATION_ID] = dest.id; |
| 184 this.state_[AppState.Field.SELECTED_DESTINATION_ACCOUNT] = dest.account; |
178 this.state_[AppState.Field.SELECTED_DESTINATION_ORIGIN] = dest.origin; | 185 this.state_[AppState.Field.SELECTED_DESTINATION_ORIGIN] = dest.origin; |
179 this.state_[AppState.Field.SELECTED_DESTINATION_CAPABILITIES] = | 186 this.state_[AppState.Field.SELECTED_DESTINATION_CAPABILITIES] = |
180 dest.capabilities; | 187 dest.capabilities; |
181 this.state_[AppState.Field.SELECTED_DESTINATION_NAME] = dest.displayName; | 188 this.state_[AppState.Field.SELECTED_DESTINATION_NAME] = dest.displayName; |
182 this.persist_(); | 189 this.persist_(); |
183 }, | 190 }, |
184 | 191 |
185 /** | 192 /** |
186 * Persists whether the GCP promotion has been dismissed. | 193 * Persists whether the GCP promotion has been dismissed. |
187 * @param {boolean} isGcpPromoDismissed Whether the GCP promotion has been | 194 * @param {boolean} isGcpPromoDismissed Whether the GCP promotion has been |
(...skipping 13 matching lines...) Expand all Loading... |
201 persist_: function() { | 208 persist_: function() { |
202 chrome.send(AppState.NATIVE_FUNCTION_NAME_, | 209 chrome.send(AppState.NATIVE_FUNCTION_NAME_, |
203 [JSON.stringify(this.state_)]); | 210 [JSON.stringify(this.state_)]); |
204 } | 211 } |
205 }; | 212 }; |
206 | 213 |
207 return { | 214 return { |
208 AppState: AppState | 215 AppState: AppState |
209 }; | 216 }; |
210 }); | 217 }); |
OLD | NEW |