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

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

Issue 11194020: Creates GCP promo for ChromeOS users with no cloud printers. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Removes extraneous comma. Created 8 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
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 * @private 65 * @private
66 */ 66 */
67 this.isLandscapeEnabled_ = null; 67 this.isLandscapeEnabled_ = null;
68 68
69 /** 69 /**
70 * Whether printing collation is enabled. 70 * Whether printing collation is enabled.
71 * @type {?boolean} 71 * @type {?boolean}
72 * @private 72 * @private
73 */ 73 */
74 this.isCollateEnabled_ = null; 74 this.isCollateEnabled_ = null;
75
76 /**
77 * Whether the GCP promotion has been dismissed.
78 * @type {boolean}
79 * @private
80 */
81 this.isGcpPromoDismissed_ = true;
ydolgov1 2012/10/16 21:44:54 Why is it true by default? Should we initialize it
ydolgov1 2012/10/16 21:44:54 And also can you move it closer to selectedDestina
Toscano 2012/10/16 22:24:14 I'd like to keep the default behavior to not show
Toscano 2012/10/16 22:24:14 Done.
75 }; 82 };
76 83
77 /** 84 /**
78 * Current version of the app state. This value helps to understand how to 85 * Current version of the app state. This value helps to understand how to
79 * parse earlier versions of the app state. 86 * parse earlier versions of the app state.
80 * @type {number} 87 * @type {number}
81 * @const 88 * @const
82 * @private 89 * @private
83 */ 90 */
84 AppState.VERSION_ = 2; 91 AppState.VERSION_ = 2;
85 92
86 /** 93 /**
87 * Enumeration of field names for serialized app state. 94 * Enumeration of field names for serialized app state.
88 * @enum {string} 95 * @enum {string}
89 * @private 96 * @private
90 */ 97 */
91 AppState.Field_ = { 98 AppState.Field_ = {
92 VERSION: 'version', 99 VERSION: 'version',
93 SELECTED_DESTINATION_ID: 'selectedDestinationId', 100 SELECTED_DESTINATION_ID: 'selectedDestinationId',
94 IS_SELECTED_DESTINATION_LOCAL: 'isSelectedDestinationLocal', 101 IS_SELECTED_DESTINATION_LOCAL: 'isSelectedDestinationLocal',
95 MARGINS_TYPE: 'marginsType', 102 MARGINS_TYPE: 'marginsType',
96 CUSTOM_MARGINS: 'customMargins', 103 CUSTOM_MARGINS: 'customMargins',
97 IS_COLOR_ENABLED: 'isColorEnabled', 104 IS_COLOR_ENABLED: 'isColorEnabled',
98 IS_DUPLEX_ENABLED: 'isDuplexEnabled', 105 IS_DUPLEX_ENABLED: 'isDuplexEnabled',
99 IS_HEADER_FOOTER_ENABLED: 'isHeaderFooterEnabled', 106 IS_HEADER_FOOTER_ENABLED: 'isHeaderFooterEnabled',
100 IS_LANDSCAPE_ENABLED: 'isLandscapeEnabled', 107 IS_LANDSCAPE_ENABLED: 'isLandscapeEnabled',
101 IS_COLLATE_ENABLED: 'isCollateEnabled' 108 IS_COLLATE_ENABLED: 'isCollateEnabled',
109 IS_GCP_PROMO_DISMISSED: 'isGcpPromoDismissed'
102 }; 110 };
103 111
104 /** 112 /**
105 * Name of C++ layer function to persist app state. 113 * Name of C++ layer function to persist app state.
106 * @type {string} 114 * @type {string}
107 * @const 115 * @const
108 * @private 116 * @private
109 */ 117 */
110 AppState.NATIVE_FUNCTION_NAME_ = 'saveAppState'; 118 AppState.NATIVE_FUNCTION_NAME_ = 'saveAppState';
111 119
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 /** @return {?boolean} Whether landscape page orientation is selected. */ 156 /** @return {?boolean} Whether landscape page orientation is selected. */
149 get isLandscapeEnabled() { 157 get isLandscapeEnabled() {
150 return this.isLandscapeEnabled_; 158 return this.isLandscapeEnabled_;
151 }, 159 },
152 160
153 /** @return {?boolean} Whether printing collation is enabled. */ 161 /** @return {?boolean} Whether printing collation is enabled. */
154 get isCollateEnabled() { 162 get isCollateEnabled() {
155 return this.isCollateEnabled_; 163 return this.isCollateEnabled_;
156 }, 164 },
157 165
166 /** @return {boolean} Whether the GCP promotion has been dismissed. */
ydolgov1 2012/10/16 22:43:17 Can you also move this one closer to isSelectedDes
Toscano 2012/10/16 22:58:44 Done.
167 get isGcpPromoDismissed() {
168 return this.isGcpPromoDismissed_;
169 },
170
158 /** 171 /**
159 * Initializes the app state from a serialized string returned by the native 172 * Initializes the app state from a serialized string returned by the native
160 * layer. 173 * layer.
161 * @param {?string} serializedAppStateStr Serialized string representation 174 * @param {?string} serializedAppStateStr Serialized string representation
162 * of the app state. 175 * of the app state.
163 */ 176 */
164 init: function(serializedAppStateStr) { 177 init: function(serializedAppStateStr) {
165 if (!serializedAppStateStr) { 178 if (!serializedAppStateStr) {
166 return; 179 return;
167 } 180 }
(...skipping 24 matching lines...) Expand all
192 this.isHeaderFooterEnabled_ = 205 this.isHeaderFooterEnabled_ =
193 state[AppState.Field_.IS_HEADER_FOOTER_ENABLED]; 206 state[AppState.Field_.IS_HEADER_FOOTER_ENABLED];
194 } 207 }
195 if (state.hasOwnProperty(AppState.Field_.IS_LANDSCAPE_ENABLED)) { 208 if (state.hasOwnProperty(AppState.Field_.IS_LANDSCAPE_ENABLED)) {
196 this.isLandscapeEnabled_ = 209 this.isLandscapeEnabled_ =
197 state[AppState.Field_.IS_LANDSCAPE_ENABLED]; 210 state[AppState.Field_.IS_LANDSCAPE_ENABLED];
198 } 211 }
199 if (state.hasOwnProperty(AppState.Field_.IS_COLLATE_ENABLED)) { 212 if (state.hasOwnProperty(AppState.Field_.IS_COLLATE_ENABLED)) {
200 this.isCollateEnabled_ = state[AppState.Field_.IS_COLLATE_ENABLED]; 213 this.isCollateEnabled_ = state[AppState.Field_.IS_COLLATE_ENABLED];
201 } 214 }
215 this.isGcpPromoDismissed_ =
ydolgov1 2012/10/16 22:43:17 And this closer to "this.selectedDestinationId_ =.
Toscano 2012/10/16 22:58:44 Done.
216 state[AppState.Field_.IS_GCP_PROMO_DISMISSED] || false;
202 } 217 }
203 }, 218 },
204 219
205 /** 220 /**
206 * Persists the selected destination. 221 * Persists the selected destination.
207 * @param {!print_preview.Destination} dest Destination to persist. 222 * @param {!print_preview.Destination} dest Destination to persist.
208 */ 223 */
209 persistSelectedDestination: function(dest) { 224 persistSelectedDestination: function(dest) {
210 this.selectedDestinationId_ = dest.id; 225 this.selectedDestinationId_ = dest.id;
211 this.isSelectedDestinationLocal_ = dest.isLocal; 226 this.isSelectedDestinationLocal_ = dest.isLocal;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 /** 285 /**
271 * Persists whether printing collation is enabled. 286 * Persists whether printing collation is enabled.
272 * @param {?boolean} isCollateEnabled Whether printing collation is enabled. 287 * @param {?boolean} isCollateEnabled Whether printing collation is enabled.
273 */ 288 */
274 persistIsCollateEnabled: function(isCollateEnabled) { 289 persistIsCollateEnabled: function(isCollateEnabled) {
275 this.isCollateEnabled_ = isCollateEnabled; 290 this.isCollateEnabled_ = isCollateEnabled;
276 this.persist_(); 291 this.persist_();
277 }, 292 },
278 293
279 /** 294 /**
295 * Persists whether the GCP promotion has been dismissed.
296 * @param {boolean} isGcpPromoDismissed Whether the GCP promotion has been
297 * dismissed.
298 */
299 persistIsGcpPromoDismissed: function(isGcpPromoDismissed) {
ydolgov1 2012/10/16 22:43:17 Please fix indentation.
Toscano 2012/10/16 22:58:44 Done.
300 this.isGcpPromoDismissed_ = isGcpPromoDismissed;
301 this.persist_();
302 },
303
304 /**
280 * Calls into the native layer to persist the application state. 305 * Calls into the native layer to persist the application state.
281 * @private 306 * @private
282 */ 307 */
283 persist_: function() { 308 persist_: function() {
284 var obj = {}; 309 var obj = {};
285 obj[AppState.Field_.VERSION] = AppState.VERSION_; 310 obj[AppState.Field_.VERSION] = AppState.VERSION_;
286 obj[AppState.Field_.SELECTED_DESTINATION_ID] = 311 obj[AppState.Field_.SELECTED_DESTINATION_ID] =
287 this.selectedDestinationId_; 312 this.selectedDestinationId_;
288 obj[AppState.Field_.IS_SELECTED_DESTINATION_LOCAL] = 313 obj[AppState.Field_.IS_SELECTED_DESTINATION_LOCAL] =
289 this.isSelectedDestinationLocal_; 314 this.isSelectedDestinationLocal_;
290 obj[AppState.Field_.MARGINS_TYPE] = this.marginsType_; 315 obj[AppState.Field_.MARGINS_TYPE] = this.marginsType_;
291 if (this.customMargins_) { 316 if (this.customMargins_) {
292 obj[AppState.Field_.CUSTOM_MARGINS] = this.customMargins_.serialize(); 317 obj[AppState.Field_.CUSTOM_MARGINS] = this.customMargins_.serialize();
293 } 318 }
294 obj[AppState.Field_.IS_COLOR_ENABLED] = this.isColorEnabled_; 319 obj[AppState.Field_.IS_COLOR_ENABLED] = this.isColorEnabled_;
295 obj[AppState.Field_.IS_DUPLEX_ENABLED] = this.isDuplexEnabled_; 320 obj[AppState.Field_.IS_DUPLEX_ENABLED] = this.isDuplexEnabled_;
296 obj[AppState.Field_.IS_HEADER_FOOTER_ENABLED] = 321 obj[AppState.Field_.IS_HEADER_FOOTER_ENABLED] =
297 this.isHeaderFooterEnabled_; 322 this.isHeaderFooterEnabled_;
298 obj[AppState.Field_.IS_LANDSCAPE_ENABLED] = this.isLandscapeEnabled_; 323 obj[AppState.Field_.IS_LANDSCAPE_ENABLED] = this.isLandscapeEnabled_;
299 obj[AppState.Field_.IS_COLLATE_ENABLED] = this.isCollateEnabled_; 324 obj[AppState.Field_.IS_COLLATE_ENABLED] = this.isCollateEnabled_;
325 obj[AppState.Field_.IS_GCP_PROMO_DISMISSED] = this.isGcpPromoDismissed_;
ydolgov1 2012/10/16 22:43:17 And also please move this one closer to "obj[AppSt
Toscano 2012/10/16 22:58:44 Done.
300 chrome.send(AppState.NATIVE_FUNCTION_NAME_, [JSON.stringify(obj)]); 326 chrome.send(AppState.NATIVE_FUNCTION_NAME_, [JSON.stringify(obj)]);
301 } 327 }
302 }; 328 };
303 329
304 return { 330 return {
305 AppState: AppState 331 AppState: AppState
306 }; 332 };
307 }); 333 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698