OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/ui/webui/print_preview_handler.h" | 5 #include "chrome/browser/ui/webui/print_preview_handler.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "content/browser/tab_contents/tab_contents.h" | 44 #include "content/browser/tab_contents/tab_contents.h" |
45 #include "content/public/browser/browser_thread.h" | 45 #include "content/public/browser/browser_thread.h" |
46 #include "printing/backend/print_backend.h" | 46 #include "printing/backend/print_backend.h" |
47 #include "printing/metafile.h" | 47 #include "printing/metafile.h" |
48 #include "printing/metafile_impl.h" | 48 #include "printing/metafile_impl.h" |
49 #include "printing/page_range.h" | 49 #include "printing/page_range.h" |
50 #include "printing/page_size_margins.h" | 50 #include "printing/page_size_margins.h" |
51 #include "printing/print_settings.h" | 51 #include "printing/print_settings.h" |
52 #include "unicode/ulocdata.h" | 52 #include "unicode/ulocdata.h" |
53 | 53 |
54 #if !defined(OS_CHROMEOS) | 54 #if !defined(OS_MACOSX) |
55 #include "base/command_line.h" | 55 #include "base/command_line.h" |
56 #include "chrome/common/chrome_switches.h" | 56 #include "chrome/common/chrome_switches.h" |
57 #endif | 57 #endif |
58 | 58 |
59 using content::BrowserThread; | 59 using content::BrowserThread; |
60 using printing::Metafile; | 60 using printing::Metafile; |
61 | 61 |
62 namespace { | 62 namespace { |
63 | 63 |
64 enum UserActionBuckets { | 64 enum UserActionBuckets { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 // Name of a dictionary fielad holdong cloud print related data; | 98 // Name of a dictionary fielad holdong cloud print related data; |
99 const char kCloudPrintData[] = "cloudPrintData"; | 99 const char kCloudPrintData[] = "cloudPrintData"; |
100 // Name of a dictionary field holding the initiator tab title. | 100 // Name of a dictionary field holding the initiator tab title. |
101 const char kInitiatorTabTitle[] = "initiatorTabTitle"; | 101 const char kInitiatorTabTitle[] = "initiatorTabTitle"; |
102 // Name of a dictionary field holding the measurement system according to the | 102 // Name of a dictionary field holding the measurement system according to the |
103 // locale. | 103 // locale. |
104 const char kMeasurementSystem[] = "measurementSystem"; | 104 const char kMeasurementSystem[] = "measurementSystem"; |
105 // Name of a dictionary field holding the number format according to the locale. | 105 // Name of a dictionary field holding the number format according to the locale. |
106 const char kNumberFormat[] = "numberFormat"; | 106 const char kNumberFormat[] = "numberFormat"; |
| 107 // Name of a dictionary field specifying whether to print automatically in |
| 108 // kiosk mode. See http://crbug.com/31395. |
| 109 const char kPrintAutomaticallyInKioskMode[] = "printAutomaticallyInKioskMode"; |
107 | 110 |
108 | 111 |
109 // Get the print job settings dictionary from |args|. The caller takes | 112 // Get the print job settings dictionary from |args|. The caller takes |
110 // ownership of the returned DictionaryValue. Returns NULL on failure. | 113 // ownership of the returned DictionaryValue. Returns NULL on failure. |
111 DictionaryValue* GetSettingsDictionary(const ListValue* args) { | 114 DictionaryValue* GetSettingsDictionary(const ListValue* args) { |
112 std::string json_str; | 115 std::string json_str; |
113 if (!args->GetString(0, &json_str)) { | 116 if (!args->GetString(0, &json_str)) { |
114 NOTREACHED() << "Could not read JSON argument"; | 117 NOTREACHED() << "Could not read JSON argument"; |
115 return NULL; | 118 return NULL; |
116 } | 119 } |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 | 634 |
632 base::DictionaryValue initial_settings; | 635 base::DictionaryValue initial_settings; |
633 initial_settings.SetString(kInitiatorTabTitle, | 636 initial_settings.SetString(kInitiatorTabTitle, |
634 print_preview_ui->initiator_tab_title()); | 637 print_preview_ui->initiator_tab_title()); |
635 initial_settings.SetBoolean(printing::kSettingPreviewModifiable, | 638 initial_settings.SetBoolean(printing::kSettingPreviewModifiable, |
636 print_preview_ui->source_is_modifiable()); | 639 print_preview_ui->source_is_modifiable()); |
637 initial_settings.SetString(printing::kSettingPrinterName, | 640 initial_settings.SetString(printing::kSettingPrinterName, |
638 default_printer); | 641 default_printer); |
639 initial_settings.SetString(kCloudPrintData, cloud_print_data); | 642 initial_settings.SetString(kCloudPrintData, cloud_print_data); |
640 | 643 |
| 644 #if defined(OS_MACOSX) |
| 645 bool kiosk_mode = false; // No kiosk mode on Mac yet. |
| 646 #else |
| 647 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
| 648 bool kiosk_mode = (cmdline->HasSwitch(switches::kKioskMode) && |
| 649 cmdline->HasSwitch(switches::kKioskModePrinting)); |
| 650 #endif |
| 651 initial_settings.SetBoolean(kPrintAutomaticallyInKioskMode, kiosk_mode); |
| 652 |
641 if (print_preview_ui->source_is_modifiable()) { | 653 if (print_preview_ui->source_is_modifiable()) { |
642 GetLastUsedMarginSettings(&initial_settings); | 654 GetLastUsedMarginSettings(&initial_settings); |
643 GetNumberFormatAndMeasurementSystem(&initial_settings); | 655 GetNumberFormatAndMeasurementSystem(&initial_settings); |
644 } | 656 } |
645 web_ui_->CallJavascriptFunction("setInitialSettings", initial_settings); | 657 web_ui_->CallJavascriptFunction("setInitialSettings", initial_settings); |
646 } | 658 } |
647 | 659 |
648 void PrintPreviewHandler::ActivateInitiatorTabAndClosePreviewTab() { | 660 void PrintPreviewHandler::ActivateInitiatorTabAndClosePreviewTab() { |
649 TabContentsWrapper* initiator_tab = GetInitiatorTab(); | 661 TabContentsWrapper* initiator_tab = GetInitiatorTab(); |
650 if (initiator_tab) { | 662 if (initiator_tab) { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 return; | 850 return; |
839 | 851 |
840 // We no longer require the initiator tab details. Remove those details | 852 // We no longer require the initiator tab details. Remove those details |
841 // associated with the preview tab to allow the initiator tab to create | 853 // associated with the preview tab to allow the initiator tab to create |
842 // another preview tab. | 854 // another preview tab. |
843 printing::PrintPreviewTabController* tab_controller = | 855 printing::PrintPreviewTabController* tab_controller = |
844 printing::PrintPreviewTabController::GetInstance(); | 856 printing::PrintPreviewTabController::GetInstance(); |
845 if (tab_controller) | 857 if (tab_controller) |
846 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); | 858 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); |
847 } | 859 } |
OLD | NEW |