OLD | NEW |
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 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" | 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // Name of a dictionary field holding the number format according to the locale. | 160 // Name of a dictionary field holding the number format according to the locale. |
161 const char kNumberFormat[] = "numberFormat"; | 161 const char kNumberFormat[] = "numberFormat"; |
162 // Name of a dictionary field specifying whether to print automatically in | 162 // Name of a dictionary field specifying whether to print automatically in |
163 // kiosk mode. See http://crbug.com/31395. | 163 // kiosk mode. See http://crbug.com/31395. |
164 const char kPrintAutomaticallyInKioskMode[] = "printAutomaticallyInKioskMode"; | 164 const char kPrintAutomaticallyInKioskMode[] = "printAutomaticallyInKioskMode"; |
165 // Dictionary field to indicate whether Chrome is running in forced app (app | 165 // Dictionary field to indicate whether Chrome is running in forced app (app |
166 // kiosk) mode. It's not the same as desktop Chrome kiosk (the one above). | 166 // kiosk) mode. It's not the same as desktop Chrome kiosk (the one above). |
167 const char kAppKioskMode[] = "appKioskMode"; | 167 const char kAppKioskMode[] = "appKioskMode"; |
168 // Dictionary field to store Cloud Print base URL. | 168 // Dictionary field to store Cloud Print base URL. |
169 const char kCloudPrintUrl[] = "cloudPrintUrl"; | 169 const char kCloudPrintUrl[] = "cloudPrintUrl"; |
170 #if defined(OS_WIN) | |
171 const char kHidePrintWithSystemDialogLink[] = "hidePrintWithSystemDialogLink"; | |
172 #endif | |
173 // Name of a dictionary field holding the state of selection for document. | 170 // Name of a dictionary field holding the state of selection for document. |
174 const char kDocumentHasSelection[] = "documentHasSelection"; | 171 const char kDocumentHasSelection[] = "documentHasSelection"; |
175 // Dictionary field holding the default destination selection rules. | 172 // Dictionary field holding the default destination selection rules. |
176 const char kDefaultDestinationSelectionRules[] = | 173 const char kDefaultDestinationSelectionRules[] = |
177 "defaultDestinationSelectionRules"; | 174 "defaultDestinationSelectionRules"; |
178 | 175 |
179 // Id of the predefined PDF printer. | 176 // Id of the predefined PDF printer. |
180 const char kLocalPdfPrinterId[] = "Save as PDF"; | 177 const char kLocalPdfPrinterId[] = "Save as PDF"; |
181 | 178 |
182 // Additional printer capability setting keys. | 179 // Additional printer capability setting keys. |
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 if (sticky_settings->printer_app_state()) { | 1283 if (sticky_settings->printer_app_state()) { |
1287 initial_settings.SetString(kAppState, | 1284 initial_settings.SetString(kAppState, |
1288 *sticky_settings->printer_app_state()); | 1285 *sticky_settings->printer_app_state()); |
1289 } | 1286 } |
1290 | 1287 |
1291 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 1288 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
1292 initial_settings.SetBoolean(kPrintAutomaticallyInKioskMode, | 1289 initial_settings.SetBoolean(kPrintAutomaticallyInKioskMode, |
1293 cmdline->HasSwitch(switches::kKioskModePrinting)); | 1290 cmdline->HasSwitch(switches::kKioskModePrinting)); |
1294 initial_settings.SetBoolean(kAppKioskMode, | 1291 initial_settings.SetBoolean(kAppKioskMode, |
1295 chrome::IsRunningInForcedAppMode()); | 1292 chrome::IsRunningInForcedAppMode()); |
1296 #if defined(OS_WIN) | |
1297 // In Win8 metro, the system print dialog can only open on the desktop. Doing | |
1298 // so will cause the browser to appear hung, so we don't show the link in | |
1299 // metro. | |
1300 bool is_ash = (chrome::GetActiveDesktop() == chrome::HOST_DESKTOP_TYPE_ASH); | |
1301 initial_settings.SetBoolean(kHidePrintWithSystemDialogLink, is_ash); | |
1302 #endif | |
1303 if (prefs) { | 1293 if (prefs) { |
1304 const std::string rules_str = | 1294 const std::string rules_str = |
1305 prefs->GetString(prefs::kPrintPreviewDefaultDestinationSelectionRules); | 1295 prefs->GetString(prefs::kPrintPreviewDefaultDestinationSelectionRules); |
1306 if (!rules_str.empty()) | 1296 if (!rules_str.empty()) |
1307 initial_settings.SetString(kDefaultDestinationSelectionRules, rules_str); | 1297 initial_settings.SetString(kDefaultDestinationSelectionRules, rules_str); |
1308 } | 1298 } |
1309 | 1299 |
1310 if (print_preview_ui()->source_is_modifiable()) | 1300 if (print_preview_ui()->source_is_modifiable()) |
1311 GetNumberFormatAndMeasurementSystem(&initial_settings); | 1301 GetNumberFormatAndMeasurementSystem(&initial_settings); |
1312 web_ui()->CallJavascriptFunction("setInitialSettings", initial_settings); | 1302 web_ui()->CallJavascriptFunction("setInitialSettings", initial_settings); |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1813 | 1803 |
1814 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { | 1804 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { |
1815 if (gaia_cookie_manager_service_) | 1805 if (gaia_cookie_manager_service_) |
1816 gaia_cookie_manager_service_->RemoveObserver(this); | 1806 gaia_cookie_manager_service_->RemoveObserver(this); |
1817 } | 1807 } |
1818 | 1808 |
1819 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1809 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
1820 const base::Closure& closure) { | 1810 const base::Closure& closure) { |
1821 pdf_file_saved_closure_ = closure; | 1811 pdf_file_saved_closure_ = closure; |
1822 } | 1812 } |
OLD | NEW |