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

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

Issue 588713002: Compile print_preview, part 3: reduce down to 185 errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@I_print_preview_2
Patch Set: fix assert Created 6 years, 2 months 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 get and persist the print preview application state. 9 * Object used to get and persist the print preview application state.
10 * @constructor 10 * @constructor
11 */ 11 */
12 function AppState() { 12 function AppState() {
13 /** 13 /**
14 * Internal representation of application state. 14 * Internal representation of application state.
15 * @type {Object.<string: Object>} 15 * @type {Object}
16 * @private 16 * @private
17 */ 17 */
18 this.state_ = {}; 18 this.state_ = {};
19 this.state_[AppState.Field.VERSION] = AppState.VERSION_; 19 this.state_[AppState.Field.VERSION] = AppState.VERSION_;
20 this.state_[AppState.Field.IS_GCP_PROMO_DISMISSED] = true; 20 this.state_[AppState.Field.IS_GCP_PROMO_DISMISSED] = true;
21 21
22 /** 22 /**
23 * Whether the app state has been initialized. The app state will ignore all 23 * Whether the app state has been initialized. The app state will ignore all
24 * writes until it has been initialized. 24 * writes until it has been initialized.
25 * @type {boolean} 25 * @type {boolean}
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 /** @return {?string} ID of the selected destination. */ 73 /** @return {?string} ID of the selected destination. */
74 get selectedDestinationId() { 74 get selectedDestinationId() {
75 return this.state_[AppState.Field.SELECTED_DESTINATION_ID]; 75 return this.state_[AppState.Field.SELECTED_DESTINATION_ID];
76 }, 76 },
77 77
78 /** @return {?string} Account the selected destination is registered for. */ 78 /** @return {?string} Account the selected destination is registered for. */
79 get selectedDestinationAccount() { 79 get selectedDestinationAccount() {
80 return this.state_[AppState.Field.SELECTED_DESTINATION_ACCOUNT]; 80 return this.state_[AppState.Field.SELECTED_DESTINATION_ACCOUNT];
81 }, 81 },
82 82
83 /** @return {?string} Origin of the selected destination. */ 83 /**
84 * @return {?print_preview.Destination.Origin.<string>} Origin of the
85 * selected destination.
86 */
84 get selectedDestinationOrigin() { 87 get selectedDestinationOrigin() {
85 return this.state_[AppState.Field.SELECTED_DESTINATION_ORIGIN]; 88 return this.state_[AppState.Field.SELECTED_DESTINATION_ORIGIN];
86 }, 89 },
87 90
88 /** @return {?print_preview.Cdd} CDD of the selected destination. */ 91 /** @return {?print_preview.Cdd} CDD of the selected destination. */
89 get selectedDestinationCapabilities() { 92 get selectedDestinationCapabilities() {
90 return this.state_[AppState.Field.SELECTED_DESTINATION_CAPABILITIES]; 93 return this.state_[AppState.Field.SELECTED_DESTINATION_CAPABILITIES];
91 }, 94 },
92 95
93 /** @return {?string} Name of the selected destination. */ 96 /** @return {?string} Name of the selected destination. */
(...skipping 10 matching lines...) Expand all
104 * @param {!print_preview.AppState.Field} field App state field to check if 107 * @param {!print_preview.AppState.Field} field App state field to check if
105 * set. 108 * set.
106 * @return {boolean} Whether a field has been set in the app state. 109 * @return {boolean} Whether a field has been set in the app state.
107 */ 110 */
108 hasField: function(field) { 111 hasField: function(field) {
109 return this.state_.hasOwnProperty(field); 112 return this.state_.hasOwnProperty(field);
110 }, 113 },
111 114
112 /** 115 /**
113 * @param {!print_preview.AppState.Field} field App state field to get. 116 * @param {!print_preview.AppState.Field} field App state field to get.
114 * @return {Object} Value of the app state field. 117 * @return {?} Value of the app state field.
115 */ 118 */
116 getField: function(field) { 119 getField: function(field) {
117 if (field == AppState.Field.CUSTOM_MARGINS) { 120 if (field == AppState.Field.CUSTOM_MARGINS) {
118 return this.state_[field] ? 121 return this.state_[field] ?
119 print_preview.Margins.parse(this.state_[field]) : null; 122 print_preview.Margins.parse(this.state_[field]) : null;
120 } else { 123 } else {
121 return this.state_[field]; 124 return this.state_[field];
122 } 125 }
123 }, 126 },
124 127
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 /** 159 /**
157 * Sets to initialized state. Now object will accept persist requests. 160 * Sets to initialized state. Now object will accept persist requests.
158 */ 161 */
159 setInitialized: function() { 162 setInitialized: function() {
160 this.isInitialized_ = true; 163 this.isInitialized_ = true;
161 }, 164 },
162 165
163 /** 166 /**
164 * Persists the given value for the given field. 167 * Persists the given value for the given field.
165 * @param {!print_preview.AppState.Field} field Field to persist. 168 * @param {!print_preview.AppState.Field} field Field to persist.
166 * @param {Object} value Value of field to persist. 169 * @param {?} value Value of field to persist.
167 */ 170 */
168 persistField: function(field, value) { 171 persistField: function(field, value) {
169 if (!this.isInitialized_) 172 if (!this.isInitialized_)
170 return; 173 return;
171 if (field == AppState.Field.CUSTOM_MARGINS) { 174 if (field == AppState.Field.CUSTOM_MARGINS) {
172 this.state_[field] = value ? value.serialize() : null; 175 this.state_[field] = value ? value.serialize() : null;
173 } else { 176 } else {
174 this.state_[field] = value; 177 this.state_[field] = value;
175 } 178 }
176 this.persist_(); 179 this.persist_();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 persist_: function() { 214 persist_: function() {
212 chrome.send(AppState.NATIVE_FUNCTION_NAME_, 215 chrome.send(AppState.NATIVE_FUNCTION_NAME_,
213 [JSON.stringify(this.state_)]); 216 [JSON.stringify(this.state_)]);
214 } 217 }
215 }; 218 };
216 219
217 return { 220 return {
218 AppState: AppState 221 AppState: AppState
219 }; 222 };
220 }); 223 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698