| 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 #include "chrome/browser/ui/android/infobars/translate_compact_infobar.h" | 5 #include "chrome/browser/ui/android/infobars/translate_compact_infobar.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 if (action == InfoBarAndroid::ACTION_TRANSLATE) { | 64 if (action == InfoBarAndroid::ACTION_TRANSLATE) { |
| 65 action_flags_ |= FLAG_TRANSLATE; | 65 action_flags_ |= FLAG_TRANSLATE; |
| 66 delegate->Translate(); | 66 delegate->Translate(); |
| 67 if (!delegate->ShouldAlwaysTranslate() && ShouldAutoAlwaysTranslate()) { | 67 if (!delegate->ShouldAlwaysTranslate() && ShouldAutoAlwaysTranslate()) { |
| 68 JNIEnv* env = base::android::AttachCurrentThread(); | 68 JNIEnv* env = base::android::AttachCurrentThread(); |
| 69 Java_TranslateCompactInfoBar_setAutoAlwaysTranslate(env, | 69 Java_TranslateCompactInfoBar_setAutoAlwaysTranslate(env, |
| 70 GetJavaInfoBar()); | 70 GetJavaInfoBar()); |
| 71 } | 71 } |
| 72 } else if (action == InfoBarAndroid::ACTION_TRANSLATE_SHOW_ORIGINAL) { | 72 } else if (action == InfoBarAndroid::ACTION_TRANSLATE_SHOW_ORIGINAL) { |
| 73 action_flags_ |= FLAG_REVERT; | 73 action_flags_ |= FLAG_REVERT; |
| 74 delegate->RevertTranslation(); | 74 delegate->RevertWithoutClosingInfobar(); |
| 75 } else if (action == InfoBarAndroid::ACTION_CANCEL) { | 75 } else if (action == InfoBarAndroid::ACTION_CANCEL) { |
| 76 delegate->TranslationDeclined(); | 76 delegate->TranslationDeclined(); |
| 77 } else { | 77 } else { |
| 78 DCHECK_EQ(InfoBarAndroid::ACTION_NONE, action); | 78 DCHECK_EQ(InfoBarAndroid::ACTION_NONE, action); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 void TranslateCompactInfoBar::SetJavaInfoBar( | 82 void TranslateCompactInfoBar::SetJavaInfoBar( |
| 83 const base::android::JavaRef<jobject>& java_info_bar) { | 83 const base::android::JavaRef<jobject>& java_info_bar) { |
| 84 InfoBarAndroid::SetJavaInfoBar(java_info_bar); | 84 InfoBarAndroid::SetJavaInfoBar(java_info_bar); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 bool TranslateCompactInfoBar::IsDeclinedByUser() { | 167 bool TranslateCompactInfoBar::IsDeclinedByUser() { |
| 168 return action_flags_ == FLAG_NONE; | 168 return action_flags_ == FLAG_NONE; |
| 169 }; | 169 }; |
| 170 | 170 |
| 171 // Native JNI methods --------------------------------------------------------- | 171 // Native JNI methods --------------------------------------------------------- |
| 172 | 172 |
| 173 // static | 173 // static |
| 174 bool RegisterTranslateCompactInfoBar(JNIEnv* env) { | 174 bool RegisterTranslateCompactInfoBar(JNIEnv* env) { |
| 175 return RegisterNativesImpl(env); | 175 return RegisterNativesImpl(env); |
| 176 } | 176 } |
| OLD | NEW |