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

Side by Side Diff: chrome/browser/ui/android/infobars/translate_compact_infobar.h

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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 #ifndef CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_ 5 #ifndef CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_
6 #define CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_ 6 #define CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_
7 7
8 #include "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "chrome/browser/translate/chrome_translate_client.h" 10 #include "chrome/browser/translate/chrome_translate_client.h"
(...skipping 21 matching lines...) Expand all
32 32
33 // JNI method specific to boolean settings in translate. 33 // JNI method specific to boolean settings in translate.
34 void ApplyBoolTranslateOption(JNIEnv* env, 34 void ApplyBoolTranslateOption(JNIEnv* env,
35 const base::android::JavaParamRef<jobject>& obj, 35 const base::android::JavaParamRef<jobject>& obj,
36 int option, 36 int option,
37 jboolean value); 37 jboolean value);
38 38
39 // Check whether we should automatically trigger "Always Translate". 39 // Check whether we should automatically trigger "Always Translate".
40 bool ShouldAutoAlwaysTranslate(); 40 bool ShouldAutoAlwaysTranslate();
41 41
42 // Check whether we should automatically trigger "Never Translate Language".
43 jboolean ShouldAutoNeverTranslate(
44 JNIEnv* env,
45 const base::android::JavaParamRef<jobject>& obj);
46
42 // ContentTranslateDriver::Observer implementation. 47 // ContentTranslateDriver::Observer implementation.
43 void OnPageTranslated(const std::string& original_lang, 48 void OnPageTranslated(const std::string& original_lang,
44 const std::string& translated_lang, 49 const std::string& translated_lang,
45 translate::TranslateErrors::Type error_type) override; 50 translate::TranslateErrors::Type error_type) override;
46 51
47 private: 52 private:
48 // InfoBarAndroid: 53 // InfoBarAndroid:
49 base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar( 54 base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar(
50 JNIEnv* env) override; 55 JNIEnv* env) override;
51 void ProcessButton(int action) override; 56 void ProcessButton(int action) override;
52 void SetJavaInfoBar( 57 void SetJavaInfoBar(
53 const base::android::JavaRef<jobject>& java_info_bar) override; 58 const base::android::JavaRef<jobject>& java_info_bar) override;
54 59
55 translate::TranslateInfoBarDelegate* GetDelegate(); 60 translate::TranslateInfoBarDelegate* GetDelegate();
56 translate::ContentTranslateDriver* translate_driver_; 61 translate::ContentTranslateDriver* translate_driver_;
57 62
63 // If number of consecutive translations is equal to this number, infobar will
64 // automatically trigger "Always Translate".
65 const int kAcceptCountThreshold = 5;
66 // If number of consecutive denied is equal to this number, infobar will
67 // automatically trigger "Never Translate Language".
68 const int kDeniedCountThreshold = 7;
69
58 DISALLOW_COPY_AND_ASSIGN(TranslateCompactInfoBar); 70 DISALLOW_COPY_AND_ASSIGN(TranslateCompactInfoBar);
59 }; 71 };
60 72
61 // Registers the native methods through JNI. 73 // Registers the native methods through JNI.
62 bool RegisterTranslateCompactInfoBar(JNIEnv* env); 74 bool RegisterTranslateCompactInfoBar(JNIEnv* env);
63 75
64 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_ 76 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698