| 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 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 return; | 882 return; |
| 883 } | 883 } |
| 884 #endif | 884 #endif |
| 885 | 885 |
| 886 if (print_with_extension) { | 886 if (print_with_extension) { |
| 887 // TODO(tbarzic): Record UMA stats. | 887 // TODO(tbarzic): Record UMA stats. |
| 888 | 888 |
| 889 std::string destination_id; | 889 std::string destination_id; |
| 890 std::string print_ticket; | 890 std::string print_ticket; |
| 891 std::string capabilities; | 891 std::string capabilities; |
| 892 int width = 0; |
| 893 int height = 0; |
| 892 if (!settings->GetString(printing::kSettingDeviceName, &destination_id) || | 894 if (!settings->GetString(printing::kSettingDeviceName, &destination_id) || |
| 893 !settings->GetString(printing::kSettingTicket, &print_ticket) || | 895 !settings->GetString(printing::kSettingTicket, &print_ticket) || |
| 894 !settings->GetString(printing::kSettingCapabilities, &capabilities)) { | 896 !settings->GetString(printing::kSettingCapabilities, &capabilities) || |
| 897 !settings->GetInteger(printing::kSettingPageWidth, &width) || |
| 898 !settings->GetInteger(printing::kSettingPageHeight, &height) || |
| 899 width <= 0 || height <= 0) { |
| 895 NOTREACHED(); | 900 NOTREACHED(); |
| 896 OnExtensionPrintResult(false, "FAILED"); | 901 OnExtensionPrintResult(false, "FAILED"); |
| 897 return; | 902 return; |
| 898 } | 903 } |
| 899 | 904 |
| 900 base::string16 title; | 905 base::string16 title; |
| 901 scoped_refptr<base::RefCountedBytes> data; | 906 scoped_refptr<base::RefCountedBytes> data; |
| 902 if (!GetPreviewDataAndTitle(&data, &title)) { | 907 if (!GetPreviewDataAndTitle(&data, &title)) { |
| 903 LOG(ERROR) << "Nothing to print; no preview available."; | 908 LOG(ERROR) << "Nothing to print; no preview available."; |
| 904 OnExtensionPrintResult(false, "NO_DATA"); | 909 OnExtensionPrintResult(false, "NO_DATA"); |
| 905 return; | 910 return; |
| 906 } | 911 } |
| 907 | 912 |
| 908 EnsureExtensionPrinterHandlerSet(); | 913 EnsureExtensionPrinterHandlerSet(); |
| 909 extension_printer_handler_->StartPrint( | 914 extension_printer_handler_->StartPrint( |
| 910 destination_id, capabilities, print_ticket, data, | 915 destination_id, capabilities, print_ticket, gfx::Size(width, height), |
| 911 base::Bind(&PrintPreviewHandler::OnExtensionPrintResult, | 916 data, base::Bind(&PrintPreviewHandler::OnExtensionPrintResult, |
| 912 base::Unretained(this))); | 917 base::Unretained(this))); |
| 913 return; | 918 return; |
| 914 } | 919 } |
| 915 | 920 |
| 916 scoped_refptr<base::RefCountedBytes> data; | 921 scoped_refptr<base::RefCountedBytes> data; |
| 917 base::string16 title; | 922 base::string16 title; |
| 918 if (!GetPreviewDataAndTitle(&data, &title)) { | 923 if (!GetPreviewDataAndTitle(&data, &title)) { |
| 919 // Nothing to print, no preview available. | 924 // Nothing to print, no preview available. |
| 920 return; | 925 return; |
| 921 } | 926 } |
| 922 | 927 |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 | 1711 |
| 1707 void PrintPreviewHandler::UnregisterForMergeSession() { | 1712 void PrintPreviewHandler::UnregisterForMergeSession() { |
| 1708 if (reconcilor_) | 1713 if (reconcilor_) |
| 1709 reconcilor_->RemoveMergeSessionObserver(this); | 1714 reconcilor_->RemoveMergeSessionObserver(this); |
| 1710 } | 1715 } |
| 1711 | 1716 |
| 1712 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1717 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
| 1713 const base::Closure& closure) { | 1718 const base::Closure& closure) { |
| 1714 pdf_file_saved_closure_ = closure; | 1719 pdf_file_saved_closure_ = closure; |
| 1715 } | 1720 } |
| OLD | NEW |