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

Unified Diff: chrome/browser/resources/print_preview/native_layer.js

Issue 59843010: Print to Privet local printers (PDF only) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/print_preview/native_layer.js
diff --git a/chrome/browser/resources/print_preview/native_layer.js b/chrome/browser/resources/print_preview/native_layer.js
index 7a2fa366a6517787598b42f834fbd1350b1b3ec2..112b573f36ee291037956200559d2e2ff5efaf58 100644
--- a/chrome/browser/resources/print_preview/native_layer.js
+++ b/chrome/browser/resources/print_preview/native_layer.js
@@ -48,6 +48,7 @@ cr.define('print_preview', function() {
this.onPrivetPrinterSearchDone_.bind(this);
global['onPrivetCapabilitiesSet'] =
this.onPrivetCapabilitiesSet_.bind(this);
+ global['onPrivetPrintFailed'] = this.onPrivetPrintFailed_.bind(this);
};
/**
@@ -81,7 +82,8 @@ cr.define('print_preview', function() {
PRIVET_PRINTER_SEARCH_DONE:
'print_preview.NativeLayer.PRIVET_PRINTER_SEARCH_DONE',
PRIVET_CAPABILITIES_SET:
- 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET'
+ 'print_preview.NativeLayer.PRIVET_CAPABILITIES_SET',
+ PRIVET_PRINT_FAILED: 'print_preview.NativeLayer.PRIVET_PRINT_FAILED'
};
/**
@@ -273,6 +275,7 @@ cr.define('print_preview', function() {
'printToPDF': destination.id ==
print_preview.Destination.GooglePromotedId.SAVE_AS_PDF,
'printWithCloudPrint': !destination.isLocal,
+ 'printWithPrivet': destination.isPrivet,
'deviceName': destination.id,
'isFirstRequest': false,
'requestID': -1,
@@ -300,6 +303,10 @@ cr.define('print_preview', function() {
};
}
+ if (destination.isPrivet) {
+ ticket['ticket'] = printTicketStore.createPrintTicket(destination);
+ }
+
if (opt_isOpenPdfInPreview) {
ticket['OpenPDFInPreview'] = true;
}
@@ -654,8 +661,8 @@ cr.define('print_preview', function() {
* @private
*/
onPrivetPrinterSearchDone_: function() {
- var privetPrinterSearchDoneEvent = new Event(
- NativeLayer.EventType.PRIVET_PRINTER_SEARCH_DONE);
+ var privetPrinterSearchDoneEvent =
+ new Event(NativeLayer.EventType.PRIVET_PRINTER_SEARCH_DONE);
this.dispatchEvent(privetPrinterSearchDoneEvent);
},
@@ -665,11 +672,23 @@ cr.define('print_preview', function() {
* @private
*/
onPrivetCapabilitiesSet_: function(printer, capabilities) {
- var privetCapabilitiesSetEvent = new Event(
- NativeLayer.EventType.PRIVET_CAPABILITIES_SET);
+ var privetCapabilitiesSetEvent =
+ new Event(NativeLayer.EventType.PRIVET_CAPABILITIES_SET);
privetCapabilitiesSetEvent.printer = printer;
privetCapabilitiesSetEvent.capabilities = capabilities;
this.dispatchEvent(privetCapabilitiesSetEvent);
+ },
+
+ /**
+ * @param {string} http_error The HTTP response code or -1 if not an HTTP
+ * error.
+ * @private
+ */
+ onPrivetPrintFailed_: function(http_error) {
+ var privetPrintFailedEvent =
+ new Event(NativeLayer.EventType.PRIVET_PRINT_FAILED);
+ privetPrintFailedEvent.httpError = http_error;
+ this.dispatchEvent(privetPrintFailedEvent);
}
};

Powered by Google App Engine
This is Rietveld 408576698