OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/android/infobars/autofill_credit_card_filling_infoba
r.h" |
| 6 |
| 7 #include <utility> |
| 8 |
| 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" |
| 11 #include "base/memory/ptr_util.h" |
| 12 #include "chrome/browser/android/resource_mapper.h" |
| 13 #include "chrome/browser/infobars/infobar_service.h" |
| 14 #include "components/autofill/core/browser/autofill_credit_card_filling_infobar_
delegate_mobile.h" |
| 15 #include "jni/AutofillCreditCardFillingInfoBar_jni.h" |
| 16 #include "ui/gfx/android/java_bitmap.h" |
| 17 #include "ui/gfx/image/image.h" |
| 18 #include "url/gurl.h" |
| 19 |
| 20 AutofillCreditCardFillingInfoBar::AutofillCreditCardFillingInfoBar( |
| 21 std::unique_ptr<autofill::AutofillCreditCardFillingInfoBarDelegateMobile> |
| 22 delegate) |
| 23 : ConfirmInfoBar(std::move(delegate)) {} |
| 24 |
| 25 AutofillCreditCardFillingInfoBar::~AutofillCreditCardFillingInfoBar() {} |
| 26 |
| 27 base::android::ScopedJavaLocalRef<jobject> |
| 28 AutofillCreditCardFillingInfoBar::CreateRenderInfoBar(JNIEnv* env) { |
| 29 autofill::AutofillCreditCardFillingInfoBarDelegateMobile* delegate = |
| 30 static_cast<autofill::AutofillCreditCardFillingInfoBarDelegateMobile*>( |
| 31 GetDelegate()); |
| 32 ScopedJavaLocalRef<jobject> java_bitmap; |
| 33 if (delegate->GetIconId() == infobars::InfoBarDelegate::kNoIconID && |
| 34 !delegate->GetIcon().IsEmpty()) { |
| 35 java_bitmap = gfx::ConvertToJavaBitmap(delegate->GetIcon().ToSkBitmap()); |
| 36 } |
| 37 |
| 38 base::android::ScopedJavaLocalRef<jobject> java_delegate = |
| 39 Java_AutofillCreditCardFillingInfoBar_create( |
| 40 env, reinterpret_cast<intptr_t>(this), GetEnumeratedIconId(), |
| 41 java_bitmap.obj(), |
| 42 base::android::ConvertUTF16ToJavaString( |
| 43 env, delegate->GetMessageText()) |
| 44 .obj(), |
| 45 base::android::ConvertUTF16ToJavaString( |
| 46 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK)) |
| 47 .obj(), |
| 48 base::android::ConvertUTF16ToJavaString( |
| 49 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL)) |
| 50 .obj()); |
| 51 |
| 52 Java_AutofillCreditCardFillingInfoBar_addDetail( |
| 53 env, java_delegate.obj(), |
| 54 ResourceMapper::MapFromChromiumId(delegate->issuer_icon_id()), |
| 55 base::android::ConvertUTF16ToJavaString(env, delegate->card_label()) |
| 56 .obj(), |
| 57 base::android::ConvertUTF16ToJavaString(env, delegate->card_sub_label()) |
| 58 .obj()); |
| 59 |
| 60 return java_delegate; |
| 61 } |
OLD | NEW |