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

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

Issue 11818062: Adds option to enable CSS backgrounds for printing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Merge with trunk. Created 7 years, 11 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 * @private 72 * @private
73 */ 73 */
74 this.isLandscapeEnabled_ = null; 74 this.isLandscapeEnabled_ = null;
75 75
76 /** 76 /**
77 * Whether printing collation is enabled. 77 * Whether printing collation is enabled.
78 * @type {?boolean} 78 * @type {?boolean}
79 * @private 79 * @private
80 */ 80 */
81 this.isCollateEnabled_ = null; 81 this.isCollateEnabled_ = null;
82
83 /**
84 * Whether printing CSS backgrounds is enabled.
85 * @type {?boolean}
86 * @private
87 */
88 this.isCssBackgroundEnabled_ = null;
82 }; 89 };
83 90
84 /** 91 /**
85 * Current version of the app state. This value helps to understand how to 92 * Current version of the app state. This value helps to understand how to
86 * parse earlier versions of the app state. 93 * parse earlier versions of the app state.
87 * @type {number} 94 * @type {number}
88 * @const 95 * @const
89 * @private 96 * @private
90 */ 97 */
91 AppState.VERSION_ = 2; 98 AppState.VERSION_ = 2;
92 99
93 /** 100 /**
94 * Enumeration of field names for serialized app state. 101 * Enumeration of field names for serialized app state.
95 * @enum {string} 102 * @enum {string}
96 * @private 103 * @private
97 */ 104 */
98 AppState.Field_ = { 105 AppState.Field_ = {
99 VERSION: 'version', 106 VERSION: 'version',
100 SELECTED_DESTINATION_ID: 'selectedDestinationId', 107 SELECTED_DESTINATION_ID: 'selectedDestinationId',
101 IS_SELECTED_DESTINATION_LOCAL: 'isSelectedDestinationLocal', 108 IS_SELECTED_DESTINATION_LOCAL: 'isSelectedDestinationLocal',
102 IS_GCP_PROMO_DISMISSED: 'isGcpPromoDismissed', 109 IS_GCP_PROMO_DISMISSED: 'isGcpPromoDismissed',
103 MARGINS_TYPE: 'marginsType', 110 MARGINS_TYPE: 'marginsType',
104 CUSTOM_MARGINS: 'customMargins', 111 CUSTOM_MARGINS: 'customMargins',
105 IS_COLOR_ENABLED: 'isColorEnabled', 112 IS_COLOR_ENABLED: 'isColorEnabled',
106 IS_DUPLEX_ENABLED: 'isDuplexEnabled', 113 IS_DUPLEX_ENABLED: 'isDuplexEnabled',
107 IS_HEADER_FOOTER_ENABLED: 'isHeaderFooterEnabled', 114 IS_HEADER_FOOTER_ENABLED: 'isHeaderFooterEnabled',
108 IS_LANDSCAPE_ENABLED: 'isLandscapeEnabled', 115 IS_LANDSCAPE_ENABLED: 'isLandscapeEnabled',
109 IS_COLLATE_ENABLED: 'isCollateEnabled' 116 IS_COLLATE_ENABLED: 'isCollateEnabled',
117 IS_CSS_BACKGROUND_ENABLED: 'isCssBackgroundEnabled'
110 }; 118 };
111 119
112 /** 120 /**
113 * Name of C++ layer function to persist app state. 121 * Name of C++ layer function to persist app state.
114 * @type {string} 122 * @type {string}
115 * @const 123 * @const
116 * @private 124 * @private
117 */ 125 */
118 AppState.NATIVE_FUNCTION_NAME_ = 'saveAppState'; 126 AppState.NATIVE_FUNCTION_NAME_ = 'saveAppState';
119 127
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 /** @return {?boolean} Whether landscape page orientation is selected. */ 169 /** @return {?boolean} Whether landscape page orientation is selected. */
162 get isLandscapeEnabled() { 170 get isLandscapeEnabled() {
163 return this.isLandscapeEnabled_; 171 return this.isLandscapeEnabled_;
164 }, 172 },
165 173
166 /** @return {?boolean} Whether printing collation is enabled. */ 174 /** @return {?boolean} Whether printing collation is enabled. */
167 get isCollateEnabled() { 175 get isCollateEnabled() {
168 return this.isCollateEnabled_; 176 return this.isCollateEnabled_;
169 }, 177 },
170 178
179 /** @return {?boolean} Whether printing CSS backgrounds is enabled. */
180 get isCssBackgroundEnabled() {
181 return this.isCssBackgroundEnabled_;
182 },
183
171 /** 184 /**
172 * Initializes the app state from a serialized string returned by the native 185 * Initializes the app state from a serialized string returned by the native
173 * layer. 186 * layer.
174 * @param {?string} serializedAppStateStr Serialized string representation 187 * @param {?string} serializedAppStateStr Serialized string representation
175 * of the app state. 188 * of the app state.
176 */ 189 */
177 init: function(serializedAppStateStr) { 190 init: function(serializedAppStateStr) {
178 if (!serializedAppStateStr) { 191 if (!serializedAppStateStr) {
179 // Set some state defaults. 192 // Set some state defaults.
180 this.isGcpPromoDismissed_ = false; 193 this.isGcpPromoDismissed_ = false;
(...skipping 28 matching lines...) Expand all
209 this.isHeaderFooterEnabled_ = 222 this.isHeaderFooterEnabled_ =
210 state[AppState.Field_.IS_HEADER_FOOTER_ENABLED]; 223 state[AppState.Field_.IS_HEADER_FOOTER_ENABLED];
211 } 224 }
212 if (state.hasOwnProperty(AppState.Field_.IS_LANDSCAPE_ENABLED)) { 225 if (state.hasOwnProperty(AppState.Field_.IS_LANDSCAPE_ENABLED)) {
213 this.isLandscapeEnabled_ = 226 this.isLandscapeEnabled_ =
214 state[AppState.Field_.IS_LANDSCAPE_ENABLED]; 227 state[AppState.Field_.IS_LANDSCAPE_ENABLED];
215 } 228 }
216 if (state.hasOwnProperty(AppState.Field_.IS_COLLATE_ENABLED)) { 229 if (state.hasOwnProperty(AppState.Field_.IS_COLLATE_ENABLED)) {
217 this.isCollateEnabled_ = state[AppState.Field_.IS_COLLATE_ENABLED]; 230 this.isCollateEnabled_ = state[AppState.Field_.IS_COLLATE_ENABLED];
218 } 231 }
232 if (state.hasOwnProperty(AppState.Field_.IS_CSS_BACKGROUND_ENABLED)) {
233 this.isCssBackgroundEnabled_ =
234 state[AppState.Field_.IS_CSS_BACKGROUND_ENABLED];
235 }
219 } 236 }
220 }, 237 },
221 238
222 /** 239 /**
223 * Persists the selected destination. 240 * Persists the selected destination.
224 * @param {!print_preview.Destination} dest Destination to persist. 241 * @param {!print_preview.Destination} dest Destination to persist.
225 */ 242 */
226 persistSelectedDestination: function(dest) { 243 persistSelectedDestination: function(dest) {
227 this.selectedDestinationId_ = dest.id; 244 this.selectedDestinationId_ = dest.id;
228 this.isSelectedDestinationLocal_ = dest.isLocal; 245 this.isSelectedDestinationLocal_ = dest.isLocal;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 /** 314 /**
298 * Persists whether printing collation is enabled. 315 * Persists whether printing collation is enabled.
299 * @param {?boolean} isCollateEnabled Whether printing collation is enabled. 316 * @param {?boolean} isCollateEnabled Whether printing collation is enabled.
300 */ 317 */
301 persistIsCollateEnabled: function(isCollateEnabled) { 318 persistIsCollateEnabled: function(isCollateEnabled) {
302 this.isCollateEnabled_ = isCollateEnabled; 319 this.isCollateEnabled_ = isCollateEnabled;
303 this.persist_(); 320 this.persist_();
304 }, 321 },
305 322
306 /** 323 /**
324 * Persists whether printing CSS backgrounds is enabled.
325 * @param {?boolean} isCssBackgroundEnabled Whether printing CSS
326 * backgrounds is enabled.
327 */
328 persistIsCssBackgroundEnabled: function(isCssBackgroundEnabled) {
329 this.isCssBackgroundEnabled_ = isCssBackgroundEnabled;
330 this.persist_();
331 },
332
333 /**
307 * Calls into the native layer to persist the application state. 334 * Calls into the native layer to persist the application state.
308 * @private 335 * @private
309 */ 336 */
310 persist_: function() { 337 persist_: function() {
311 var obj = {}; 338 var obj = {};
312 obj[AppState.Field_.VERSION] = AppState.VERSION_; 339 obj[AppState.Field_.VERSION] = AppState.VERSION_;
313 obj[AppState.Field_.SELECTED_DESTINATION_ID] = 340 obj[AppState.Field_.SELECTED_DESTINATION_ID] =
314 this.selectedDestinationId_; 341 this.selectedDestinationId_;
315 obj[AppState.Field_.IS_SELECTED_DESTINATION_LOCAL] = 342 obj[AppState.Field_.IS_SELECTED_DESTINATION_LOCAL] =
316 this.isSelectedDestinationLocal_; 343 this.isSelectedDestinationLocal_;
317 obj[AppState.Field_.IS_GCP_PROMO_DISMISSED] = this.isGcpPromoDismissed_; 344 obj[AppState.Field_.IS_GCP_PROMO_DISMISSED] = this.isGcpPromoDismissed_;
318 obj[AppState.Field_.MARGINS_TYPE] = this.marginsType_; 345 obj[AppState.Field_.MARGINS_TYPE] = this.marginsType_;
319 if (this.customMargins_) { 346 if (this.customMargins_) {
320 obj[AppState.Field_.CUSTOM_MARGINS] = this.customMargins_.serialize(); 347 obj[AppState.Field_.CUSTOM_MARGINS] = this.customMargins_.serialize();
321 } 348 }
322 obj[AppState.Field_.IS_COLOR_ENABLED] = this.isColorEnabled_; 349 obj[AppState.Field_.IS_COLOR_ENABLED] = this.isColorEnabled_;
323 obj[AppState.Field_.IS_DUPLEX_ENABLED] = this.isDuplexEnabled_; 350 obj[AppState.Field_.IS_DUPLEX_ENABLED] = this.isDuplexEnabled_;
324 obj[AppState.Field_.IS_HEADER_FOOTER_ENABLED] = 351 obj[AppState.Field_.IS_HEADER_FOOTER_ENABLED] =
325 this.isHeaderFooterEnabled_; 352 this.isHeaderFooterEnabled_;
326 obj[AppState.Field_.IS_LANDSCAPE_ENABLED] = this.isLandscapeEnabled_; 353 obj[AppState.Field_.IS_LANDSCAPE_ENABLED] = this.isLandscapeEnabled_;
327 obj[AppState.Field_.IS_COLLATE_ENABLED] = this.isCollateEnabled_; 354 obj[AppState.Field_.IS_COLLATE_ENABLED] = this.isCollateEnabled_;
355 obj[AppState.Field_.IS_CSS_BACKGROUND_ENABLED] =
356 this.isCssBackgroundEnabled_;
328 chrome.send(AppState.NATIVE_FUNCTION_NAME_, [JSON.stringify(obj)]); 357 chrome.send(AppState.NATIVE_FUNCTION_NAME_, [JSON.stringify(obj)]);
329 } 358 }
330 }; 359 };
331 360
332 return { 361 return {
333 AppState: AppState 362 AppState: AppState
334 }; 363 };
335 }); 364 });
OLDNEW
« no previous file with comments | « chrome/browser/printing/printing_message_filter.cc ('k') | chrome/browser/resources/print_preview/data/print_ticket_store.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698