OLD | NEW |
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 26 matching lines...) Expand all Loading... |
37 const base::android::JavaParamRef<jobject>& obj, | 37 const base::android::JavaParamRef<jobject>& obj, |
38 int option, | 38 int option, |
39 jboolean value); | 39 jboolean value); |
40 | 40 |
41 // Check whether we should automatically trigger "Always Translate". | 41 // Check whether we should automatically trigger "Always Translate". |
42 bool ShouldAutoAlwaysTranslate(); | 42 bool ShouldAutoAlwaysTranslate(); |
43 | 43 |
44 // Check whether we should automatically trigger "Never Translate Language". | 44 // Check whether we should automatically trigger "Never Translate Language". |
45 jboolean ShouldAutoNeverTranslate( | 45 jboolean ShouldAutoNeverTranslate( |
46 JNIEnv* env, | 46 JNIEnv* env, |
47 const base::android::JavaParamRef<jobject>& obj); | 47 const base::android::JavaParamRef<jobject>& obj, |
| 48 jboolean menu_expanded); |
48 | 49 |
49 // TranslateInfoBarDelegate::Observer implementation. | 50 // TranslateInfoBarDelegate::Observer implementation. |
50 void OnTranslateStepChanged(translate::TranslateStep step, | 51 void OnTranslateStepChanged(translate::TranslateStep step, |
51 translate::TranslateErrors::Type error_type) override; | 52 translate::TranslateErrors::Type error_type) override; |
52 bool IsDeclinedByUser() override; | 53 bool IsDeclinedByUser() override; |
53 | 54 |
54 private: | 55 private: |
55 // InfoBarAndroid: | 56 // InfoBarAndroid: |
56 base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar( | 57 base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar( |
57 JNIEnv* env) override; | 58 JNIEnv* env) override; |
58 void ProcessButton(int action) override; | 59 void ProcessButton(int action) override; |
59 void SetJavaInfoBar( | 60 void SetJavaInfoBar( |
60 const base::android::JavaRef<jobject>& java_info_bar) override; | 61 const base::android::JavaRef<jobject>& java_info_bar) override; |
61 | 62 |
62 translate::TranslateInfoBarDelegate* GetDelegate(); | 63 translate::TranslateInfoBarDelegate* GetDelegate(); |
63 | 64 |
64 // Bits for trace user actions. | 65 // Bits for trace user actions. |
65 unsigned int action_flags_; | 66 unsigned int action_flags_; |
66 | 67 |
67 // User action flags to record what the user has done in each session. | 68 // User action flags to record what the user has done in each session. |
68 enum ActionFlag { | 69 enum ActionFlag { |
69 FLAG_NONE = 0, | 70 FLAG_NONE = 0, |
70 FLAG_TRANSLATE = 1 << 0, | 71 FLAG_TRANSLATE = 1 << 0, |
71 FLAG_REVERT = 1 << 1, | 72 FLAG_REVERT = 1 << 1, |
72 FLAG_ALWAYS_TRANSLATE = 1 << 2, | 73 FLAG_ALWAYS_TRANSLATE = 1 << 2, |
73 FLAG_NEVER_LANGUAGE = 1 << 3, | 74 FLAG_NEVER_LANGUAGE = 1 << 3, |
74 FLAG_NEVER_SITE = 1 << 4, | 75 FLAG_NEVER_SITE = 1 << 4, |
| 76 FLAG_EXPAND_MENU = 1 << 5, |
75 }; | 77 }; |
76 | 78 |
77 // If number of consecutive translations is equal to this number, infobar will | 79 // If number of consecutive translations is equal to this number, infobar will |
78 // automatically trigger "Always Translate". | 80 // automatically trigger "Always Translate". |
79 const int kAcceptCountThreshold = 5; | 81 const int kAcceptCountThreshold = 5; |
80 // If number of consecutive denied is equal to this number, infobar will | 82 // If number of consecutive denied is equal to this number, infobar will |
81 // automatically trigger "Never Translate Language". | 83 // automatically trigger "Never Translate Language". |
82 const int kDeniedCountThreshold = 7; | 84 const int kDeniedCountThreshold = 7; |
83 | 85 |
84 DISALLOW_COPY_AND_ASSIGN(TranslateCompactInfoBar); | 86 DISALLOW_COPY_AND_ASSIGN(TranslateCompactInfoBar); |
85 }; | 87 }; |
86 | 88 |
87 // Registers the native methods through JNI. | 89 // Registers the native methods through JNI. |
88 bool RegisterTranslateCompactInfoBar(JNIEnv* env); | 90 bool RegisterTranslateCompactInfoBar(JNIEnv* env); |
89 | 91 |
90 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_ | 92 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_ |
OLD | NEW |