diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-15 07:03:51 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-15 07:03:51 +0000 |
commit | 794c203391679cd8d3020dfae5359373e9427383 (patch) | |
tree | af830ab7a3e5ae5267594cd5cd6a45786104b7dd | |
parent | 2117f255f3ce87d60d2205a2e40798b7382c6d1f (diff) | |
download | chromium_src-794c203391679cd8d3020dfae5359373e9427383.zip chromium_src-794c203391679cd8d3020dfae5359373e9427383.tar.gz chromium_src-794c203391679cd8d3020dfae5359373e9427383.tar.bz2 |
Print preview: A quick hack to support printing to the default printer without user confirmation in kiosk mode.
BUG=31395
TEST=none
Review URL: http://codereview.chromium.org/8915027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114605 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/print_preview/print_preview.js | 8 | ||||
-rw-r--r-- | chrome/browser/ui/webui/print_preview_handler.cc | 14 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 4 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 |
4 files changed, 26 insertions, 1 deletions
diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js index 8ed968c..b43d295 100644 --- a/chrome/browser/resources/print_preview/print_preview.js +++ b/chrome/browser/resources/print_preview/print_preview.js @@ -53,6 +53,10 @@ var isPrintReadyMetafileReady = false; // True when preview tab is hidden. var isTabHidden = false; +// True in kiosk mode where print preview can print automatically without +// user intervention. See http://crbug.com/31395. +var printAutomaticallyInKioskMode = false; + // @type {print_preview.PrintHeader} Holds the print and cancel buttons. var printHeader; @@ -191,6 +195,8 @@ function setInitialSettings(initialSettings) { } setDefaultPrinter(initialSettings['printerName'], initialSettings['cloudPrintData']); + printAutomaticallyInKioskMode = + initialSettings['printAutomaticallyInKioskMode']; } /** @@ -815,6 +821,8 @@ function onPDFLoad() { isFirstPageLoaded = true; checkAndHideOverlayLayerIfValid(); sendPrintDocumentRequestIfNeeded(); + if (printAutomaticallyInKioskMode) + printHeader.printButton.click(); } function setPluginPreviewPageCount() { diff --git a/chrome/browser/ui/webui/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview_handler.cc index 03233b5..cc65922 100644 --- a/chrome/browser/ui/webui/print_preview_handler.cc +++ b/chrome/browser/ui/webui/print_preview_handler.cc @@ -51,7 +51,7 @@ #include "printing/print_settings.h" #include "unicode/ulocdata.h" -#if !defined(OS_CHROMEOS) +#if !defined(OS_MACOSX) #include "base/command_line.h" #include "chrome/common/chrome_switches.h" #endif @@ -104,6 +104,9 @@ const char kInitiatorTabTitle[] = "initiatorTabTitle"; const char kMeasurementSystem[] = "measurementSystem"; // Name of a dictionary field holding the number format according to the locale. const char kNumberFormat[] = "numberFormat"; +// Name of a dictionary field specifying whether to print automatically in +// kiosk mode. See http://crbug.com/31395. +const char kPrintAutomaticallyInKioskMode[] = "printAutomaticallyInKioskMode"; // Get the print job settings dictionary from |args|. The caller takes @@ -638,6 +641,15 @@ void PrintPreviewHandler::SendInitialSettings( default_printer); initial_settings.SetString(kCloudPrintData, cloud_print_data); +#if defined(OS_MACOSX) + bool kiosk_mode = false; // No kiosk mode on Mac yet. +#else + CommandLine* cmdline = CommandLine::ForCurrentProcess(); + bool kiosk_mode = (cmdline->HasSwitch(switches::kKioskMode) && + cmdline->HasSwitch(switches::kKioskModePrinting)); +#endif + initial_settings.SetBoolean(kPrintAutomaticallyInKioskMode, kiosk_mode); + if (print_preview_ui->source_is_modifiable()) { GetLastUsedMarginSettings(&initial_settings); GetNumberFormatAndMeasurementSystem(&initial_settings); diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index 0718b18..69f28d8 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -1270,6 +1270,10 @@ const char kUseMockKeychain[] = "use-mock-keychain"; #if !defined(OS_MACOSX) // Enables Kiosk mode. const char kKioskMode[] = "kiosk"; + +// Print automatically in kiosk mode. |kKioskMode| must be set as well. +// See http://crbug.com/31395. +const char kKioskModePrinting[] = "kiosk-printing"; #endif #if defined(TOOLKIT_VIEWS) diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index 0d9d42d..e986f20 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -361,6 +361,7 @@ extern const char kUseMockKeychain[]; #if !defined(OS_MACOSX) extern const char kKioskMode[]; +extern const char kKioskModePrinting[]; #endif #if defined(TOOLKIT_VIEWS) |