| Index: chrome/browser/translate/chrome_translate_client.cc
|
| diff --git a/chrome/browser/translate/chrome_translate_client.cc b/chrome/browser/translate/chrome_translate_client.cc
|
| index 06ce2bbbcd236307ca099d12faf0e7064c05534a..85751ce025f517f9e85bab67fc0b4564e7e09a9f 100644
|
| --- a/chrome/browser/translate/chrome_translate_client.cc
|
| +++ b/chrome/browser/translate/chrome_translate_client.cc
|
| @@ -26,6 +26,7 @@
|
| #include "chrome/common/chrome_paths.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/grit/theme_resources.h"
|
| +#include "components/metrics/proto/translate_event.pb.h"
|
| #include "components/prefs/pref_service.h"
|
| #include "components/translate/core/browser/language_model.h"
|
| #include "components/translate/core/browser/language_state.h"
|
| @@ -198,12 +199,21 @@ void ChromeTranslateClient::ShowTranslateUI(
|
| // another page.
|
| if (!base::FeatureList::IsEnabled(translate::kTranslateUI2016Q2) &&
|
| !GetLanguageState().HasLanguageChanged()) {
|
| + if (translate_manager_) {
|
| + translate_manager_->RecordTranslateEvent(
|
| + metrics::TranslateEventProto::MATCHES_PREVIOUS_LANGUAGE);
|
| + }
|
| return;
|
| }
|
|
|
| if (!triggered_from_menu &&
|
| - GetTranslatePrefs()->IsTooOftenDenied(source_language))
|
| + GetTranslatePrefs()->IsTooOftenDenied(source_language)) {
|
| + if (translate_manager_) {
|
| + translate_manager_->RecordTranslateEvent(
|
| + metrics::TranslateEventProto::LANGUAGE_DISABLED_BY_AUTO_BLACKLIST);
|
| + }
|
| return;
|
| + }
|
| }
|
| ShowBubble(step, error_type);
|
| }
|
| @@ -319,16 +329,28 @@ void ChromeTranslateClient::ShowBubble(
|
| return;
|
| }
|
|
|
| - if (web_contents() != browser->tab_strip_model()->GetActiveWebContents())
|
| + if (web_contents() != browser->tab_strip_model()->GetActiveWebContents()) {
|
| + if (translate_manager_ &&
|
| + step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) {
|
| + translate_manager_->RecordTranslateEvent(
|
| + metrics::TranslateEventProto::WEBCONTENTS_NOT_ACTIVE);
|
| + }
|
| return;
|
| + }
|
|
|
| - // This ShowBubble function is also used for upating the existing bubble.
|
| + // This ShowBubble function is also used for updating the existing bubble.
|
| // However, with the bubble shown, any browser windows are NOT activated
|
| // because the bubble takes the focus from the other widgets including the
|
| // browser windows. So it is checked that |browser| is the last activated
|
| // browser, not is now activated.
|
| - if (browser != chrome::FindLastActive())
|
| + if (browser != chrome::FindLastActive()) {
|
| + if (translate_manager_ &&
|
| + step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) {
|
| + translate_manager_->RecordTranslateEvent(
|
| + metrics::TranslateEventProto::BROSWER_WINDOW_NOT_ACTIVE);
|
| + }
|
| return;
|
| + }
|
|
|
| // During auto-translating, the bubble should not be shown.
|
| if (step == translate::TRANSLATE_STEP_TRANSLATING ||
|
|
|