| 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 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 // Nothing to print, no preview available. | 821 // Nothing to print, no preview available. |
| 822 return; | 822 return; |
| 823 } | 823 } |
| 824 | 824 |
| 825 if (is_cloud_printer) { | 825 if (is_cloud_printer) { |
| 826 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToCloudPrint", | 826 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToCloudPrint", |
| 827 page_count); | 827 page_count); |
| 828 ReportUserActionHistogram(PRINT_WITH_CLOUD_PRINT); | 828 ReportUserActionHistogram(PRINT_WITH_CLOUD_PRINT); |
| 829 SendCloudPrintJob(data.get()); | 829 SendCloudPrintJob(data.get()); |
| 830 } else { | 830 } else { |
| 831 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count); | 831 bool system_dialog = false; |
| 832 ReportUserActionHistogram(PRINT_TO_PRINTER); | 832 settings->GetBoolean(printing::kSettingShowSystemDialog, &system_dialog); |
| 833 if (system_dialog) { |
| 834 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.SystemDialog", page_count); |
| 835 ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG); |
| 836 } else { |
| 837 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count); |
| 838 ReportUserActionHistogram(PRINT_TO_PRINTER); |
| 839 } |
| 833 ReportPrintSettingsStats(*settings); | 840 ReportPrintSettingsStats(*settings); |
| 834 | 841 |
| 835 // This tries to activate the initiator as well, so do not clear the | 842 // This tries to activate the initiator as well, so do not clear the |
| 836 // association with the initiator yet. | 843 // association with the initiator yet. |
| 837 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( | 844 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( |
| 838 web_ui()->GetController()); | 845 web_ui()->GetController()); |
| 839 print_preview_ui->OnHidePreviewDialog(); | 846 print_preview_ui->OnHidePreviewDialog(); |
| 840 | 847 |
| 841 // Do this so the initiator can open a new print preview dialog, while the | 848 // Do this so the initiator can open a new print preview dialog, while the |
| 842 // current print preview dialog is still handling its print job. | 849 // current print preview dialog is still handling its print job. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 WebContents* initiator = GetInitiator(); | 1025 WebContents* initiator = GetInitiator(); |
| 1019 if (!initiator) | 1026 if (!initiator) |
| 1020 return; | 1027 return; |
| 1021 | 1028 |
| 1022 printing::PrintViewManager* print_view_manager = | 1029 printing::PrintViewManager* print_view_manager = |
| 1023 printing::PrintViewManager::FromWebContents(initiator); | 1030 printing::PrintViewManager::FromWebContents(initiator); |
| 1024 print_view_manager->set_observer(this); | 1031 print_view_manager->set_observer(this); |
| 1025 print_view_manager->PrintForSystemDialogNow(); | 1032 print_view_manager->PrintForSystemDialogNow(); |
| 1026 | 1033 |
| 1027 // Cancel the pending preview request if exists. | 1034 // Cancel the pending preview request if exists. |
| 1028 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( | 1035 PrintPreviewUI* print_preview_ui = |
| 1029 web_ui()->GetController()); | 1036 static_cast<PrintPreviewUI*>(web_ui()->GetController()); |
| 1030 print_preview_ui->OnCancelPendingPreviewRequest(); | 1037 print_preview_ui->OnCancelPendingPreviewRequest(); |
| 1031 } | 1038 } |
| 1032 | 1039 |
| 1033 void PrintPreviewHandler::HandleManagePrinters( | 1040 void PrintPreviewHandler::HandleManagePrinters( |
| 1034 const base::ListValue* /*args*/) { | 1041 const base::ListValue* /*args*/) { |
| 1035 ++manage_printers_dialog_request_count_; | 1042 ++manage_printers_dialog_request_count_; |
| 1036 printing::PrinterManagerDialog::ShowPrinterManagerDialog(); | 1043 printing::PrinterManagerDialog::ShowPrinterManagerDialog(); |
| 1037 } | 1044 } |
| 1038 | 1045 |
| 1039 void PrintPreviewHandler::HandlePrintWithCloudPrintDialog( | 1046 void PrintPreviewHandler::HandlePrintWithCloudPrintDialog( |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 | 1568 |
| 1562 void PrintPreviewHandler::UnregisterForMergeSession() { | 1569 void PrintPreviewHandler::UnregisterForMergeSession() { |
| 1563 if (reconcilor_) | 1570 if (reconcilor_) |
| 1564 reconcilor_->RemoveMergeSessionObserver(this); | 1571 reconcilor_->RemoveMergeSessionObserver(this); |
| 1565 } | 1572 } |
| 1566 | 1573 |
| 1567 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1574 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
| 1568 const base::Closure& closure) { | 1575 const base::Closure& closure) { |
| 1569 pdf_file_saved_closure_ = closure; | 1576 pdf_file_saved_closure_ = closure; |
| 1570 } | 1577 } |
| OLD | NEW |