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

Unified Diff: components/translate/core/browser/translate_infobar_delegate.cc

Issue 2871783003: Automatically trigger Always-Translate in new translation infobar (Closed)
Patch Set: fix Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/translate/core/browser/translate_infobar_delegate.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/translate/core/browser/translate_infobar_delegate.cc
diff --git a/components/translate/core/browser/translate_infobar_delegate.cc b/components/translate/core/browser/translate_infobar_delegate.cc
index 5fa42a5c705c0dbf1ac90aca3eba30477184e3d5..f6008521dd3d7ef0304ace07617ef6ef483f1ccd 100644
--- a/components/translate/core/browser/translate_infobar_delegate.cc
+++ b/components/translate/core/browser/translate_infobar_delegate.cc
@@ -46,6 +46,10 @@ const int kAlwaysTranslateMinCount = 3;
const int kNeverTranslateMinCount = 3;
#endif
+// For Compact UI, if number of consecutive translations is equal to this
+// number, infobar will automatically trigger "Always Translate".
+const int kAcceptCountThreshold = 5;
+
} // namespace
const base::Feature kTranslateCompactUI{"TranslateCompactUI",
@@ -298,6 +302,12 @@ void TranslateInfoBarDelegate::ShowNeverTranslateInfobar() {
}
#endif
+bool TranslateInfoBarDelegate::ShouldAutoAlwaysTranslate() {
+ return (IsCompactUIEnabled() &&
+ prefs_->GetTranslationAcceptedCount(original_language_code()) ==
+ kAcceptCountThreshold);
+}
+
// static
void TranslateInfoBarDelegate::GetAfterTranslateStrings(
std::vector<base::string16>* strings,
@@ -378,7 +388,8 @@ int TranslateInfoBarDelegate::GetIconId() const {
void TranslateInfoBarDelegate::InfoBarDismissed() {
if (step_ != translate::TRANSLATE_STEP_BEFORE_TRANSLATE)
return;
-
+ if (IsCompactUIEnabled())
+ return;
// The user closed the infobar without clicking the translate button.
TranslationDeclined();
UMA_HISTOGRAM_BOOLEAN("Translate.DeclineTranslateCloseInfobar", true);
« no previous file with comments | « components/translate/core/browser/translate_infobar_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698