Chromium Code Reviews| 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 #include "chrome/browser/printing/cloud_print/privet_constants.h" | 100 #include "chrome/browser/printing/cloud_print/privet_constants.h" |
| 101 #endif | 101 #endif |
| 102 | 102 |
| 103 using content::BrowserThread; | 103 using content::BrowserThread; |
| 104 using content::RenderFrameHost; | 104 using content::RenderFrameHost; |
| 105 using content::WebContents; | 105 using content::WebContents; |
| 106 using printing::PrintViewManager; | 106 using printing::PrintViewManager; |
| 107 | 107 |
| 108 namespace { | 108 namespace { |
| 109 | 109 |
| 110 // This enum is used to back an UMA histogram, and should therefore be treated | |
| 111 // as append only. | |
| 110 enum UserActionBuckets { | 112 enum UserActionBuckets { |
| 111 PRINT_TO_PRINTER, | 113 PRINT_TO_PRINTER, |
| 112 PRINT_TO_PDF, | 114 PRINT_TO_PDF, |
| 113 CANCEL, | 115 CANCEL, |
| 114 FALLBACK_TO_ADVANCED_SETTINGS_DIALOG, | 116 FALLBACK_TO_ADVANCED_SETTINGS_DIALOG, |
| 115 PREVIEW_FAILED, | 117 PREVIEW_FAILED, |
| 116 PREVIEW_STARTED, | 118 PREVIEW_STARTED, |
| 117 INITIATOR_CRASHED_UNUSED, | 119 INITIATOR_CRASHED_UNUSED, |
| 118 INITIATOR_CLOSED, | 120 INITIATOR_CLOSED, |
| 119 PRINT_WITH_CLOUD_PRINT, | 121 PRINT_WITH_CLOUD_PRINT, |
| 120 PRINT_WITH_PRIVET, | 122 PRINT_WITH_PRIVET, |
| 121 PRINT_WITH_EXTENSION, | 123 PRINT_WITH_EXTENSION, |
| 122 USERACTION_BUCKET_BOUNDARY | 124 USERACTION_BUCKET_BOUNDARY |
| 123 }; | 125 }; |
| 124 | 126 |
| 127 // This enum is used to back an UMA histogram, and should therefore be treated | |
| 128 // as append only. | |
| 125 enum PrintSettingsBuckets { | 129 enum PrintSettingsBuckets { |
| 126 LANDSCAPE = 0, | 130 LANDSCAPE = 0, |
| 127 PORTRAIT, | 131 PORTRAIT, |
| 128 COLOR, | 132 COLOR, |
| 129 BLACK_AND_WHITE, | 133 BLACK_AND_WHITE, |
| 130 COLLATE, | 134 COLLATE, |
| 131 SIMPLEX, | 135 SIMPLEX, |
| 132 DUPLEX, | 136 DUPLEX, |
| 133 TOTAL, | 137 TOTAL, |
| 134 HEADERS_AND_FOOTERS, | 138 HEADERS_AND_FOOTERS, |
| 135 CSS_BACKGROUND, | 139 CSS_BACKGROUND, |
| 136 SELECTION_ONLY, | 140 SELECTION_ONLY, |
| 137 EXTERNAL_PDF_PREVIEW, | 141 EXTERNAL_PDF_PREVIEW, |
| 138 PAGE_RANGE, | 142 PAGE_RANGE, |
| 139 DEFAULT_MEDIA, | 143 DEFAULT_MEDIA, |
| 140 NON_DEFAULT_MEDIA, | 144 NON_DEFAULT_MEDIA, |
| 141 COPIES, | 145 COPIES, |
| 142 NON_DEFAULT_MARGINS, | 146 NON_DEFAULT_MARGINS, |
| 143 DISTILL_PAGE_UNUSED, | 147 DISTILL_PAGE_UNUSED, |
| 144 SCALING, | 148 SCALING, |
| 145 PRINT_SETTINGS_BUCKET_BOUNDARY | 149 PRINT_SETTINGS_BUCKET_BOUNDARY |
| 146 }; | 150 }; |
| 147 | 151 |
| 152 // This enum is used to back an UMA histogram, and should therefore be treated | |
| 153 // as append only. | |
| 154 enum PrintDocumentTypeBuckets { | |
| 155 HTML_DOCUMENT = 0, | |
|
Lei Zhang
2017/02/25 01:04:01
Maybe we should see how often users print images t
| |
| 156 PDF_DOCUMENT, | |
| 157 PRINT_DOCUMENT_TYPE_BUCKET_BOUNDARY | |
| 158 }; | |
| 159 | |
| 148 void ReportUserActionHistogram(enum UserActionBuckets event) { | 160 void ReportUserActionHistogram(enum UserActionBuckets event) { |
| 149 UMA_HISTOGRAM_ENUMERATION("PrintPreview.UserAction", event, | 161 UMA_HISTOGRAM_ENUMERATION("PrintPreview.UserAction", event, |
| 150 USERACTION_BUCKET_BOUNDARY); | 162 USERACTION_BUCKET_BOUNDARY); |
| 151 } | 163 } |
| 152 | 164 |
| 153 void ReportPrintSettingHistogram(enum PrintSettingsBuckets setting) { | 165 void ReportPrintSettingHistogram(enum PrintSettingsBuckets setting) { |
| 154 UMA_HISTOGRAM_ENUMERATION("PrintPreview.PrintSettings", setting, | 166 UMA_HISTOGRAM_ENUMERATION("PrintPreview.PrintSettings", setting, |
| 155 PRINT_SETTINGS_BUCKET_BOUNDARY); | 167 PRINT_SETTINGS_BUCKET_BOUNDARY); |
| 156 } | 168 } |
| 157 | 169 |
| 170 void ReportPrintDocumentTypeHistogram(enum PrintDocumentTypeBuckets doctype) { | |
| 171 UMA_HISTOGRAM_ENUMERATION("PrintPreview.PrintDocumentType", doctype, | |
| 172 PRINT_DOCUMENT_TYPE_BUCKET_BOUNDARY); | |
| 173 } | |
| 174 | |
| 158 // Name of a dictionary field holding cloud print related data; | 175 // Name of a dictionary field holding cloud print related data; |
| 159 const char kAppState[] = "appState"; | 176 const char kAppState[] = "appState"; |
| 160 // Name of a dictionary field holding the initiator title. | 177 // Name of a dictionary field holding the initiator title. |
| 161 const char kInitiatorTitle[] = "initiatorTitle"; | 178 const char kInitiatorTitle[] = "initiatorTitle"; |
| 162 // Name of a dictionary field holding the measurement system according to the | 179 // Name of a dictionary field holding the measurement system according to the |
| 163 // locale. | 180 // locale. |
| 164 const char kMeasurementSystem[] = "measurementSystem"; | 181 const char kMeasurementSystem[] = "measurementSystem"; |
| 165 // Name of a dictionary field holding the number format according to the locale. | 182 // Name of a dictionary field holding the number format according to the locale. |
| 166 const char kNumberFormat[] = "numberFormat"; | 183 const char kNumberFormat[] = "numberFormat"; |
| 167 // Name of a dictionary field specifying whether to print automatically in | 184 // Name of a dictionary field specifying whether to print automatically in |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 797 // before printing. | 814 // before printing. |
| 798 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", | 815 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", |
| 799 regenerate_preview_request_count_); | 816 regenerate_preview_request_count_); |
| 800 | 817 |
| 801 std::unique_ptr<base::DictionaryValue> settings = GetSettingsDictionary(args); | 818 std::unique_ptr<base::DictionaryValue> settings = GetSettingsDictionary(args); |
| 802 if (!settings) | 819 if (!settings) |
| 803 return; | 820 return; |
| 804 | 821 |
| 805 ReportPrintSettingsStats(*settings); | 822 ReportPrintSettingsStats(*settings); |
| 806 | 823 |
| 824 // Report whether the user printed a PDF or an HTML document. | |
| 825 ReportPrintDocumentTypeHistogram(print_preview_ui()->source_is_modifiable() ? | |
| 826 HTML_DOCUMENT : PDF_DOCUMENT); | |
| 827 | |
| 807 // Never try to add headers/footers here. It's already in the generated PDF. | 828 // Never try to add headers/footers here. It's already in the generated PDF. |
| 808 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false); | 829 settings->SetBoolean(printing::kSettingHeaderFooterEnabled, false); |
| 809 | 830 |
| 810 bool print_to_pdf = false; | 831 bool print_to_pdf = false; |
| 811 bool is_cloud_printer = false; | 832 bool is_cloud_printer = false; |
| 812 bool print_with_privet = false; | 833 bool print_with_privet = false; |
| 813 bool print_with_extension = false; | 834 bool print_with_extension = false; |
| 814 | 835 |
| 815 bool open_pdf_in_preview = false; | 836 bool open_pdf_in_preview = false; |
| 816 #if defined(OS_MACOSX) | 837 #if defined(OS_MACOSX) |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1717 | 1738 |
| 1718 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { | 1739 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { |
| 1719 if (gaia_cookie_manager_service_) | 1740 if (gaia_cookie_manager_service_) |
| 1720 gaia_cookie_manager_service_->RemoveObserver(this); | 1741 gaia_cookie_manager_service_->RemoveObserver(this); |
| 1721 } | 1742 } |
| 1722 | 1743 |
| 1723 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1744 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
| 1724 const base::Closure& closure) { | 1745 const base::Closure& closure) { |
| 1725 pdf_file_saved_closure_ = closure; | 1746 pdf_file_saved_closure_ = closure; |
| 1726 } | 1747 } |
| OLD | NEW |