Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: chrome/browser/ui/webui/print_preview/print_preview_handler.cc

Issue 10387162: Add additional stats for print preview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add signin tracking Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/print_preview/print_preview_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 LANDSCAPE, 88 LANDSCAPE,
89 PORTRAIT, 89 PORTRAIT,
90 COLOR, 90 COLOR,
91 BLACK_AND_WHITE, 91 BLACK_AND_WHITE,
92 COLLATE, 92 COLLATE,
93 SIMPLEX, 93 SIMPLEX,
94 DUPLEX, 94 DUPLEX,
95 PRINT_SETTINGS_BUCKET_BOUNDARY 95 PRINT_SETTINGS_BUCKET_BOUNDARY
96 }; 96 };
97 97
98 enum PrintDestinationBuckets {
99 DESTINATION_SHOWN,
100 DESTINATION_CLOSED_CHANGED,
101 DESTINATION_CLOSED_UNCHANGED,
102 SIGNIN_PROMPT,
103 SIGNIN_TRIGGERED,
104 PRINT_DESTINATION_BUCKET_BOUNDARY
105 };
106
98 void ReportUserActionHistogram(enum UserActionBuckets event) { 107 void ReportUserActionHistogram(enum UserActionBuckets event) {
99 UMA_HISTOGRAM_ENUMERATION("PrintPreview.UserAction", event, 108 UMA_HISTOGRAM_ENUMERATION("PrintPreview.UserAction", event,
100 USERACTION_BUCKET_BOUNDARY); 109 USERACTION_BUCKET_BOUNDARY);
101 } 110 }
102 111
103 void ReportPrintSettingHistogram(enum PrintSettingsBuckets setting) { 112 void ReportPrintSettingHistogram(enum PrintSettingsBuckets setting) {
104 UMA_HISTOGRAM_ENUMERATION("PrintPreview.PrintSettings", setting, 113 UMA_HISTOGRAM_ENUMERATION("PrintPreview.PrintSettings", setting,
105 PRINT_SETTINGS_BUCKET_BOUNDARY); 114 PRINT_SETTINGS_BUCKET_BOUNDARY);
106 } 115 }
107 116
117 void ReportPrintDestinationHistogram(enum PrintDestinationBuckets event) {
118 UMA_HISTOGRAM_ENUMERATION("PrintPreview.DestinationAction", event,
119 PRINT_DESTINATION_BUCKET_BOUNDARY);
120 }
121
108 // Name of a dictionary fielad holdong cloud print related data; 122 // Name of a dictionary fielad holdong cloud print related data;
109 const char kCloudPrintData[] = "cloudPrintData"; 123 const char kCloudPrintData[] = "cloudPrintData";
110 // Name of a dictionary field holding the initiator tab title. 124 // Name of a dictionary field holding the initiator tab title.
111 const char kInitiatorTabTitle[] = "initiatorTabTitle"; 125 const char kInitiatorTabTitle[] = "initiatorTabTitle";
112 // Name of a dictionary field holding the measurement system according to the 126 // Name of a dictionary field holding the measurement system according to the
113 // locale. 127 // locale.
114 const char kMeasurementSystem[] = "measurementSystem"; 128 const char kMeasurementSystem[] = "measurementSystem";
115 // Name of a dictionary field holding the number format according to the locale. 129 // Name of a dictionary field holding the number format according to the locale.
116 const char kNumberFormat[] = "numberFormat"; 130 const char kNumberFormat[] = "numberFormat";
117 // Name of a dictionary field specifying whether to print automatically in 131 // Name of a dictionary field specifying whether to print automatically in
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 217
204 // static 218 // static
205 printing::StickySettings* PrintPreviewHandler::GetStickySettings() { 219 printing::StickySettings* PrintPreviewHandler::GetStickySettings() {
206 return sticky_settings.Pointer(); 220 return sticky_settings.Pointer();
207 } 221 }
208 222
209 PrintPreviewHandler::PrintPreviewHandler() 223 PrintPreviewHandler::PrintPreviewHandler()
210 : print_backend_(printing::PrintBackend::CreateInstance(NULL)), 224 : print_backend_(printing::PrintBackend::CreateInstance(NULL)),
211 regenerate_preview_request_count_(0), 225 regenerate_preview_request_count_(0),
212 manage_printers_dialog_request_count_(0), 226 manage_printers_dialog_request_count_(0),
227 manage_cloud_printers_dialog_request_count_(0),
213 reported_failed_preview_(false), 228 reported_failed_preview_(false),
214 has_logged_printers_count_(false) { 229 has_logged_printers_count_(false) {
215 ReportUserActionHistogram(PREVIEW_STARTED); 230 ReportUserActionHistogram(PREVIEW_STARTED);
216 } 231 }
217 232
218 PrintPreviewHandler::~PrintPreviewHandler() { 233 PrintPreviewHandler::~PrintPreviewHandler() {
219 if (select_file_dialog_.get()) 234 if (select_file_dialog_.get())
220 select_file_dialog_->ListenerDestroyed(); 235 select_file_dialog_->ListenerDestroyed();
221 } 236 }
222 237
(...skipping 30 matching lines...) Expand all
253 base::Unretained(this))); 268 base::Unretained(this)));
254 web_ui()->RegisterMessageCallback("cancelPendingPrintRequest", 269 web_ui()->RegisterMessageCallback("cancelPendingPrintRequest",
255 base::Bind(&PrintPreviewHandler::HandleCancelPendingPrintRequest, 270 base::Bind(&PrintPreviewHandler::HandleCancelPendingPrintRequest,
256 base::Unretained(this))); 271 base::Unretained(this)));
257 web_ui()->RegisterMessageCallback("saveLastPrinter", 272 web_ui()->RegisterMessageCallback("saveLastPrinter",
258 base::Bind(&PrintPreviewHandler::HandleSaveLastPrinter, 273 base::Bind(&PrintPreviewHandler::HandleSaveLastPrinter,
259 base::Unretained(this))); 274 base::Unretained(this)));
260 web_ui()->RegisterMessageCallback("getInitialSettings", 275 web_ui()->RegisterMessageCallback("getInitialSettings",
261 base::Bind(&PrintPreviewHandler::HandleGetInitialSettings, 276 base::Bind(&PrintPreviewHandler::HandleGetInitialSettings,
262 base::Unretained(this))); 277 base::Unretained(this)));
278 web_ui()->RegisterMessageCallback("reportDestinationEvent",
279 base::Bind(&PrintPreviewHandler::HandleReportDestinationEvent,
280 base::Unretained(this)));
263 } 281 }
264 282
265 TabContentsWrapper* PrintPreviewHandler::preview_tab_wrapper() const { 283 TabContentsWrapper* PrintPreviewHandler::preview_tab_wrapper() const {
266 return TabContentsWrapper::GetCurrentWrapperForContents(preview_tab()); 284 return TabContentsWrapper::GetCurrentWrapperForContents(preview_tab());
267 } 285 }
268 286
269 WebContents* PrintPreviewHandler::preview_tab() const { 287 WebContents* PrintPreviewHandler::preview_tab() const {
270 return web_ui()->GetWebContents(); 288 return web_ui()->GetWebContents();
271 } 289 }
272 290
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 true); 573 true);
556 574
557 // Once the cloud print dialog comes up we're no longer in a background 575 // Once the cloud print dialog comes up we're no longer in a background
558 // printing situation. Close the print preview. 576 // printing situation. Close the print preview.
559 // TODO(abodenha@chromium.org) The flow should be changed as described in 577 // TODO(abodenha@chromium.org) The flow should be changed as described in
560 // http://code.google.com/p/chromium/issues/detail?id=44093 578 // http://code.google.com/p/chromium/issues/detail?id=44093
561 ActivateInitiatorTabAndClosePreviewTab(); 579 ActivateInitiatorTabAndClosePreviewTab();
562 } 580 }
563 581
564 void PrintPreviewHandler::HandleManageCloudPrint(const ListValue* /*args*/) { 582 void PrintPreviewHandler::HandleManageCloudPrint(const ListValue* /*args*/) {
583 ++manage_cloud_printers_dialog_request_count_;
565 Browser* browser = BrowserList::GetLastActive(); 584 Browser* browser = BrowserList::GetLastActive();
566 if (browser != NULL) 585 if (browser != NULL)
567 browser->OpenURL(OpenURLParams( 586 browser->OpenURL(OpenURLParams(
568 CloudPrintURL(browser->profile()).GetCloudPrintServiceManageURL(), 587 CloudPrintURL(browser->profile()).GetCloudPrintServiceManageURL(),
569 Referrer(), 588 Referrer(),
570 NEW_FOREGROUND_TAB, 589 NEW_FOREGROUND_TAB,
571 content::PAGE_TRANSITION_LINK, 590 content::PAGE_TRANSITION_LINK,
572 false)); 591 false));
573 } 592 }
574 593
(...skipping 26 matching lines...) Expand all
601 620
602 // Record the number of times the user requests to regenerate preview data 621 // Record the number of times the user requests to regenerate preview data
603 // before cancelling. 622 // before cancelling.
604 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforeCancel", 623 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforeCancel",
605 regenerate_preview_request_count_); 624 regenerate_preview_request_count_);
606 } 625 }
607 626
608 void PrintPreviewHandler::ReportStats() { 627 void PrintPreviewHandler::ReportStats() {
609 UMA_HISTOGRAM_COUNTS("PrintPreview.ManagePrinters", 628 UMA_HISTOGRAM_COUNTS("PrintPreview.ManagePrinters",
610 manage_printers_dialog_request_count_); 629 manage_printers_dialog_request_count_);
630 UMA_HISTOGRAM_COUNTS("PrintPreview.ManageCloudPrinters",
631 manage_cloud_printers_dialog_request_count_);
611 } 632 }
612 633
613 void PrintPreviewHandler::GetNumberFormatAndMeasurementSystem( 634 void PrintPreviewHandler::GetNumberFormatAndMeasurementSystem(
614 base::DictionaryValue* settings) { 635 base::DictionaryValue* settings) {
615 636
616 // Getting the measurement system based on the locale. 637 // Getting the measurement system based on the locale.
617 UErrorCode errorCode = U_ZERO_ERROR; 638 UErrorCode errorCode = U_ZERO_ERROR;
618 const char* locale = g_browser_process->GetApplicationLocale().c_str(); 639 const char* locale = g_browser_process->GetApplicationLocale().c_str();
619 UMeasurementSystem system = ulocdata_getMeasurementSystem(locale, &errorCode); 640 UMeasurementSystem system = ulocdata_getMeasurementSystem(locale, &errorCode);
620 if (errorCode > U_ZERO_ERROR || system == UMS_LIMIT) 641 if (errorCode > U_ZERO_ERROR || system == UMS_LIMIT)
621 system = UMS_SI; 642 system = UMS_SI;
622 643
623 // Getting the number formatting based on the locale and writing to 644 // Getting the number formatting based on the locale and writing to
624 // dictionary. 645 // dictionary.
625 settings->SetString(kNumberFormat, base::FormatDouble(123456.78, 2)); 646 settings->SetString(kNumberFormat, base::FormatDouble(123456.78, 2));
626 settings->SetInteger(kMeasurementSystem, system); 647 settings->SetInteger(kMeasurementSystem, system);
627 } 648 }
628 649
629 void PrintPreviewHandler::HandleGetInitialSettings(const ListValue* /*args*/) { 650 void PrintPreviewHandler::HandleGetInitialSettings(const ListValue* /*args*/) {
630 scoped_refptr<PrintSystemTaskProxy> task = 651 scoped_refptr<PrintSystemTaskProxy> task =
631 new PrintSystemTaskProxy(AsWeakPtr(), 652 new PrintSystemTaskProxy(AsWeakPtr(),
632 print_backend_.get(), 653 print_backend_.get(),
633 has_logged_printers_count_); 654 has_logged_printers_count_);
634 BrowserThread::PostTask( 655 BrowserThread::PostTask(
635 BrowserThread::FILE, FROM_HERE, 656 BrowserThread::FILE, FROM_HERE,
636 base::Bind(&PrintSystemTaskProxy::GetDefaultPrinter, task.get())); 657 base::Bind(&PrintSystemTaskProxy::GetDefaultPrinter, task.get()));
637 } 658 }
638 659
660 void PrintPreviewHandler::HandleReportDestinationEvent(const ListValue* args) {
661 int event_number;
662 bool ret = args->GetInteger(0, &event_number);
663 if (!ret)
664 return;
665 enum PrintDestinationBuckets event =
666 static_cast<enum PrintDestinationBuckets>(event_number);
667 if (event >= PRINT_DESTINATION_BUCKET_BOUNDARY)
668 return;
669 ReportPrintDestinationHistogram(event);
670 }
671
639 void PrintPreviewHandler::SendInitialSettings( 672 void PrintPreviewHandler::SendInitialSettings(
640 const std::string& default_printer, 673 const std::string& default_printer,
641 const std::string& cloud_print_data) { 674 const std::string& cloud_print_data) {
642 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( 675 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
643 web_ui()->GetController()); 676 web_ui()->GetController());
644 677
645 base::DictionaryValue initial_settings; 678 base::DictionaryValue initial_settings;
646 initial_settings.SetString(kInitiatorTabTitle, 679 initial_settings.SetString(kInitiatorTabTitle,
647 print_preview_ui->initiator_tab_title()); 680 print_preview_ui->initiator_tab_title());
648 initial_settings.SetBoolean(printing::kSettingPreviewModifiable, 681 initial_settings.SetBoolean(printing::kSettingPreviewModifiable,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 if (prefs->GetBoolean(prefs::kCloudPrintSubmitEnabled)) { 735 if (prefs->GetBoolean(prefs::kCloudPrintSubmitEnabled)) {
703 GURL gcp_url(CloudPrintURL(profile).GetCloudPrintServiceURL()); 736 GURL gcp_url(CloudPrintURL(profile).GetCloudPrintServiceURL());
704 base::StringValue gcp_url_value(gcp_url.spec()); 737 base::StringValue gcp_url_value(gcp_url.spec());
705 web_ui()->CallJavascriptFunction("setUseCloudPrint", gcp_url_value); 738 web_ui()->CallJavascriptFunction("setUseCloudPrint", gcp_url_value);
706 } 739 }
707 } 740 }
708 } 741 }
709 742
710 void PrintPreviewHandler::SendCloudPrintJob(const DictionaryValue& settings, 743 void PrintPreviewHandler::SendCloudPrintJob(const DictionaryValue& settings,
711 std::string print_ticket) { 744 std::string print_ticket) {
745 ReportUserActionHistogram(PRINT_WITH_CLOUD_PRINT);
Scott Byer 2012/05/16 23:24:06 Isn't this redundant with HandlePrintWithCloudPrin
712 scoped_refptr<base::RefCountedBytes> data; 746 scoped_refptr<base::RefCountedBytes> data;
713 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( 747 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
714 web_ui()->GetController()); 748 web_ui()->GetController());
715 print_preview_ui->GetPrintPreviewDataForIndex( 749 print_preview_ui->GetPrintPreviewDataForIndex(
716 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data); 750 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data);
717 if (data.get() && data->size() > 0U && data->front()) { 751 if (data.get() && data->size() > 0U && data->front()) {
718 string16 print_job_title_utf16 = 752 string16 print_job_title_utf16 =
719 preview_tab_wrapper()->print_view_manager()->RenderSourceName(); 753 preview_tab_wrapper()->print_view_manager()->RenderSourceName();
720 std::string print_job_title = UTF16ToUTF8(print_job_title_utf16); 754 std::string print_job_title = UTF16ToUTF8(print_job_title_utf16);
721 std::string printer_id; 755 std::string printer_id;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 return; 904 return;
871 905
872 // We no longer require the initiator tab details. Remove those details 906 // We no longer require the initiator tab details. Remove those details
873 // associated with the preview tab to allow the initiator tab to create 907 // associated with the preview tab to allow the initiator tab to create
874 // another preview tab. 908 // another preview tab.
875 printing::PrintPreviewTabController* tab_controller = 909 printing::PrintPreviewTabController* tab_controller =
876 printing::PrintPreviewTabController::GetInstance(); 910 printing::PrintPreviewTabController::GetInstance();
877 if (tab_controller) 911 if (tab_controller)
878 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); 912 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper());
879 } 913 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/print_preview/print_preview_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698