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

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: 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 * Helper function to get the most recent destination. 130 * Helper function to get the most recent destination.
131 * @return {?RecentDestination} The most recent value of the 131 * @return {?RecentDestination} The most recent value of the
132 * destination. 132 * destination.
133 */ 133 */
134 getSelectedDestination_: function() { 134 getSelectedDestination_: function() {
135 return (this.state_[AppState.Field.RECENT_DESTINATIONS].length > 0) ? 135 return (this.state_[AppState.Field.RECENT_DESTINATIONS].length > 0) ?
136 this.state_[AppState.Field.RECENT_DESTINATIONS][0] : null; 136 this.state_[AppState.Field.RECENT_DESTINATIONS][0] : null;
137 }, 137 },
138 138
139 /** @return {?string} ID of the selected destination. */ 139 /** @return {?string} ID of the selected destination. */
140 get selectedDestinationId() { 140 get selectedDestinationId() {
dpapad 2016/11/18 00:33:20 I am also wondering why are all these getters (lin
rbpotter 2016/11/18 02:59:22 Done. They were here because they were here before
141 return this.getSelectedDestination_ ? 141 return this.getSelectedDestination_() ?
142 this.getSelectedDestination_.id : null; 142 this.getSelectedDestination_().id : null;
143 }, 143 },
144 144
145 /** @return {?string} Account the selected destination is registered for. */ 145 /** @return {?string} Account the selected destination is registered for. */
146 get selectedDestinationAccount() { 146 get selectedDestinationAccount() {
147 return this.getSelectedDestination_ ? 147 return this.getSelectedDestination_() ?
148 this.getSelectedDestination_.account : null; 148 this.getSelectedDestination_().account : null;
149 }, 149 },
150 150
151 /** 151 /**
152 * @return {?print_preview.Destination.Origin<string>} Origin of the 152 * @return {?print_preview.Destination.Origin<string>} Origin of the
153 * selected destination. 153 * selected destination.
154 */ 154 */
155 get selectedDestinationOrigin() { 155 get selectedDestinationOrigin() {
156 return this.getSelectedDestination_ ? 156 return this.getSelectedDestination_() ?
157 this.getSelectedDestination_.origin : null; 157 this.getSelectedDestination_().origin : null;
158 }, 158 },
159 159
160 /** @return {?print_preview.Cdd} CDD of the selected destination. */ 160 /** @return {?print_preview.Cdd} CDD of the selected destination. */
161 get selectedDestinationCapabilities() { 161 get selectedDestinationCapabilities() {
162 return this.getSelectedDestination_ ? 162 return this.getSelectedDestination_() ?
163 this.getSelectedDestination_.capabilities : null; 163 this.getSelectedDestination_().capabilities : null;
164 }, 164 },
165 165
166 /** @return {?string} Name of the selected destination. */ 166 /** @return {?string} Name of the selected destination. */
167 get selectedDestinationName() { 167 get selectedDestinationName() {
168 return this.getSelectedDestination_ ? 168 return this.getSelectedDestination_() ?
169 this.getSelectedDestination_.name : null; 169 this.getSelectedDestination_().name : null;
170 }, 170 },
171 171
172 /** 172 /**
173 * @return {?string} Extension ID associated with the selected destination. 173 * @return {?string} Extension ID associated with the selected destination.
174 */ 174 */
175 get selectedDestinationExtensionId() { 175 get selectedDestinationExtensionId() {
176 return this.getSelectedDestination_ ? 176 return this.getSelectedDestination_() ?
177 this.getSelectedDestination_.extensionId : null; 177 this.getSelectedDestination_().extensionId : null;
178 }, 178 },
179 179
180 /** 180 /**
181 * @return {?string} Extension name associated with the selected 181 * @return {?string} Extension name associated with the selected
182 * destination. 182 * destination.
183 */ 183 */
184 get selectedDestinationExtensionName() { 184 get selectedDestinationExtensionName() {
185 return this.getSelectedDestination_ ? 185 return this.getSelectedDestination_() ?
186 this.getSelectedDestination_.extensionName : null; 186 this.getSelectedDestination_().extensionName : null;
187 }, 187 },
188 188
189 /** 189 /**
190 * @return {?RecentDestination} The most recent destination, which is 190 * @return {?RecentDestination} The most recent destination, which is
191 * currently the selected destination. 191 * currently the selected destination.
192 */ 192 */
193 get selectedDestination() { 193 get selectedDestination() {
194 return this.getSelectedDestination_; 194 return this.getSelectedDestination_();
195 }, 195 },
196 196
197 /** 197 /**
198 * @return {?Array<!RecentDestination>} The AppState.NUM_DESTINATIONS_ most 198 * @return {?Array<!RecentDestination>} The AppState.NUM_DESTINATIONS_ most
199 * recent destinations. 199 * recent destinations.
200 */ 200 */
201 get recentDestinations() { 201 get recentDestinations() {
202 return this.state_[AppState.Field.RECENT_DESTINATIONS]; 202 return this.state_[AppState.Field.RECENT_DESTINATIONS];
203 }, 203 },
204 204
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 this.state_[field] = value; 292 this.state_[field] = value;
293 } 293 }
294 this.persist_(); 294 this.persist_();
295 }, 295 },
296 296
297 /** 297 /**
298 * Persists the selected destination. 298 * Persists the selected destination.
299 * @param {!print_preview.Destination} dest Destination to persist. 299 * @param {!print_preview.Destination} dest Destination to persist.
300 */ 300 */
301 persistSelectedDestination: function(dest) { 301 persistSelectedDestination: function(dest) {
302 if (!this.isInitialized_) 302 if (!this.isInitialized_ || !dest)
dpapad 2016/11/18 00:33:20 Also per the type annotation !print_preview.Destin
rbpotter 2016/11/18 02:59:23 Removed this and updated the place it was getting
303 return; 303 return;
304 304
305 // Determine if this destination is already in the recent destinations, 305 // Determine if this destination is already in the recent destinations,
306 // and where in the array it is located. 306 // and where in the array it is located.
307 var newDestination = new RecentDestination(dest); 307 var newDestination = new RecentDestination(dest);
308 var indexFound = this.state_[ 308 var indexFound = this.state_[
309 AppState.Field.RECENT_DESTINATIONS].findIndex(function(recent) { 309 AppState.Field.RECENT_DESTINATIONS].findIndex(function(recent) {
310 return (newDestination.id == recent.id && 310 return (newDestination.id == recent.id &&
311 newDestination.origin == recent.origin); 311 newDestination.origin == recent.origin);
312 }); 312 });
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 persist_: function() { 353 persist_: function() {
354 chrome.send(AppState.NATIVE_FUNCTION_NAME_, 354 chrome.send(AppState.NATIVE_FUNCTION_NAME_,
355 [JSON.stringify(this.state_)]); 355 [JSON.stringify(this.state_)]);
356 } 356 }
357 }; 357 };
358 358
359 return { 359 return {
360 AppState: AppState 360 AppState: AppState
361 }; 361 };
362 }); 362 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698