| 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 represent a recent destination in the app state. | 9 * Object used to represent a recent destination in the app state. |
| 10 * @constructor | 10 * @constructor |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 /** | 118 /** |
| 119 * Name of C++ layer function to persist app state. | 119 * Name of C++ layer function to persist app state. |
| 120 * @type {string} | 120 * @type {string} |
| 121 * @const | 121 * @const |
| 122 * @private | 122 * @private |
| 123 */ | 123 */ |
| 124 AppState.NATIVE_FUNCTION_NAME_ = 'saveAppState'; | 124 AppState.NATIVE_FUNCTION_NAME_ = 'saveAppState'; |
| 125 | 125 |
| 126 AppState.prototype = { | 126 AppState.prototype = { |
| 127 | |
| 128 /** | |
| 129 * Helper function to get the most recent destination. | |
| 130 * @return {?RecentDestination} The most recent value of the | |
| 131 * destination. | |
| 132 */ | |
| 133 getSelectedDestination_: function() { | |
| 134 return (this.state_[AppState.Field.RECENT_DESTINATIONS].length > 0) ? | |
| 135 this.state_[AppState.Field.RECENT_DESTINATIONS][0] : null; | |
| 136 }, | |
| 137 | |
| 138 /** @return {?string} ID of the selected destination. */ | |
| 139 get selectedDestinationId() { | |
| 140 return this.getSelectedDestination_ ? | |
| 141 this.getSelectedDestination_.id : null; | |
| 142 }, | |
| 143 | |
| 144 /** @return {?string} Account the selected destination is registered for. */ | |
| 145 get selectedDestinationAccount() { | |
| 146 return this.getSelectedDestination_ ? | |
| 147 this.getSelectedDestination_.account : null; | |
| 148 }, | |
| 149 | |
| 150 /** | |
| 151 * @return {?print_preview.Destination.Origin<string>} Origin of the | |
| 152 * selected destination. | |
| 153 */ | |
| 154 get selectedDestinationOrigin() { | |
| 155 return this.getSelectedDestination_ ? | |
| 156 this.getSelectedDestination_.origin : null; | |
| 157 }, | |
| 158 | |
| 159 /** @return {?print_preview.Cdd} CDD of the selected destination. */ | |
| 160 get selectedDestinationCapabilities() { | |
| 161 return this.getSelectedDestination_ ? | |
| 162 this.getSelectedDestination_.capabilities : null; | |
| 163 }, | |
| 164 | |
| 165 /** @return {?string} Name of the selected destination. */ | |
| 166 get selectedDestinationName() { | |
| 167 return this.getSelectedDestination_ ? | |
| 168 this.getSelectedDestination_.name : null; | |
| 169 }, | |
| 170 | |
| 171 /** | |
| 172 * @return {?string} Extension ID associated with the selected destination. | |
| 173 */ | |
| 174 get selectedDestinationExtensionId() { | |
| 175 return this.getSelectedDestination_ ? | |
| 176 this.getSelectedDestination_.extensionId : null; | |
| 177 }, | |
| 178 | |
| 179 /** | |
| 180 * @return {?string} Extension name associated with the selected | |
| 181 * destination. | |
| 182 */ | |
| 183 get selectedDestinationExtensionName() { | |
| 184 return this.getSelectedDestination_ ? | |
| 185 this.getSelectedDestination_.extensionName : null; | |
| 186 }, | |
| 187 | |
| 188 /** | 127 /** |
| 189 * @return {?RecentDestination} The most recent destination, which is | 128 * @return {?RecentDestination} The most recent destination, which is |
| 190 * currently the selected destination. | 129 * currently the selected destination. |
| 191 */ | 130 */ |
| 192 get selectedDestination() { | 131 get selectedDestination() { |
| 193 return this.getSelectedDestination_; | 132 return (this.state_[AppState.Field.RECENT_DESTINATIONS].length > 0) ? |
| 133 this.state_[AppState.Field.RECENT_DESTINATIONS][0] : null; |
| 194 }, | 134 }, |
| 195 | 135 |
| 196 /** | 136 /** |
| 197 * @return {?Array<!RecentDestination>} The AppState.NUM_DESTINATIONS_ most | 137 * @return {?Array<!RecentDestination>} The AppState.NUM_DESTINATIONS_ most |
| 198 * recent destinations. | 138 * recent destinations. |
| 199 */ | 139 */ |
| 200 get recentDestinations() { | 140 get recentDestinations() { |
| 201 return this.state_[AppState.Field.RECENT_DESTINATIONS]; | 141 return this.state_[AppState.Field.RECENT_DESTINATIONS]; |
| 202 }, | 142 }, |
| 203 | 143 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 persist_: function() { | 289 persist_: function() { |
| 350 chrome.send(AppState.NATIVE_FUNCTION_NAME_, | 290 chrome.send(AppState.NATIVE_FUNCTION_NAME_, |
| 351 [JSON.stringify(this.state_)]); | 291 [JSON.stringify(this.state_)]); |
| 352 } | 292 } |
| 353 }; | 293 }; |
| 354 | 294 |
| 355 return { | 295 return { |
| 356 AppState: AppState | 296 AppState: AppState |
| 357 }; | 297 }; |
| 358 }); | 298 }); |
| OLD | NEW |