diff options
6 files changed, 40 insertions, 5 deletions
diff --git a/chrome/browser/ui/android/infobars/translate_infobar.cc b/chrome/browser/ui/android/infobars/translate_infobar.cc index a8cd959..3a45bfa 100644 --- a/chrome/browser/ui/android/infobars/translate_infobar.cc +++ b/chrome/browser/ui/android/infobars/translate_infobar.cc @@ -7,7 +7,9 @@ #include "base/android/jni_android.h" #include "base/android/jni_array.h" #include "base/android/jni_helper.h" +#include "base/metrics/histogram.h" #include "chrome/browser/translate/translate_infobar_delegate.h" +#include "components/translate/common/translate_metrics.h" #include "grit/generated_resources.h" #include "jni/TranslateInfoBarDelegate_jni.h" #include "ui/base/l10n/l10n_util.h" @@ -90,8 +92,19 @@ void TranslateInfoBar::ApplyTranslateOptions(JNIEnv* env, bool always_translate, bool never_translate_language, bool never_translate_site) { - delegate_->set_original_language_index(source_language_index); - delegate_->set_target_language_index(target_language_index); + if (delegate_->original_language_index() != + static_cast<size_t>(source_language_index)) { + UMA_HISTOGRAM_BOOLEAN( + translate::GetMetricsName(translate::UMA_MODIFY_ORIGINAL_LANG), true); + delegate_->set_original_language_index(source_language_index); + } + + if (delegate_->target_language_index() != + static_cast<size_t>(target_language_index)) { + UMA_HISTOGRAM_BOOLEAN( + translate::GetMetricsName(translate::UMA_MODIFY_TARGET_LANG), true); + delegate_->set_target_language_index(target_language_index); + } if (delegate_->ShouldAlwaysTranslate() != always_translate) delegate_->ToggleAlwaysTranslate(); diff --git a/chrome/browser/ui/gtk/infobars/after_translate_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/after_translate_infobar_gtk.cc index 98d3f48..79a0a45 100644 --- a/chrome/browser/ui/gtk/infobars/after_translate_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/after_translate_infobar_gtk.cc @@ -6,9 +6,11 @@ #include "base/bind.h" #include "base/message_loop/message_loop.h" +#include "base/metrics/histogram.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/translate/translate_infobar_delegate.h" #include "chrome/browser/ui/gtk/gtk_util.h" +#include "components/translate/common/translate_metrics.h" #include "grit/generated_resources.h" #include "ui/base/gtk/gtk_hig_constants.h" #include "ui/base/gtk/gtk_signal_registrar.h" @@ -90,11 +92,15 @@ bool AfterTranslateInfoBar::ShowOptionsMenuButton() const { } void AfterTranslateInfoBar::SetOriginalLanguage(size_t language_index) { + UMA_HISTOGRAM_BOOLEAN( + translate::GetMetricsName(translate::UMA_MODIFY_ORIGINAL_LANG), true); GetDelegate()->set_original_language_index(language_index); GetDelegate()->Translate(); } void AfterTranslateInfoBar::SetTargetLanguage(size_t language_index) { + UMA_HISTOGRAM_BOOLEAN( + translate::GetMetricsName(translate::UMA_MODIFY_TARGET_LANG), true); GetDelegate()->set_target_language_index(language_index); GetDelegate()->Translate(); } diff --git a/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.cc b/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.cc index 7040dbd..a6dd390 100644 --- a/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.cc +++ b/chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.cc @@ -4,9 +4,11 @@ #include "chrome/browser/ui/gtk/infobars/before_translate_infobar_gtk.h" +#include "base/metrics/histogram.h" #include "base/strings/utf_string_conversions.h" #include "chrome/browser/translate/translate_infobar_delegate.h" #include "chrome/browser/ui/gtk/gtk_util.h" +#include "components/translate/common/translate_metrics.h" #include "grit/generated_resources.h" #include "ui/base/gtk/gtk_hig_constants.h" #include "ui/base/gtk/gtk_signal_registrar.h" @@ -87,6 +89,8 @@ bool BeforeTranslateInfoBar::ShowOptionsMenuButton() const { } void BeforeTranslateInfoBar::OnLanguageModified(GtkWidget* sender) { + UMA_HISTOGRAM_BOOLEAN( + translate::GetMetricsName(translate::UMA_MODIFY_ORIGINAL_LANG), true); GetDelegate()->set_original_language_index( GetLanguageComboboxActiveId(GTK_COMBO_BOX(sender))); } diff --git a/chrome/browser/ui/views/infobars/translate_language_menu_model.cc b/chrome/browser/ui/views/infobars/translate_language_menu_model.cc index 5a5b189..a93c4b02 100644 --- a/chrome/browser/ui/views/infobars/translate_language_menu_model.cc +++ b/chrome/browser/ui/views/infobars/translate_language_menu_model.cc @@ -7,6 +7,7 @@ #include "base/metrics/histogram.h" #include "chrome/browser/translate/translate_infobar_delegate.h" #include "chrome/browser/ui/views/infobars/translate_infobar_base.h" +#include "components/translate/common/translate_metrics.h" TranslateLanguageMenuModel::TranslateLanguageMenuModel( LanguageType language_type, @@ -48,10 +49,12 @@ void TranslateLanguageMenuModel::ExecuteCommand(int command_id, int event_flags) { size_t command_id_size_t = static_cast<size_t>(command_id); if (language_type_ == ORIGINAL) { - UMA_HISTOGRAM_BOOLEAN("Translate.ModifyOriginalLang", true); + UMA_HISTOGRAM_BOOLEAN( + translate::GetMetricsName(translate::UMA_MODIFY_ORIGINAL_LANG), true); infobar_delegate_->set_original_language_index(command_id_size_t); } else { - UMA_HISTOGRAM_BOOLEAN("Translate.ModifyTargetLang", true); + UMA_HISTOGRAM_BOOLEAN( + translate::GetMetricsName(translate::UMA_MODIFY_TARGET_LANG), true); infobar_delegate_->set_target_language_index(command_id_size_t); } infobar_->UpdateLanguageButtonText(button_, diff --git a/components/translate/common/translate_metrics.cc b/components/translate/common/translate_metrics.cc index b095084..5402491 100644 --- a/components/translate/common/translate_metrics.cc +++ b/components/translate/common/translate_metrics.cc @@ -23,6 +23,9 @@ const char kTranslateTimeToTranslate[] = "Translate.TimeToTranslate"; const char kTranslateUserActionDuration[] = "Translate.UserActionDuration"; const char kTranslatePageScheme[] = "Translate.PageScheme"; const char kTranslateSimilarLanguageMatch[] = "Translate.SimilarLanguageMatch"; +const char kTranslateModifyOriginalLang[] = "Translate.ModifyOriginalLang"; +const char kTranslateModifyTargetLang[] = "Translate.ModifyTargetlLang"; + const char kSchemeHttp[] = "http"; const char kSchemeHttps[] = "https"; @@ -33,6 +36,8 @@ struct MetricsEntry { }; // This entry table should be updated when new UMA items are added. +// TODO(miguelg) Move kTranslateModifyOriginalLang and +// kTranslateModifyTargetLang to the UX delegate once crbug/312720 is fixed. const MetricsEntry kMetricsEntries[] = { {UMA_LANGUAGE_DETECTION, kRenderer4LanguageDetection}, {UMA_CONTENT_LANGUAGE, kTranslateContentLanguage}, @@ -43,7 +48,9 @@ const MetricsEntry kMetricsEntries[] = { {UMA_TIME_TO_TRANSLATE, kTranslateTimeToTranslate}, {UMA_USER_ACTION_DURATION, kTranslateUserActionDuration}, {UMA_PAGE_SCHEME, kTranslatePageScheme}, - {UMA_SIMILAR_LANGUAGE_MATCH, kTranslateSimilarLanguageMatch}, }; + {UMA_SIMILAR_LANGUAGE_MATCH, kTranslateSimilarLanguageMatch}, + {UMA_MODIFY_ORIGINAL_LANG, kTranslateModifyOriginalLang}, + {UMA_MODIFY_TARGET_LANG, kTranslateModifyTargetLang}, }; COMPILE_ASSERT(arraysize(kMetricsEntries) == UMA_MAX, arraysize_of_kMetricsEntries_should_be_UMA_MAX); diff --git a/components/translate/common/translate_metrics.h b/components/translate/common/translate_metrics.h index 9baa268..a38db44 100644 --- a/components/translate/common/translate_metrics.h +++ b/components/translate/common/translate_metrics.h @@ -24,6 +24,8 @@ enum MetricsNameIndex { UMA_USER_ACTION_DURATION, UMA_PAGE_SCHEME, UMA_SIMILAR_LANGUAGE_MATCH, + UMA_MODIFY_ORIGINAL_LANG, + UMA_MODIFY_TARGET_LANG, UMA_MAX, }; |