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 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 | 827 |
828 int width = 0; | 828 int width = 0; |
829 int height = 0; | 829 int height = 0; |
830 if (!settings->GetString(printing::kSettingDeviceName, &printer_name) || | 830 if (!settings->GetString(printing::kSettingDeviceName, &printer_name) || |
831 !settings->GetString(printing::kSettingTicket, &print_ticket) || | 831 !settings->GetString(printing::kSettingTicket, &print_ticket) || |
832 !settings->GetString(printing::kSettingCapabilities, &capabilities) || | 832 !settings->GetString(printing::kSettingCapabilities, &capabilities) || |
833 !settings->GetInteger(printing::kSettingPageWidth, &width) || | 833 !settings->GetInteger(printing::kSettingPageWidth, &width) || |
834 !settings->GetInteger(printing::kSettingPageHeight, &height) || | 834 !settings->GetInteger(printing::kSettingPageHeight, &height) || |
835 width <= 0 || height <= 0) { | 835 width <= 0 || height <= 0) { |
836 NOTREACHED(); | 836 NOTREACHED(); |
837 base::FundamentalValue http_code_value(-1); | 837 base::Value http_code_value(-1); |
838 web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed", | 838 web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed", |
839 http_code_value); | 839 http_code_value); |
840 return; | 840 return; |
841 } | 841 } |
842 | 842 |
843 PrintToPrivetPrinter( | 843 PrintToPrivetPrinter( |
844 printer_name, print_ticket, capabilities, gfx::Size(width, height)); | 844 printer_name, print_ticket, capabilities, gfx::Size(width, height)); |
845 return; | 845 return; |
846 } | 846 } |
847 #endif | 847 #endif |
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 privet_local_print_operation_ = | 1498 privet_local_print_operation_ = |
1499 privet_http_client_->CreateLocalPrintOperation(this); | 1499 privet_http_client_->CreateLocalPrintOperation(this); |
1500 | 1500 |
1501 privet_local_print_operation_->SetTicket(print_ticket); | 1501 privet_local_print_operation_->SetTicket(print_ticket); |
1502 privet_local_print_operation_->SetCapabilities(capabilities); | 1502 privet_local_print_operation_->SetCapabilities(capabilities); |
1503 | 1503 |
1504 scoped_refptr<base::RefCountedBytes> data; | 1504 scoped_refptr<base::RefCountedBytes> data; |
1505 base::string16 title; | 1505 base::string16 title; |
1506 | 1506 |
1507 if (!GetPreviewDataAndTitle(&data, &title)) { | 1507 if (!GetPreviewDataAndTitle(&data, &title)) { |
1508 base::FundamentalValue http_code_value(-1); | 1508 base::Value http_code_value(-1); |
1509 web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed", | 1509 web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed", |
1510 http_code_value); | 1510 http_code_value); |
1511 return; | 1511 return; |
1512 } | 1512 } |
1513 | 1513 |
1514 privet_local_print_operation_->SetJobname(base::UTF16ToUTF8(title)); | 1514 privet_local_print_operation_->SetJobname(base::UTF16ToUTF8(title)); |
1515 privet_local_print_operation_->SetPageSize(page_size); | 1515 privet_local_print_operation_->SetPageSize(page_size); |
1516 privet_local_print_operation_->SetData(data.get()); | 1516 privet_local_print_operation_->SetData(data.get()); |
1517 | 1517 |
1518 Profile* profile = Profile::FromWebUI(web_ui()); | 1518 Profile* profile = Profile::FromWebUI(web_ui()); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1597 } | 1597 } |
1598 | 1598 |
1599 void PrintPreviewHandler::OnPrivetPrintingDone( | 1599 void PrintPreviewHandler::OnPrivetPrintingDone( |
1600 const cloud_print::PrivetLocalPrintOperation* print_operation) { | 1600 const cloud_print::PrivetLocalPrintOperation* print_operation) { |
1601 ClosePreviewDialog(); | 1601 ClosePreviewDialog(); |
1602 } | 1602 } |
1603 | 1603 |
1604 void PrintPreviewHandler::OnPrivetPrintingError( | 1604 void PrintPreviewHandler::OnPrivetPrintingError( |
1605 const cloud_print::PrivetLocalPrintOperation* print_operation, | 1605 const cloud_print::PrivetLocalPrintOperation* print_operation, |
1606 int http_code) { | 1606 int http_code) { |
1607 base::FundamentalValue http_code_value(http_code); | 1607 base::Value http_code_value(http_code); |
1608 web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed", | 1608 web_ui()->CallJavascriptFunctionUnsafe("onPrivetPrintFailed", |
1609 http_code_value); | 1609 http_code_value); |
1610 } | 1610 } |
1611 | 1611 |
1612 void PrintPreviewHandler::FillPrinterDescription( | 1612 void PrintPreviewHandler::FillPrinterDescription( |
1613 const std::string& name, | 1613 const std::string& name, |
1614 const cloud_print::DeviceDescription& description, | 1614 const cloud_print::DeviceDescription& description, |
1615 bool has_local_printing, | 1615 bool has_local_printing, |
1616 base::DictionaryValue* printer_value) { | 1616 base::DictionaryValue* printer_value) { |
1617 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 1617 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
(...skipping 14 matching lines...) Expand all Loading... |
1632 return; | 1632 return; |
1633 | 1633 |
1634 extension_printer_handler_ = | 1634 extension_printer_handler_ = |
1635 PrinterHandler::CreateForExtensionPrinters(Profile::FromWebUI(web_ui())); | 1635 PrinterHandler::CreateForExtensionPrinters(Profile::FromWebUI(web_ui())); |
1636 } | 1636 } |
1637 | 1637 |
1638 void PrintPreviewHandler::OnGotPrintersForExtension( | 1638 void PrintPreviewHandler::OnGotPrintersForExtension( |
1639 const base::ListValue& printers, | 1639 const base::ListValue& printers, |
1640 bool done) { | 1640 bool done) { |
1641 web_ui()->CallJavascriptFunctionUnsafe("onExtensionPrintersAdded", printers, | 1641 web_ui()->CallJavascriptFunctionUnsafe("onExtensionPrintersAdded", printers, |
1642 base::FundamentalValue(done)); | 1642 base::Value(done)); |
1643 } | 1643 } |
1644 | 1644 |
1645 void PrintPreviewHandler::OnGotExtensionPrinterInfo( | 1645 void PrintPreviewHandler::OnGotExtensionPrinterInfo( |
1646 const std::string& printer_id, | 1646 const std::string& printer_id, |
1647 const base::DictionaryValue& printer_info) { | 1647 const base::DictionaryValue& printer_info) { |
1648 if (printer_info.empty()) { | 1648 if (printer_info.empty()) { |
1649 web_ui()->CallJavascriptFunctionUnsafe("failedToResolveProvisionalPrinter", | 1649 web_ui()->CallJavascriptFunctionUnsafe("failedToResolveProvisionalPrinter", |
1650 base::StringValue(printer_id)); | 1650 base::StringValue(printer_id)); |
1651 return; | 1651 return; |
1652 } | 1652 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1697 | 1697 |
1698 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { | 1698 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { |
1699 if (gaia_cookie_manager_service_) | 1699 if (gaia_cookie_manager_service_) |
1700 gaia_cookie_manager_service_->RemoveObserver(this); | 1700 gaia_cookie_manager_service_->RemoveObserver(this); |
1701 } | 1701 } |
1702 | 1702 |
1703 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1703 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
1704 const base::Closure& closure) { | 1704 const base::Closure& closure) { |
1705 pdf_file_saved_closure_ = closure; | 1705 pdf_file_saved_closure_ = closure; |
1706 } | 1706 } |
OLD | NEW |