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 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 ScopedJavaLocalRef<jobject> TranslateCompactInfoBar::CreateRenderInfoBar( | 38 ScopedJavaLocalRef<jobject> TranslateCompactInfoBar::CreateRenderInfoBar( |
39 JNIEnv* env) { | 39 JNIEnv* env) { |
40 translate::TranslateInfoBarDelegate* delegate = GetDelegate(); | 40 translate::TranslateInfoBarDelegate* delegate = GetDelegate(); |
41 | 41 |
42 base::android::ScopedJavaLocalRef<jobjectArray> java_languages = | 42 base::android::ScopedJavaLocalRef<jobjectArray> java_languages = |
43 TranslateUtils::GetJavaLanguages(env, delegate); | 43 TranslateUtils::GetJavaLanguages(env, delegate); |
44 base::android::ScopedJavaLocalRef<jobjectArray> java_codes = | 44 base::android::ScopedJavaLocalRef<jobjectArray> java_codes = |
45 TranslateUtils::GetJavaLanguageCodes(env, delegate); | 45 TranslateUtils::GetJavaLanguageCodes(env, delegate); |
| 46 base::android::ScopedJavaLocalRef<jintArray> java_hash_codes = |
| 47 TranslateUtils::GetJavaLanguageHashCodes(env, delegate); |
46 | 48 |
47 ScopedJavaLocalRef<jstring> source_language_code = | 49 ScopedJavaLocalRef<jstring> source_language_code = |
48 base::android::ConvertUTF8ToJavaString( | 50 base::android::ConvertUTF8ToJavaString( |
49 env, delegate->original_language_code()); | 51 env, delegate->original_language_code()); |
50 | 52 |
51 ScopedJavaLocalRef<jstring> target_language_code = | 53 ScopedJavaLocalRef<jstring> target_language_code = |
52 base::android::ConvertUTF8ToJavaString(env, | 54 base::android::ConvertUTF8ToJavaString(env, |
53 delegate->target_language_code()); | 55 delegate->target_language_code()); |
54 return Java_TranslateCompactInfoBar_create( | 56 return Java_TranslateCompactInfoBar_create( |
55 env, delegate->translate_step(), source_language_code, | 57 env, delegate->translate_step(), source_language_code, |
56 target_language_code, delegate->ShouldAlwaysTranslate(), | 58 target_language_code, delegate->ShouldAlwaysTranslate(), |
57 delegate->triggered_from_menu(), java_languages, java_codes); | 59 delegate->triggered_from_menu(), java_languages, java_codes, |
| 60 java_hash_codes); |
58 } | 61 } |
59 | 62 |
60 void TranslateCompactInfoBar::ProcessButton(int action) { | 63 void TranslateCompactInfoBar::ProcessButton(int action) { |
61 if (!owner()) | 64 if (!owner()) |
62 return; // We're closing; don't call anything, it might access the owner. | 65 return; // We're closing; don't call anything, it might access the owner. |
63 | 66 |
64 // TODO(ramyasharma): Handle other button clicks. | 67 // TODO(ramyasharma): Handle other button clicks. |
65 translate::TranslateInfoBarDelegate* delegate = GetDelegate(); | 68 translate::TranslateInfoBarDelegate* delegate = GetDelegate(); |
66 if (action == InfoBarAndroid::ACTION_TRANSLATE) | 69 if (action == InfoBarAndroid::ACTION_TRANSLATE) |
67 delegate->Translate(); | 70 delegate->Translate(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 translate::TranslateInfoBarDelegate* TranslateCompactInfoBar::GetDelegate() { | 142 translate::TranslateInfoBarDelegate* TranslateCompactInfoBar::GetDelegate() { |
140 return delegate()->AsTranslateInfoBarDelegate(); | 143 return delegate()->AsTranslateInfoBarDelegate(); |
141 } | 144 } |
142 | 145 |
143 // Native JNI methods --------------------------------------------------------- | 146 // Native JNI methods --------------------------------------------------------- |
144 | 147 |
145 // static | 148 // static |
146 bool RegisterTranslateCompactInfoBar(JNIEnv* env) { | 149 bool RegisterTranslateCompactInfoBar(JNIEnv* env) { |
147 return RegisterNativesImpl(env); | 150 return RegisterNativesImpl(env); |
148 } | 151 } |
OLD | NEW |