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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 #include "content/public/browser/navigation_controller.h" | 71 #include "content/public/browser/navigation_controller.h" |
72 #include "content/public/browser/navigation_entry.h" | 72 #include "content/public/browser/navigation_entry.h" |
73 #include "content/public/browser/render_process_host.h" | 73 #include "content/public/browser/render_process_host.h" |
74 #include "content/public/browser/render_view_host.h" | 74 #include "content/public/browser/render_view_host.h" |
75 #include "content/public/browser/web_contents.h" | 75 #include "content/public/browser/web_contents.h" |
76 #include "content/public/browser/web_ui.h" | 76 #include "content/public/browser/web_ui.h" |
77 #include "google_apis/gaia/oauth2_token_service.h" | 77 #include "google_apis/gaia/oauth2_token_service.h" |
78 #include "net/base/url_util.h" | 78 #include "net/base/url_util.h" |
79 #include "printing/backend/print_backend.h" | 79 #include "printing/backend/print_backend.h" |
80 #include "printing/backend/print_backend_consts.h" | 80 #include "printing/backend/print_backend_consts.h" |
| 81 #include "printing/features/features.h" |
81 #include "printing/pdf_render_settings.h" | 82 #include "printing/pdf_render_settings.h" |
82 #include "printing/print_settings.h" | 83 #include "printing/print_settings.h" |
83 #include "printing/printing_context.h" | 84 #include "printing/printing_context.h" |
84 #include "printing/units.h" | 85 #include "printing/units.h" |
85 #include "third_party/icu/source/i18n/unicode/ulocdata.h" | 86 #include "third_party/icu/source/i18n/unicode/ulocdata.h" |
86 | 87 |
87 #if defined(OS_CHROMEOS) | 88 #if defined(OS_CHROMEOS) |
88 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" | 89 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" |
89 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" | 90 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" |
90 #include "chrome/common/url_constants.h" | 91 #include "chrome/common/url_constants.h" |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 // Nothing to print, no preview available. | 964 // Nothing to print, no preview available. |
964 return; | 965 return; |
965 } | 966 } |
966 | 967 |
967 if (is_cloud_printer) { | 968 if (is_cloud_printer) { |
968 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToCloudPrint", | 969 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToCloudPrint", |
969 page_count); | 970 page_count); |
970 ReportUserActionHistogram(PRINT_WITH_CLOUD_PRINT); | 971 ReportUserActionHistogram(PRINT_WITH_CLOUD_PRINT); |
971 SendCloudPrintJob(data.get()); | 972 SendCloudPrintJob(data.get()); |
972 } else { | 973 } else { |
973 #if defined(ENABLE_BASIC_PRINTING) | 974 #if BUILDFLAG(ENABLE_BASIC_PRINTING) |
974 bool system_dialog = false; | 975 bool system_dialog = false; |
975 settings->GetBoolean(printing::kSettingShowSystemDialog, &system_dialog); | 976 settings->GetBoolean(printing::kSettingShowSystemDialog, &system_dialog); |
976 if (system_dialog) { | 977 if (system_dialog) { |
977 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.SystemDialog", page_count); | 978 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.SystemDialog", page_count); |
978 ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG); | 979 ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG); |
979 } else { | 980 } else { |
980 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count); | 981 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count); |
981 ReportUserActionHistogram(PRINT_TO_PRINTER); | 982 ReportUserActionHistogram(PRINT_TO_PRINTER); |
982 } | 983 } |
983 | 984 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 // printing has finished. Then the dialog closes and PrintPreviewDone() gets | 1017 // printing has finished. Then the dialog closes and PrintPreviewDone() gets |
1017 // called. In the case below, since the preview dialog will be hidden and | 1018 // called. In the case below, since the preview dialog will be hidden and |
1018 // not closed, we need to make this call. | 1019 // not closed, we need to make this call. |
1019 if (initiator) { | 1020 if (initiator) { |
1020 printing::PrintViewManager* print_view_manager = | 1021 printing::PrintViewManager* print_view_manager = |
1021 printing::PrintViewManager::FromWebContents(initiator); | 1022 printing::PrintViewManager::FromWebContents(initiator); |
1022 print_view_manager->PrintPreviewDone(); | 1023 print_view_manager->PrintPreviewDone(); |
1023 } | 1024 } |
1024 #else | 1025 #else |
1025 NOTREACHED(); | 1026 NOTREACHED(); |
1026 #endif // defined(ENABLE_BASIC_PRINTING) | 1027 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) |
1027 } | 1028 } |
1028 } | 1029 } |
1029 | 1030 |
1030 void PrintPreviewHandler::PrintToPdf() { | 1031 void PrintPreviewHandler::PrintToPdf() { |
1031 if (!print_to_pdf_path_.empty()) { | 1032 if (!print_to_pdf_path_.empty()) { |
1032 // User has already selected a path, no need to show the dialog again. | 1033 // User has already selected a path, no need to show the dialog again. |
1033 PostPrintToPdfTask(); | 1034 PostPrintToPdfTask(); |
1034 } else if (!select_file_dialog_.get() || | 1035 } else if (!select_file_dialog_.get() || |
1035 !select_file_dialog_->IsRunning(platform_util::GetTopLevel( | 1036 !select_file_dialog_->IsRunning(platform_util::GetTopLevel( |
1036 preview_web_contents()->GetNativeView()))) { | 1037 preview_web_contents()->GetNativeView()))) { |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1765 | 1766 |
1766 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { | 1767 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { |
1767 if (gaia_cookie_manager_service_) | 1768 if (gaia_cookie_manager_service_) |
1768 gaia_cookie_manager_service_->RemoveObserver(this); | 1769 gaia_cookie_manager_service_->RemoveObserver(this); |
1769 } | 1770 } |
1770 | 1771 |
1771 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1772 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
1772 const base::Closure& closure) { | 1773 const base::Closure& closure) { |
1773 pdf_file_saved_closure_ = closure; | 1774 pdf_file_saved_closure_ = closure; |
1774 } | 1775 } |
OLD | NEW |