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

Side by Side Diff: components/translate/core/browser/translate_infobar_delegate.cc

Issue 2874393002: Automatically trigger Never-Translate in new translation infobar (Closed)
Patch Set: sync and merge 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 unified diff | Download patch
« no previous file with comments | « components/translate/core/browser/translate_infobar_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/translate/core/browser/translate_infobar_delegate.h" 5 #include "components/translate/core/browser/translate_infobar_delegate.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
(...skipping 27 matching lines...) Expand all
38 #elif defined(OS_IOS) 38 #elif defined(OS_IOS)
39 // The iOS implementation, like the Android implementation, shows the "Never 39 // The iOS implementation, like the Android implementation, shows the "Never
40 // translate" infobar after two denials. There is an offset of one because on 40 // translate" infobar after two denials. There is an offset of one because on
41 // Android the last event is not counted. 41 // Android the last event is not counted.
42 const int kAlwaysTranslateMinCount = 1; 42 const int kAlwaysTranslateMinCount = 1;
43 const int kNeverTranslateMinCount = 2; 43 const int kNeverTranslateMinCount = 2;
44 #else 44 #else
45 const int kAlwaysTranslateMinCount = 3; 45 const int kAlwaysTranslateMinCount = 3;
46 const int kNeverTranslateMinCount = 3; 46 const int kNeverTranslateMinCount = 3;
47 #endif 47 #endif
48
49 // For Compact UI, if number of consecutive translations is equal to this
50 // number, infobar will automatically trigger "Always Translate".
51 const int kAcceptCountThreshold = 5;
52
53 } // namespace 48 } // namespace
54 49
55 const base::Feature kTranslateCompactUI{"TranslateCompactUI", 50 const base::Feature kTranslateCompactUI{"TranslateCompactUI",
56 base::FEATURE_DISABLED_BY_DEFAULT}; 51 base::FEATURE_DISABLED_BY_DEFAULT};
57 52
58 const size_t TranslateInfoBarDelegate::kNoIndex = TranslateUIDelegate::kNoIndex; 53 const size_t TranslateInfoBarDelegate::kNoIndex = TranslateUIDelegate::kNoIndex;
59 54
60 TranslateInfoBarDelegate::~TranslateInfoBarDelegate() { 55 TranslateInfoBarDelegate::~TranslateInfoBarDelegate() {
61 } 56 }
62 57
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 } 290 }
296 291
297 #if defined(OS_IOS) 292 #if defined(OS_IOS)
298 void TranslateInfoBarDelegate::ShowNeverTranslateInfobar() { 293 void TranslateInfoBarDelegate::ShowNeverTranslateInfobar() {
299 Create(true, translate_manager_, infobar()->owner(), is_off_the_record_, 294 Create(true, translate_manager_, infobar()->owner(), is_off_the_record_,
300 translate::TRANSLATE_STEP_NEVER_TRANSLATE, original_language_code(), 295 translate::TRANSLATE_STEP_NEVER_TRANSLATE, original_language_code(),
301 target_language_code(), TranslateErrors::NONE, false); 296 target_language_code(), TranslateErrors::NONE, false);
302 } 297 }
303 #endif 298 #endif
304 299
305 bool TranslateInfoBarDelegate::ShouldAutoAlwaysTranslate() { 300 int TranslateInfoBarDelegate::GetTranslationAcceptedCount() {
306 return (IsCompactUIEnabled() && 301 return prefs_->GetTranslationAcceptedCount(original_language_code());
307 prefs_->GetTranslationAcceptedCount(original_language_code()) == 302 }
308 kAcceptCountThreshold); 303
304 int TranslateInfoBarDelegate::GetTranslationDeniedCount() {
305 return prefs_->GetTranslationDeniedCount(original_language_code());
309 } 306 }
310 307
311 // static 308 // static
312 void TranslateInfoBarDelegate::GetAfterTranslateStrings( 309 void TranslateInfoBarDelegate::GetAfterTranslateStrings(
313 std::vector<base::string16>* strings, 310 std::vector<base::string16>* strings,
314 bool* swap_languages, 311 bool* swap_languages,
315 bool autodetermined_source_language) { 312 bool autodetermined_source_language) {
316 DCHECK(strings); 313 DCHECK(strings);
317 314
318 if (autodetermined_source_language) { 315 if (autodetermined_source_language) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 TranslationDeclined(); 391 TranslationDeclined();
395 UMA_HISTOGRAM_BOOLEAN("Translate.DeclineTranslateCloseInfobar", true); 392 UMA_HISTOGRAM_BOOLEAN("Translate.DeclineTranslateCloseInfobar", true);
396 } 393 }
397 394
398 TranslateInfoBarDelegate* 395 TranslateInfoBarDelegate*
399 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { 396 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() {
400 return this; 397 return this;
401 } 398 }
402 399
403 } // namespace translate 400 } // namespace translate
OLDNEW
« 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