Index: components/translate/core/browser/translate_ui_delegate.cc |
diff --git a/components/translate/core/browser/translate_ui_delegate.cc b/components/translate/core/browser/translate_ui_delegate.cc |
index 50879397171f0a66a0c9c50180aea59e27d7a43e..694c5888c217e5f97e616d575cbafe4b51da6e6b 100644 |
--- a/components/translate/core/browser/translate_ui_delegate.cc |
+++ b/components/translate/core/browser/translate_ui_delegate.cc |
@@ -6,6 +6,7 @@ |
#include "base/i18n/string_compare.h" |
#include "base/metrics/histogram_macros.h" |
+#include "base/strings/string_number_conversions.h" |
#include "components/translate/core/browser/language_state.h" |
#include "components/translate/core/browser/translate_client.h" |
#include "components/translate/core/browser/translate_download_manager.h" |
@@ -13,6 +14,7 @@ |
#include "components/translate/core/browser/translate_manager.h" |
#include "components/translate/core/browser/translate_prefs.h" |
#include "components/translate/core/common/translate_constants.h" |
+#include "components/variations/variations_associated_data.h" |
#include "third_party/icu/source/i18n/unicode/coll.h" |
#include "ui/base/l10n/l10n_util.h" |
@@ -302,14 +304,35 @@ bool TranslateUIDelegate::ShouldAlwaysTranslate() { |
} |
bool TranslateUIDelegate::ShouldAlwaysTranslateBeCheckedByDefault() { |
- // After 2 clicks on Translate for the same language. |
- // We check for == 2 instead of >= 2 because if the user translates with the |
+ if (ShouldAlwaysTranslate()) |
+ return true; |
+ |
+ std::map<std::string, std::string> params; |
+ int always_translate_offer_threshold = -1; |
+ if (variations::GetVariationParams(translate::kTranslateUI2016Q2TrialName, |
+ ¶ms)) { |
+ auto it = params.find(translate::kAlwaysTranslateOfferThreshold); |
groby-ooo-7-16
2016/06/28 17:35:20
Why not the shorter variant? (I'm fine with using
ftang
2016/06/28 21:51:12
Done.
|
+ if (it != params.end()) { |
+ if (!base::StringToInt(it->second, &always_translate_offer_threshold)) { |
+ // if we cannot parse the number, return false. |
+ return false; |
+ } |
+ } |
+ } |
+ |
+ if (always_translate_offer_threshold < 0) { |
groby-ooo-7-16
2016/06/28 17:35:20
<= 0?
ftang
2016/06/28 21:51:12
Done.
|
+ // if the number is negative, we never set the checked by default. |
+ return false; |
+ } |
+ |
+ // After N clicks on Translate for the same language. |
+ // We check for == N instead of >= N because if the user translates with the |
// "Always do this?" on, then the next time the bubble won't show up. |
// The only chance the bubble will show up is after the user manually unchecks |
// "Always do this?". In that case, since it is after user explictly unchecks, |
- // we should show as it as unchecked so we only check == 2 instead of >= 2. |
- return ShouldAlwaysTranslate() || |
- prefs_->GetTranslationAcceptedCount(GetOriginalLanguageCode()) == 2; |
+ // we should show as it as unchecked so we only check == N instead of >= N. |
+ return prefs_->GetTranslationAcceptedCount(GetOriginalLanguageCode()) == |
groby-ooo-7-16
2016/06/28 17:35:20
You really want greater-equals here. Otherwise, yo
ftang
2016/06/28 21:51:12
The problem of that is, then if the user explicitl
|
+ always_translate_offer_threshold; |
} |
void TranslateUIDelegate::SetAlwaysTranslate(bool value) { |