Chromium Code Reviews
Help | Chromium Project | Sign in
(304)

Side by Side Diff: chrome/browser/views/infobars/translate_infobars.cc

Issue 853010: Adding UMA stats to the translate UI so we can get user usage... (Closed) Base URL: svn://chrome-svn/chrome/branches/249/src/
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/translate/translate_infobars_delegates.cc ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/infobars/translate_infobars.h" 5 #include "chrome/browser/views/infobars/translate_infobars.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 return true; 541 return true;
542 } 542 }
543 543
544 bool TranslateInfoBar::GetAcceleratorForCommandId(int command_id, 544 bool TranslateInfoBar::GetAcceleratorForCommandId(int command_id,
545 views::Accelerator* accelerator) { 545 views::Accelerator* accelerator) {
546 return false; 546 return false;
547 } 547 }
548 548
549 void TranslateInfoBar::ExecuteCommand(int command_id) { 549 void TranslateInfoBar::ExecuteCommand(int command_id) {
550 if (command_id >= IDC_TRANSLATE_TARGET_LANGUAGE_BASE) { 550 if (command_id >= IDC_TRANSLATE_TARGET_LANGUAGE_BASE) {
551 UMA_HISTOGRAM_COUNTS("Translate.ModifyTargetLang", 1);
kuan 2010/03/13 00:47:31 maybe call this in TranslateInfoBarDelegate::Modif
jcampan 2010/03/13 00:58:48 The goal of these UMA stats is to provide us with
551 OnLanguageModified(target_language_menu_button_, 552 OnLanguageModified(target_language_menu_button_,
552 command_id - IDC_TRANSLATE_TARGET_LANGUAGE_BASE); 553 command_id - IDC_TRANSLATE_TARGET_LANGUAGE_BASE);
553 } else if (command_id >= IDC_TRANSLATE_ORIGINAL_LANGUAGE_BASE) { 554 } else if (command_id >= IDC_TRANSLATE_ORIGINAL_LANGUAGE_BASE) {
555 UMA_HISTOGRAM_COUNTS("Translate.ModifyOriginalLang", 1);
kuan 2010/03/13 00:47:31 maybe call this in TranslateInfoBarDelegate::Modif
jcampan 2010/03/13 00:58:48 Same remark as above.
554 OnLanguageModified(original_language_menu_button_, 556 OnLanguageModified(original_language_menu_button_,
555 command_id - IDC_TRANSLATE_ORIGINAL_LANGUAGE_BASE); 557 command_id - IDC_TRANSLATE_ORIGINAL_LANGUAGE_BASE);
556 } else { 558 } else {
557 switch (command_id) { 559 switch (command_id) {
558 case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_LANG: 560 case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_LANG:
561 UMA_HISTOGRAM_COUNTS("Translate.NeverTranslateLang", 1);
559 GetDelegate()->ToggleLanguageBlacklist(); 562 GetDelegate()->ToggleLanguageBlacklist();
kuan 2010/03/13 00:47:31 maybe move the uma call to delegate's ToggleLangua
jcampan 2010/03/13 00:58:48 Same remark as above.
560 break; 563 break;
561 564
562 case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_SITE: 565 case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_SITE:
566 UMA_HISTOGRAM_COUNTS("Translate.NeverTranslateSite", 1);
563 GetDelegate()->ToggleSiteBlacklist(); 567 GetDelegate()->ToggleSiteBlacklist();
kuan 2010/03/13 00:47:31 maybe move the uma call to delegate's ToggleSiteBl
jcampan 2010/03/13 00:58:48 Same remark as above.
564 break; 568 break;
565 569
566 case IDC_TRANSLATE_OPTIONS_ALWAYS: 570 case IDC_TRANSLATE_OPTIONS_ALWAYS:
571 UMA_HISTOGRAM_COUNTS("Translate.AlwaysTranslateLang", 1);
567 GetDelegate()->ToggleAlwaysTranslate(); 572 GetDelegate()->ToggleAlwaysTranslate();
kuan 2010/03/13 00:47:31 maybe move the uma call to delegate's ToggleAlways
jcampan 2010/03/13 00:58:48 Same remark as above.
568 break; 573 break;
569 574
570 case IDC_TRANSLATE_OPTIONS_ABOUT: { 575 case IDC_TRANSLATE_OPTIONS_ABOUT: {
571 TabContents* tab_contents = GetDelegate()->tab_contents(); 576 TabContents* tab_contents = GetDelegate()->tab_contents();
572 if (tab_contents) { 577 if (tab_contents) {
573 string16 url = l10n_util::GetStringUTF16( 578 string16 url = l10n_util::GetStringUTF16(
574 IDS_ABOUT_GOOGLE_TRANSLATE_URL); 579 IDS_ABOUT_GOOGLE_TRANSLATE_URL);
575 tab_contents->OpenURL(GURL(url), GURL(), NEW_FOREGROUND_TAB, 580 tab_contents->OpenURL(GURL(url), GURL(), NEW_FOREGROUND_TAB,
576 PageTransition::LINK); 581 PageTransition::LINK);
577 } 582 }
578 break; 583 break;
579 } 584 }
580 585
581 default: 586 default:
582 NOTREACHED() << "Invalid command id from menu."; 587 NOTREACHED() << "Invalid command id from menu.";
583 break; 588 break;
584 } 589 }
585 } 590 }
586 } 591 }
587 592
588 // TranslateInfoBar, views::ButtonListener overrides: -------------------------- 593 // TranslateInfoBar, views::ButtonListener overrides: --------------------------
589 594
590 void TranslateInfoBar::ButtonPressed( 595 void TranslateInfoBar::ButtonPressed(
591 views::Button* sender, const views::Event& event) { 596 views::Button* sender, const views::Event& event) {
592 if (sender == accept_button_) { 597 if (sender == accept_button_) {
593 GetDelegate()->Translate(); 598 GetDelegate()->Translate();
594 UpdateState(GetDelegate()->state()); 599 UpdateState(GetDelegate()->state());
600 UMA_HISTOGRAM_COUNTS("Translate.Translate", 1);
kuan 2010/03/13 00:47:31 maybe move the uma call to delegate's Translate.
jcampan 2010/03/13 00:58:48 If we do that, we won't know if it is an automatic
595 } else if (sender == deny_button_) { 601 } else if (sender == deny_button_) {
596 GetDelegate()->TranslationDeclined(); 602 GetDelegate()->TranslationDeclined();
603 UMA_HISTOGRAM_COUNTS("Translate.DeclineTranslate", 1);
kuan 2010/03/13 00:47:31 maybe move the uma call to TranslationDeclined.
jcampan 2010/03/13 00:58:48 If we do that we won't be able to differentiate wh
597 RemoveInfoBar(); 604 RemoveInfoBar();
598 } else { // Let base InfoBar handle close button. 605 } else { // Let base InfoBar handle close button.
599 InfoBar::ButtonPressed(sender, event); 606 InfoBar::ButtonPressed(sender, event);
600 } 607 }
601 } 608 }
602 609
603 // TranslateInfoBar, NotificationObserver overrides: --------------------------- 610 // TranslateInfoBar, NotificationObserver overrides: ---------------------------
604 611
605 void TranslateInfoBar::Observe(NotificationType type, 612 void TranslateInfoBar::Observe(NotificationType type,
606 const NotificationSource& source, const NotificationDetails& details) { 613 const NotificationSource& source, const NotificationDetails& details) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 GetDelegate()->GetLocaleFromIndex(new_language_index)); 728 GetDelegate()->GetLocaleFromIndex(new_language_index));
722 menu_button->SetText(UTF16ToWideHack(new_language)); 729 menu_button->SetText(UTF16ToWideHack(new_language));
723 menu_button->ClearMaxTextSize(); 730 menu_button->ClearMaxTextSize();
724 menu_button->SizeToPreferredSize(); 731 menu_button->SizeToPreferredSize();
725 Layout(); 732 Layout();
726 SchedulePaint(); 733 SchedulePaint();
727 // Clear options menu model so that it'll be created with new language. 734 // Clear options menu model so that it'll be created with new language.
728 options_menu_model_.reset(); 735 options_menu_model_.reset();
729 // If necessary, trigger translation. 736 // If necessary, trigger translation.
730 if (GetDelegate()->state() == TranslateInfoBarDelegate::kAfterTranslate) 737 if (GetDelegate()->state() == TranslateInfoBarDelegate::kAfterTranslate)
731 GetDelegate()->Translate(); 738 GetDelegate()->Translate();
kuan 2010/03/13 00:47:31 if u move the uma call for Translate above to dele
jcampan 2010/03/13 00:58:48 I think it is OK. We want to track user usage. So
732 } 739 }
733 740
734 inline TranslateInfoBarDelegate* TranslateInfoBar::GetDelegate() const { 741 inline TranslateInfoBarDelegate* TranslateInfoBar::GetDelegate() const {
735 return static_cast<TranslateInfoBarDelegate*>(delegate()); 742 return static_cast<TranslateInfoBarDelegate*>(delegate());
736 } 743 }
737 744
738 inline int TranslateInfoBar::GetSpacingAfterFirstLanguageButton() const { 745 inline int TranslateInfoBar::GetSpacingAfterFirstLanguageButton() const {
739 return (GetDelegate()->state() == TranslateInfoBarDelegate::kBeforeTranslate ? 746 return (GetDelegate()->state() == TranslateInfoBarDelegate::kBeforeTranslate ?
740 10 : kButtonInLabelSpacing); 747 10 : kButtonInLabelSpacing);
741 } 748 }
742 749
743 // TranslateInfoBarDelegate, InfoBarDelegate overrides: ------------------ 750 // TranslateInfoBarDelegate, InfoBarDelegate overrides: ------------------
744 751
745 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { 752 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() {
746 return new TranslateInfoBar(this); 753 return new TranslateInfoBar(this);
747 } 754 }
OLDNEW
« no previous file with comments | « chrome/browser/translate/translate_infobars_delegates.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 1280:2d3e6564b7b6