| 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; |
| 53 // Returns true if the user didn't take any affirmative action. |
| 54 // The function will be called when the translate infobar is dismissed. |
| 55 // If it's true, we will record a declined event. |
| 52 bool IsDeclinedByUser() override; | 56 bool IsDeclinedByUser() override; |
| 53 | 57 |
| 54 private: | 58 private: |
| 55 // InfoBarAndroid: | 59 // InfoBarAndroid: |
| 56 base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar( | 60 base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar( |
| 57 JNIEnv* env) override; | 61 JNIEnv* env) override; |
| 58 void ProcessButton(int action) override; | 62 void ProcessButton(int action) override; |
| 59 void SetJavaInfoBar( | 63 void SetJavaInfoBar( |
| 60 const base::android::JavaRef<jobject>& java_info_bar) override; | 64 const base::android::JavaRef<jobject>& java_info_bar) override; |
| 61 | 65 |
| 62 translate::TranslateInfoBarDelegate* GetDelegate(); | 66 translate::TranslateInfoBarDelegate* GetDelegate(); |
| 63 | 67 |
| 64 // Bits for trace user actions. | 68 // Bits for trace user's affirmative actions. |
| 65 unsigned int action_flags_; | 69 unsigned int action_flags_; |
| 66 | 70 |
| 67 // User action flags to record what the user has done in each session. | 71 // Affirmative action flags to record what the user has done in one session. |
| 68 enum ActionFlag { | 72 enum ActionFlag { |
| 69 FLAG_NONE = 0, | 73 FLAG_NONE = 0, |
| 70 FLAG_TRANSLATE = 1 << 0, | 74 FLAG_TRANSLATE = 1 << 0, |
| 71 FLAG_REVERT = 1 << 1, | 75 FLAG_REVERT = 1 << 1, |
| 72 FLAG_ALWAYS_TRANSLATE = 1 << 2, | 76 FLAG_ALWAYS_TRANSLATE = 1 << 2, |
| 73 FLAG_NEVER_LANGUAGE = 1 << 3, | 77 FLAG_NEVER_LANGUAGE = 1 << 3, |
| 74 FLAG_NEVER_SITE = 1 << 4, | 78 FLAG_NEVER_SITE = 1 << 4, |
| 79 FLAG_EXPAND_MENU = 1 << 5, |
| 75 }; | 80 }; |
| 76 | 81 |
| 77 // If number of consecutive translations is equal to this number, infobar will | 82 // If number of consecutive translations is equal to this number, infobar will |
| 78 // automatically trigger "Always Translate". | 83 // automatically trigger "Always Translate". |
| 79 const int kAcceptCountThreshold = 5; | 84 const int kAcceptCountThreshold = 5; |
| 80 // If number of consecutive denied is equal to this number, infobar will | 85 // If number of consecutive denied is equal to this number, infobar will |
| 81 // automatically trigger "Never Translate Language". | 86 // automatically trigger "Never Translate Language". |
| 82 const int kDeniedCountThreshold = 7; | 87 const int kDeniedCountThreshold = 7; |
| 83 | 88 |
| 84 DISALLOW_COPY_AND_ASSIGN(TranslateCompactInfoBar); | 89 DISALLOW_COPY_AND_ASSIGN(TranslateCompactInfoBar); |
| 85 }; | 90 }; |
| 86 | 91 |
| 87 // Registers the native methods through JNI. | 92 // Registers the native methods through JNI. |
| 88 bool RegisterTranslateCompactInfoBar(JNIEnv* env); | 93 bool RegisterTranslateCompactInfoBar(JNIEnv* env); |
| 89 | 94 |
| 90 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_ | 95 #endif // CHROME_BROWSER_UI_ANDROID_INFOBARS_TRANSLATE_COMPACT_INFOBAR_H_ |
| OLD | NEW |