Chromium Code Reviews| 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_) { |
|
groby-ooo-7-16
2016/10/25 18:53:10
Should never be NULL - just DCHECK if you want to
Roger McFarlane (Chromium)
2016/10/25 20:07:56
translate_manager_ is reset to NULL on WebContents
groby-ooo-7-16
2016/10/25 23:17:21
We really shouldn't have to - ChromeTranslateClien
Roger McFarlane (Chromium)
2016/11/07 20:51:58
Done.
|
| + 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_ && |
|
groby-ooo-7-16
2016/10/25 18:53:10
Is there a specific reason you're checking transla
Roger McFarlane (Chromium)
2016/10/25 20:07:56
Acknowledged. See previous commentary re: WebConte
|
| + step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) { |
|
groby-ooo-7-16
2016/10/25 18:53:10
Why is this just recorded for BEFORE_TRANSLATE?
Roger McFarlane (Chromium)
2016/10/25 20:07:56
We're capturing the outcome of showing the transla
groby-ooo-7-16
2016/10/25 23:17:21
If you don't mind, could you add a comment here? B
Roger McFarlane (Chromium)
2016/11/07 20:51:58
Done.
|
| + 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); |
|
groby-ooo-7-16
2016/10/25 18:53:10
See above :)
Roger McFarlane (Chromium)
2016/10/25 20:07:56
Acknowledged. See previous commentary re: WebConte
|
| + } |
| return; |
|
groby-ooo-7-16
2016/10/25 18:53:10
On a wider scale, I'm wondering it this should ret
Roger McFarlane (Chromium)
2016/10/25 20:07:56
In the most recent patchset, I've done something s
groby-ooo-7-16
2016/10/25 23:17:21
Is it worth doing in this patchset, or should we p
Roger McFarlane (Chromium)
2016/11/07 20:51:58
Done.
|
| + } |
| // During auto-translating, the bubble should not be shown. |
| if (step == translate::TRANSLATE_STEP_TRANSLATING || |