Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: chrome/browser/resources/print_preview/data/app_state.js

Issue 2516523002: Fix CrOS reverting to Save as PDF and random PDF preview fail (Closed)
Patch Set: Add helper Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 /** 119 /**
120 * Name of C++ layer function to persist app state. 120 * Name of C++ layer function to persist app state.
121 * @type {string} 121 * @type {string}
122 * @const 122 * @const
123 * @private 123 * @private
124 */ 124 */
125 AppState.NATIVE_FUNCTION_NAME_ = 'saveAppState'; 125 AppState.NATIVE_FUNCTION_NAME_ = 'saveAppState';
126 126
127 AppState.prototype = { 127 AppState.prototype = {
128
129 /**
130 * Helper function to get the most recent destination.
131 * @return {?RecentDestination} The most recent value of the
132 * destination.
133 */
134 getSelectedDestination_: function() {
135 return (this.state_[AppState.Field.RECENT_DESTINATIONS].length > 0) ?
136 this.state_[AppState.Field.RECENT_DESTINATIONS][0] : null;
137 },
138
139 /** @return {?string} ID of the selected destination. */
140 get selectedDestinationId() {
141 return this.getSelectedDestination_ ?
142 this.getSelectedDestination_.id : null;
143 },
144
145 /** @return {?string} Account the selected destination is registered for. */
146 get selectedDestinationAccount() {
147 return this.getSelectedDestination_ ?
148 this.getSelectedDestination_.account : null;
149 },
150
151 /**
152 * @return {?print_preview.Destination.Origin<string>} Origin of the
153 * selected destination.
154 */
155 get selectedDestinationOrigin() {
156 return this.getSelectedDestination_ ?
157 this.getSelectedDestination_.origin : null;
158 },
159
160 /** @return {?print_preview.Cdd} CDD of the selected destination. */
161 get selectedDestinationCapabilities() {
162 return this.getSelectedDestination_ ?
163 this.getSelectedDestination_.capabilities : null;
164 },
165
166 /** @return {?string} Name of the selected destination. */
167 get selectedDestinationName() {
168 return this.getSelectedDestination_ ?
169 this.getSelectedDestination_.name : null;
170 },
171
172 /**
173 * @return {?string} Extension ID associated with the selected destination.
174 */
175 get selectedDestinationExtensionId() {
176 return this.getSelectedDestination_ ?
177 this.getSelectedDestination_.extensionId : null;
178 },
179
180 /**
181 * @return {?string} Extension name associated with the selected
182 * destination.
183 */
184 get selectedDestinationExtensionName() {
185 return this.getSelectedDestination_ ?
186 this.getSelectedDestination_.extensionName : null;
187 },
188
189 /** 128 /**
190 * @return {?RecentDestination} The most recent destination, which is 129 * @return {?RecentDestination} The most recent destination, which is
191 * currently the selected destination. 130 * currently the selected destination.
192 */ 131 */
193 get selectedDestination() { 132 get selectedDestination() {
194 return this.getSelectedDestination_; 133 return (this.state_[AppState.Field.RECENT_DESTINATIONS].length > 0) ?
134 this.state_[AppState.Field.RECENT_DESTINATIONS][0] : null;
195 }, 135 },
196 136
197 /** 137 /**
198 * @return {?Array<!RecentDestination>} The AppState.NUM_DESTINATIONS_ most 138 * @return {?Array<!RecentDestination>} The AppState.NUM_DESTINATIONS_ most
199 * recent destinations. 139 * recent destinations.
200 */ 140 */
201 get recentDestinations() { 141 get recentDestinations() {
202 return this.state_[AppState.Field.RECENT_DESTINATIONS]; 142 return this.state_[AppState.Field.RECENT_DESTINATIONS];
203 }, 143 },
204 144
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 persist_: function() { 293 persist_: function() {
354 chrome.send(AppState.NATIVE_FUNCTION_NAME_, 294 chrome.send(AppState.NATIVE_FUNCTION_NAME_,
355 [JSON.stringify(this.state_)]); 295 [JSON.stringify(this.state_)]);
356 } 296 }
357 }; 297 };
358 298
359 return { 299 return {
360 AppState: AppState 300 AppState: AppState
361 }; 301 };
362 }); 302 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698