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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 CSS_BACKGROUND, | 134 CSS_BACKGROUND, |
135 SELECTION_ONLY, | 135 SELECTION_ONLY, |
136 EXTERNAL_PDF_PREVIEW, | 136 EXTERNAL_PDF_PREVIEW, |
137 PAGE_RANGE, | 137 PAGE_RANGE, |
138 DEFAULT_MEDIA, | 138 DEFAULT_MEDIA, |
139 NON_DEFAULT_MEDIA, | 139 NON_DEFAULT_MEDIA, |
140 COPIES, | 140 COPIES, |
141 NON_DEFAULT_MARGINS, | 141 NON_DEFAULT_MARGINS, |
142 DISTILL_PAGE_UNUSED, | 142 DISTILL_PAGE_UNUSED, |
143 SCALING, | 143 SCALING, |
| 144 PRINT_AS_IMAGE, |
144 PRINT_SETTINGS_BUCKET_BOUNDARY | 145 PRINT_SETTINGS_BUCKET_BOUNDARY |
145 }; | 146 }; |
146 | 147 |
147 void ReportUserActionHistogram(enum UserActionBuckets event) { | 148 void ReportUserActionHistogram(enum UserActionBuckets event) { |
148 UMA_HISTOGRAM_ENUMERATION("PrintPreview.UserAction", event, | 149 UMA_HISTOGRAM_ENUMERATION("PrintPreview.UserAction", event, |
149 USERACTION_BUCKET_BOUNDARY); | 150 USERACTION_BUCKET_BOUNDARY); |
150 } | 151 } |
151 | 152 |
152 void ReportPrintSettingHistogram(enum PrintSettingsBuckets setting) { | 153 void ReportPrintSettingHistogram(enum PrintSettingsBuckets setting) { |
153 UMA_HISTOGRAM_ENUMERATION("PrintPreview.PrintSettings", setting, | 154 UMA_HISTOGRAM_ENUMERATION("PrintPreview.PrintSettings", setting, |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 if (settings.GetBoolean(printing::kSettingShouldPrintSelectionOnly, | 282 if (settings.GetBoolean(printing::kSettingShouldPrintSelectionOnly, |
282 &selection_only) && selection_only) { | 283 &selection_only) && selection_only) { |
283 ReportPrintSettingHistogram(SELECTION_ONLY); | 284 ReportPrintSettingHistogram(SELECTION_ONLY); |
284 } | 285 } |
285 | 286 |
286 bool external_preview = false; | 287 bool external_preview = false; |
287 if (settings.GetBoolean(printing::kSettingOpenPDFInPreview, | 288 if (settings.GetBoolean(printing::kSettingOpenPDFInPreview, |
288 &external_preview) && external_preview) { | 289 &external_preview) && external_preview) { |
289 ReportPrintSettingHistogram(EXTERNAL_PDF_PREVIEW); | 290 ReportPrintSettingHistogram(EXTERNAL_PDF_PREVIEW); |
290 } | 291 } |
| 292 |
| 293 bool rasterize = false; |
| 294 if (settings.GetBoolean(printing::kSettingRasterizePdf, |
| 295 &rasterize) && rasterize) { |
| 296 ReportPrintSettingHistogram(PRINT_AS_IMAGE); |
| 297 } |
291 } | 298 } |
292 | 299 |
293 // Callback that stores a PDF file on disk. | 300 // Callback that stores a PDF file on disk. |
294 void PrintToPdfCallback(const scoped_refptr<base::RefCountedBytes>& data, | 301 void PrintToPdfCallback(const scoped_refptr<base::RefCountedBytes>& data, |
295 const base::FilePath& path, | 302 const base::FilePath& path, |
296 const base::Closure& pdf_file_saved_closure) { | 303 const base::Closure& pdf_file_saved_closure) { |
297 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 304 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); |
298 base::File file(path, | 305 base::File file(path, |
299 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); | 306 base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); |
300 file.WriteAtCurrentPos(reinterpret_cast<const char*>(data->front()), | 307 file.WriteAtCurrentPos(reinterpret_cast<const char*>(data->front()), |
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1716 | 1723 |
1717 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { | 1724 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { |
1718 if (gaia_cookie_manager_service_) | 1725 if (gaia_cookie_manager_service_) |
1719 gaia_cookie_manager_service_->RemoveObserver(this); | 1726 gaia_cookie_manager_service_->RemoveObserver(this); |
1720 } | 1727 } |
1721 | 1728 |
1722 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1729 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
1723 const base::Closure& closure) { | 1730 const base::Closure& closure) { |
1724 pdf_file_saved_closure_ = closure; | 1731 pdf_file_saved_closure_ = closure; |
1725 } | 1732 } |
OLD | NEW |