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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 if (settings.GetBoolean(printing::kSettingOpenPDFInPreview, | 284 if (settings.GetBoolean(printing::kSettingOpenPDFInPreview, |
285 &external_preview) && external_preview) { | 285 &external_preview) && external_preview) { |
286 ReportPrintSettingHistogram(EXTERNAL_PDF_PREVIEW); | 286 ReportPrintSettingHistogram(EXTERNAL_PDF_PREVIEW); |
287 } | 287 } |
288 | 288 |
289 bool distill_page = false; | 289 bool distill_page = false; |
290 if (settings.GetBoolean(printing::kSettingDistillPageEnabled, | 290 if (settings.GetBoolean(printing::kSettingDistillPageEnabled, |
291 &distill_page) && distill_page) { | 291 &distill_page) && distill_page) { |
292 ReportPrintSettingHistogram(DISTILL_PAGE); | 292 ReportPrintSettingHistogram(DISTILL_PAGE); |
293 } | 293 } |
294 | |
295 } | 294 } |
296 | 295 |
297 // Callback that stores a PDF file on disk. | 296 // Callback that stores a PDF file on disk. |
298 void PrintToPdfCallback(const scoped_refptr<base::RefCountedBytes>& data, | 297 void PrintToPdfCallback(const scoped_refptr<base::RefCountedBytes>& data, |
299 const base::FilePath& path, | 298 const base::FilePath& path, |
300 const base::Closure& pdf_file_saved_closure) { | 299 const base::Closure& pdf_file_saved_closure) { |
301 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 300 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
302 printing::PdfMetafileSkia metafile; | 301 printing::PdfMetafileSkia metafile; |
303 metafile.InitFromData(static_cast<const void*>(data->front()), data->size()); | 302 metafile.InitFromData(static_cast<const void*>(data->front()), data->size()); |
304 base::File file(path, | 303 base::File file(path, |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 // Nothing to print, no preview available. | 996 // Nothing to print, no preview available. |
998 return; | 997 return; |
999 } | 998 } |
1000 | 999 |
1001 if (is_cloud_printer) { | 1000 if (is_cloud_printer) { |
1002 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToCloudPrint", | 1001 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToCloudPrint", |
1003 page_count); | 1002 page_count); |
1004 ReportUserActionHistogram(PRINT_WITH_CLOUD_PRINT); | 1003 ReportUserActionHistogram(PRINT_WITH_CLOUD_PRINT); |
1005 SendCloudPrintJob(data.get()); | 1004 SendCloudPrintJob(data.get()); |
1006 } else { | 1005 } else { |
| 1006 #if defined(ENABLE_BASIC_PRINTING) |
1007 bool system_dialog = false; | 1007 bool system_dialog = false; |
1008 settings->GetBoolean(printing::kSettingShowSystemDialog, &system_dialog); | 1008 settings->GetBoolean(printing::kSettingShowSystemDialog, &system_dialog); |
1009 if (system_dialog) { | 1009 if (system_dialog) { |
1010 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.SystemDialog", page_count); | 1010 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.SystemDialog", page_count); |
1011 ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG); | 1011 ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG); |
1012 } else { | 1012 } else { |
1013 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count); | 1013 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count); |
1014 ReportUserActionHistogram(PRINT_TO_PRINTER); | 1014 ReportUserActionHistogram(PRINT_TO_PRINTER); |
1015 } | 1015 } |
1016 | 1016 |
(...skipping 30 matching lines...) Expand all Loading... |
1047 | 1047 |
1048 // For all other cases above, the preview dialog will stay open until the | 1048 // For all other cases above, the preview dialog will stay open until the |
1049 // printing has finished. Then the dialog closes and PrintPreviewDone() gets | 1049 // printing has finished. Then the dialog closes and PrintPreviewDone() gets |
1050 // called. In the case below, since the preview dialog will be hidden and | 1050 // called. In the case below, since the preview dialog will be hidden and |
1051 // not closed, we need to make this call. | 1051 // not closed, we need to make this call. |
1052 if (initiator) { | 1052 if (initiator) { |
1053 printing::PrintViewManager* print_view_manager = | 1053 printing::PrintViewManager* print_view_manager = |
1054 printing::PrintViewManager::FromWebContents(initiator); | 1054 printing::PrintViewManager::FromWebContents(initiator); |
1055 print_view_manager->PrintPreviewDone(); | 1055 print_view_manager->PrintPreviewDone(); |
1056 } | 1056 } |
| 1057 #else |
| 1058 NOTREACHED(); |
| 1059 #endif // defined(ENABLE_BASIC_PRINTING) |
1057 } | 1060 } |
1058 } | 1061 } |
1059 | 1062 |
1060 void PrintPreviewHandler::PrintToPdf() { | 1063 void PrintPreviewHandler::PrintToPdf() { |
1061 if (!print_to_pdf_path_.empty()) { | 1064 if (!print_to_pdf_path_.empty()) { |
1062 // User has already selected a path, no need to show the dialog again. | 1065 // User has already selected a path, no need to show the dialog again. |
1063 PostPrintToPdfTask(); | 1066 PostPrintToPdfTask(); |
1064 } else if (!select_file_dialog_.get() || | 1067 } else if (!select_file_dialog_.get() || |
1065 !select_file_dialog_->IsRunning(platform_util::GetTopLevel( | 1068 !select_file_dialog_->IsRunning(platform_util::GetTopLevel( |
1066 preview_web_contents()->GetNativeView()))) { | 1069 preview_web_contents()->GetNativeView()))) { |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1820 | 1823 |
1821 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { | 1824 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { |
1822 if (gaia_cookie_manager_service_) | 1825 if (gaia_cookie_manager_service_) |
1823 gaia_cookie_manager_service_->RemoveObserver(this); | 1826 gaia_cookie_manager_service_->RemoveObserver(this); |
1824 } | 1827 } |
1825 | 1828 |
1826 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1829 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
1827 const base::Closure& closure) { | 1830 const base::Closure& closure) { |
1828 pdf_file_saved_closure_ = closure; | 1831 pdf_file_saved_closure_ = closure; |
1829 } | 1832 } |
OLD | NEW |