| 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 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // locale. | 181 // locale. |
| 182 const char kMeasurementSystem[] = "measurementSystem"; | 182 const char kMeasurementSystem[] = "measurementSystem"; |
| 183 // Name of a dictionary field holding the number format according to the locale. | 183 // Name of a dictionary field holding the number format according to the locale. |
| 184 const char kNumberFormat[] = "numberFormat"; | 184 const char kNumberFormat[] = "numberFormat"; |
| 185 // Name of a dictionary field specifying whether to print automatically in | 185 // Name of a dictionary field specifying whether to print automatically in |
| 186 // kiosk mode. See http://crbug.com/31395. | 186 // kiosk mode. See http://crbug.com/31395. |
| 187 const char kPrintAutomaticallyInKioskMode[] = "printAutomaticallyInKioskMode"; | 187 const char kPrintAutomaticallyInKioskMode[] = "printAutomaticallyInKioskMode"; |
| 188 // Dictionary field to indicate whether Chrome is running in forced app (app | 188 // Dictionary field to indicate whether Chrome is running in forced app (app |
| 189 // kiosk) mode. It's not the same as desktop Chrome kiosk (the one above). | 189 // kiosk) mode. It's not the same as desktop Chrome kiosk (the one above). |
| 190 const char kAppKioskMode[] = "appKioskMode"; | 190 const char kAppKioskMode[] = "appKioskMode"; |
| 191 // Dictionary field to store Cloud Print base URL. | |
| 192 const char kCloudPrintUrl[] = "cloudPrintUrl"; | |
| 193 // Name of a dictionary field holding the state of selection for document. | 191 // Name of a dictionary field holding the state of selection for document. |
| 194 const char kDocumentHasSelection[] = "documentHasSelection"; | 192 const char kDocumentHasSelection[] = "documentHasSelection"; |
| 195 // Dictionary field holding the default destination selection rules. | 193 // Dictionary field holding the default destination selection rules. |
| 196 const char kDefaultDestinationSelectionRules[] = | 194 const char kDefaultDestinationSelectionRules[] = |
| 197 "defaultDestinationSelectionRules"; | 195 "defaultDestinationSelectionRules"; |
| 198 | 196 |
| 199 // Id of the predefined PDF printer. | 197 // Id of the predefined PDF printer. |
| 200 const char kLocalPdfPrinterId[] = "Save as PDF"; | 198 const char kLocalPdfPrinterId[] = "Save as PDF"; |
| 201 | 199 |
| 202 // Timeout for searching for privet printers, in seconds. | 200 // Timeout for searching for privet printers, in seconds. |
| (...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1426 } | 1424 } |
| 1427 | 1425 |
| 1428 ResolveJavascriptCallback(base::Value(callback_id), printers); | 1426 ResolveJavascriptCallback(base::Value(callback_id), printers); |
| 1429 } | 1427 } |
| 1430 | 1428 |
| 1431 void PrintPreviewHandler::SendCloudPrintEnabled() { | 1429 void PrintPreviewHandler::SendCloudPrintEnabled() { |
| 1432 Profile* profile = Profile::FromBrowserContext( | 1430 Profile* profile = Profile::FromBrowserContext( |
| 1433 preview_web_contents()->GetBrowserContext()); | 1431 preview_web_contents()->GetBrowserContext()); |
| 1434 PrefService* prefs = profile->GetPrefs(); | 1432 PrefService* prefs = profile->GetPrefs(); |
| 1435 if (prefs->GetBoolean(prefs::kCloudPrintSubmitEnabled)) { | 1433 if (prefs->GetBoolean(prefs::kCloudPrintSubmitEnabled)) { |
| 1436 base::DictionaryValue settings; | 1434 FireWebUIListener( |
| 1437 settings.SetString(kCloudPrintUrl, | 1435 "use-cloud-print", |
| 1438 GURL(cloud_devices::GetCloudPrintURL()).spec()); | 1436 base::Value(GURL(cloud_devices::GetCloudPrintURL()).spec()), |
| 1439 settings.SetBoolean(kAppKioskMode, chrome::IsRunningInForcedAppMode()); | 1437 base::Value(chrome::IsRunningInForcedAppMode())); |
| 1440 web_ui()->CallJavascriptFunctionUnsafe("setUseCloudPrint", settings); | |
| 1441 } | 1438 } |
| 1442 } | 1439 } |
| 1443 | 1440 |
| 1444 void PrintPreviewHandler::SendCloudPrintJob(const std::string& callback_id, | 1441 void PrintPreviewHandler::SendCloudPrintJob(const std::string& callback_id, |
| 1445 const base::RefCountedBytes* data) { | 1442 const base::RefCountedBytes* data) { |
| 1446 // BASE64 encode the job data. | 1443 // BASE64 encode the job data. |
| 1447 const base::StringPiece raw_data(reinterpret_cast<const char*>(data->front()), | 1444 const base::StringPiece raw_data(reinterpret_cast<const char*>(data->front()), |
| 1448 data->size()); | 1445 data->size()); |
| 1449 std::string base64_data; | 1446 std::string base64_data; |
| 1450 base::Base64Encode(raw_data, &base64_data); | 1447 base::Base64Encode(raw_data, &base64_data); |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 | 1895 |
| 1899 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { | 1896 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { |
| 1900 if (gaia_cookie_manager_service_) | 1897 if (gaia_cookie_manager_service_) |
| 1901 gaia_cookie_manager_service_->RemoveObserver(this); | 1898 gaia_cookie_manager_service_->RemoveObserver(this); |
| 1902 } | 1899 } |
| 1903 | 1900 |
| 1904 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1901 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
| 1905 const base::Closure& closure) { | 1902 const base::Closure& closure) { |
| 1906 pdf_file_saved_closure_ = closure; | 1903 pdf_file_saved_closure_ = closure; |
| 1907 } | 1904 } |
| OLD | NEW |