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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 this.isCssBackgroundEnabled_ = null; | 88 this.isCssBackgroundEnabled_ = null; |
89 }; | 89 }; |
90 | 90 |
91 /** | 91 /** |
92 * Current version of the app state. This value helps to understand how to | 92 * Current version of the app state. This value helps to understand how to |
93 * parse earlier versions of the app state. | 93 * parse earlier versions of the app state. |
94 * @type {number} | 94 * @type {number} |
95 * @const | 95 * @const |
96 * @private | 96 * @private |
97 */ | 97 */ |
98 AppState.VERSION_ = 2; | 98 AppState.VERSION_ = 3; |
99 | 99 |
100 /** | 100 /** |
101 * Enumeration of field names for serialized app state. | 101 * Enumeration of field names for serialized app state. |
102 * @enum {string} | 102 * @enum {string} |
103 * @private | 103 * @private |
104 */ | 104 */ |
105 AppState.Field_ = { | 105 AppState.Field_ = { |
106 VERSION: 'version', | 106 VERSION: 'version', |
107 SELECTED_DESTINATION_ID: 'selectedDestinationId', | 107 SELECTED_DESTINATION_ID: 'selectedDestinationId', |
108 SELECTED_DESTINATION_ORIGIN: 'selectedDestinationOrigin', | 108 SELECTED_DESTINATION_ORIGIN: 'selectedDestinationOrigin', |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 if (!serializedAppStateStr) { | 192 if (!serializedAppStateStr) { |
193 // Set some state defaults. | 193 // Set some state defaults. |
194 this.isGcpPromoDismissed_ = false; | 194 this.isGcpPromoDismissed_ = false; |
195 return; | 195 return; |
196 } | 196 } |
197 | 197 |
198 var state = JSON.parse(serializedAppStateStr); | 198 var state = JSON.parse(serializedAppStateStr); |
199 if (state[AppState.Field_.VERSION] == AppState.VERSION_) { | 199 if (state[AppState.Field_.VERSION] == AppState.VERSION_) { |
200 this.selectedDestinationId_ = | 200 this.selectedDestinationId_ = |
201 state[AppState.Field_.SELECTED_DESTINATION_ID] || null; | 201 state[AppState.Field_.SELECTED_DESTINATION_ID] || null; |
| 202 state[AppState.Field_.SELECTED_DESTINATION_ORIGIN] || null; |
202 if (state.hasOwnProperty( | 203 if (state.hasOwnProperty( |
203 AppState.Field_.IS_SELECTED_DESTINATION_LOCAL)) { | 204 AppState.Field_.IS_SELECTED_DESTINATION_LOCAL)) { |
204 this.selectedDestinationOrigin_ = | 205 this.selectedDestinationOrigin_ = |
205 state[AppState.Field_.IS_SELECTED_DESTINATION_LOCAL] ? | 206 state[AppState.Field_.IS_SELECTED_DESTINATION_LOCAL] ? |
206 print_preview.Destination.Origin.LOCAL : | 207 print_preview.Destination.Origin.LOCAL : |
207 print_preview.Destination.Origin.COOKIES; | 208 print_preview.Destination.Origin.COOKIES; |
208 } else { | 209 } else { |
209 this.selectedDestinationOrigin_ = | 210 this.selectedDestinationOrigin_ = |
210 state[AppState.Field_.SELECTED_DESTINATION_ORIGIN] || null; | 211 state[AppState.Field_.SELECTED_DESTINATION_ORIGIN] || null; |
211 } | 212 } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 obj[AppState.Field_.IS_CSS_BACKGROUND_ENABLED] = | 363 obj[AppState.Field_.IS_CSS_BACKGROUND_ENABLED] = |
363 this.isCssBackgroundEnabled_; | 364 this.isCssBackgroundEnabled_; |
364 chrome.send(AppState.NATIVE_FUNCTION_NAME_, [JSON.stringify(obj)]); | 365 chrome.send(AppState.NATIVE_FUNCTION_NAME_, [JSON.stringify(obj)]); |
365 } | 366 } |
366 }; | 367 }; |
367 | 368 |
368 return { | 369 return { |
369 AppState: AppState | 370 AppState: AppState |
370 }; | 371 }; |
371 }); | 372 }); |
OLD | NEW |