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 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 } | 742 } |
743 | 743 |
744 void PrintPreviewHandler::HandlePrint(const base::ListValue* args) { | 744 void PrintPreviewHandler::HandlePrint(const base::ListValue* args) { |
745 ReportStats(); | 745 ReportStats(); |
746 | 746 |
747 // Record the number of times the user requests to regenerate preview data | 747 // Record the number of times the user requests to regenerate preview data |
748 // before printing. | 748 // before printing. |
749 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", | 749 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", |
750 regenerate_preview_request_count_); | 750 regenerate_preview_request_count_); |
751 | 751 |
752 WebContents* initiator = GetInitiator(); | |
753 if (initiator) { | |
754 RenderViewHost* rvh = initiator->GetRenderViewHost(); | |
755 rvh->Send(new PrintMsg_ResetScriptedPrintCount(rvh->GetRoutingID())); | |
756 } | |
757 | |
758 scoped_ptr<base::DictionaryValue> settings(GetSettingsDictionary(args)); | 752 scoped_ptr<base::DictionaryValue> settings(GetSettingsDictionary(args)); |
759 if (!settings.get()) | 753 if (!settings.get()) |
760 return; | 754 return; |
761 | 755 |
762 // Never try to add headers/footers here. It's already in the generated PDF. | 756 // Never try to add headers/footers here. It's already in the generated PDF. |
763 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false); | 757 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false); |
764 | 758 |
765 bool print_to_pdf = false; | 759 bool print_to_pdf = false; |
766 bool is_cloud_printer = false; | 760 bool is_cloud_printer = false; |
767 bool print_with_privet = false; | 761 bool print_with_privet = false; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 settings->SetInteger(printing::kPreviewUIID, | 846 settings->SetInteger(printing::kPreviewUIID, |
853 print_preview_ui->GetIDForPrintPreviewUI()); | 847 print_preview_ui->GetIDForPrintPreviewUI()); |
854 RenderViewHost* rvh = preview_web_contents()->GetRenderViewHost(); | 848 RenderViewHost* rvh = preview_web_contents()->GetRenderViewHost(); |
855 rvh->Send(new PrintMsg_PrintForPrintPreview(rvh->GetRoutingID(), | 849 rvh->Send(new PrintMsg_PrintForPrintPreview(rvh->GetRoutingID(), |
856 *settings)); | 850 *settings)); |
857 | 851 |
858 // For all other cases above, the preview dialog will stay open until the | 852 // For all other cases above, the preview dialog will stay open until the |
859 // printing has finished. Then the dialog closes and PrintPreviewDone() gets | 853 // printing has finished. Then the dialog closes and PrintPreviewDone() gets |
860 // called. In the case below, since the preview dialog will be hidden and | 854 // called. In the case below, since the preview dialog will be hidden and |
861 // not closed, we need to make this call. | 855 // not closed, we need to make this call. |
| 856 WebContents* initiator = GetInitiator(); |
862 if (initiator) { | 857 if (initiator) { |
863 printing::PrintViewManager* print_view_manager = | 858 printing::PrintViewManager* print_view_manager = |
864 printing::PrintViewManager::FromWebContents(initiator); | 859 printing::PrintViewManager::FromWebContents(initiator); |
865 print_view_manager->PrintPreviewDone(); | 860 print_view_manager->PrintPreviewDone(); |
866 } | 861 } |
867 } | 862 } |
868 } | 863 } |
869 | 864 |
870 void PrintPreviewHandler::PrintToPdf() { | 865 void PrintPreviewHandler::PrintToPdf() { |
871 if (!print_to_pdf_path_.empty()) { | 866 if (!print_to_pdf_path_.empty()) { |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1561 | 1556 |
1562 void PrintPreviewHandler::UnregisterForMergeSession() { | 1557 void PrintPreviewHandler::UnregisterForMergeSession() { |
1563 if (reconcilor_) | 1558 if (reconcilor_) |
1564 reconcilor_->RemoveMergeSessionObserver(this); | 1559 reconcilor_->RemoveMergeSessionObserver(this); |
1565 } | 1560 } |
1566 | 1561 |
1567 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1562 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
1568 const base::Closure& closure) { | 1563 const base::Closure& closure) { |
1569 pdf_file_saved_closure_ = closure; | 1564 pdf_file_saved_closure_ = closure; |
1570 } | 1565 } |
OLD | NEW |