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

Side by Side Diff: chrome/browser/resources/print_preview/native_layer.js

Issue 2606043004: Perform printer setup on Chrome OS before selecting printer. (Closed)
Patch Set: fix nits Created 3 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.exportPath('print_preview'); 5 cr.exportPath('print_preview');
6 6
7 /** 7 /**
8 * @typedef {{selectSaveAsPdfDestination: boolean, 8 * @typedef {{selectSaveAsPdfDestination: boolean,
9 * layoutSettings.portrait: boolean, 9 * layoutSettings.portrait: boolean,
10 * pageRange: string, 10 * pageRange: string,
11 * headersAndFooters: boolean, 11 * headersAndFooters: boolean,
12 * backgroundColorsAndImages: boolean, 12 * backgroundColorsAndImages: boolean,
13 * margins: number}} 13 * margins: number}}
14 * @see chrome/browser/printing/print_preview_pdf_generated_browsertest.cc 14 * @see chrome/browser/printing/print_preview_pdf_generated_browsertest.cc
15 */ 15 */
16 print_preview.PreviewSettings; 16 print_preview.PreviewSettings;
17 17
18 /**
19 * @typedef {{
20 * printerId: string,
21 * success: boolean,
22 * capabilities: Object,
23 * }}
24 */
25 print_preview.PrinterSetupResponse;
26
18 cr.define('print_preview', function() { 27 cr.define('print_preview', function() {
19 'use strict'; 28 'use strict';
20 29
21 /** 30 /**
22 * An interface to the native Chromium printing system layer. 31 * An interface to the native Chromium printing system layer.
23 * @constructor 32 * @constructor
24 * @extends {cr.EventTarget} 33 * @extends {cr.EventTarget}
25 */ 34 */
26 function NativeLayer() { 35 function NativeLayer() {
27 cr.EventTarget.call(this); 36 cr.EventTarget.call(this);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 * the resolved destination properties by calling 234 * the resolved destination properties by calling
226 * {@code onProvisionalPrinterResolved}, or in case of an error 235 * {@code onProvisionalPrinterResolved}, or in case of an error
227 * {@code failedToResolveProvisionalPrinter} 236 * {@code failedToResolveProvisionalPrinter}
228 * @param {string} provisionalDestinationId 237 * @param {string} provisionalDestinationId
229 */ 238 */
230 grantExtensionPrinterAccess: function(provisionalDestinationId) { 239 grantExtensionPrinterAccess: function(provisionalDestinationId) {
231 chrome.send('grantExtensionPrinterAccess', [provisionalDestinationId]); 240 chrome.send('grantExtensionPrinterAccess', [provisionalDestinationId]);
232 }, 241 },
233 242
234 /** 243 /**
244 * Requests that Chrome peform printer setup for the given printer.
245 * @param {string} printerId
246 * @return {!Promise<!print_preview.PrinterSetupResponse>}
247 */
248 setupPrinter: function(printerId) {
249 return cr.sendWithPromise('setupPrinter', printerId);
250 },
251
252 /**
235 * @param {!print_preview.Destination} destination Destination to print to. 253 * @param {!print_preview.Destination} destination Destination to print to.
236 * @param {!print_preview.ticket_items.Color} color Color ticket item. 254 * @param {!print_preview.ticket_items.Color} color Color ticket item.
237 * @return {number} Native layer color model. 255 * @return {number} Native layer color model.
238 * @private 256 * @private
239 */ 257 */
240 getNativeColorModel_: function(destination, color) { 258 getNativeColorModel_: function(destination, color) {
241 // For non-local printers native color model is ignored anyway. 259 // For non-local printers native color model is ignored anyway.
242 var option = destination.isLocal ? color.getSelectedOption() : null; 260 var option = destination.isLocal ? color.getSelectedOption() : null;
243 var nativeColorModel = parseInt(option ? option.vendor_id : null, 10); 261 var nativeColorModel = parseInt(option ? option.vendor_id : null, 10);
244 if (isNaN(nativeColorModel)) { 262 if (isNaN(nativeColorModel)) {
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 return this.serializedDefaultDestinationSelectionRulesStr_; 1113 return this.serializedDefaultDestinationSelectionRulesStr_;
1096 } 1114 }
1097 }; 1115 };
1098 1116
1099 // Export 1117 // Export
1100 return { 1118 return {
1101 NativeInitialSettings: NativeInitialSettings, 1119 NativeInitialSettings: NativeInitialSettings,
1102 NativeLayer: NativeLayer 1120 NativeLayer: NativeLayer
1103 }; 1121 };
1104 }); 1122 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698