Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/browser/ui/android/infobars/autofill_credit_card_filling_infobar.cc

Issue 2026353002: [Autofill] Credit Card Assist Infobar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed CreateCreditCardFillingInfoBar from interface Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 // static
28 bool AutofillCreditCardFillingInfoBar::Register(JNIEnv* env) {
29 return RegisterNativesImpl(env);
30 }
31
32 base::android::ScopedJavaLocalRef<jobject>
33 AutofillCreditCardFillingInfoBar::CreateRenderInfoBar(JNIEnv* env) {
34 autofill::AutofillCreditCardFillingInfoBarDelegateMobile* delegate =
35 static_cast<autofill::AutofillCreditCardFillingInfoBarDelegateMobile*>(
36 GetDelegate());
37 ScopedJavaLocalRef<jobject> java_bitmap;
38 if (delegate->GetIconId() == infobars::InfoBarDelegate::kNoIconID &&
39 !delegate->GetIcon().IsEmpty()) {
40 java_bitmap = gfx::ConvertToJavaBitmap(delegate->GetIcon().ToSkBitmap());
41 }
42
43 base::android::ScopedJavaLocalRef<jobject> java_delegate =
44 Java_AutofillCreditCardFillingInfoBar_create(
45 env, reinterpret_cast<intptr_t>(this), GetEnumeratedIconId(),
46 java_bitmap.obj(), base::android::ConvertUTF16ToJavaString(
47 env, delegate->GetMessageText())
48 .obj(),
49 base::android::ConvertUTF16ToJavaString(
50 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK))
51 .obj(),
52 base::android::ConvertUTF16ToJavaString(
53 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL))
54 .obj());
55
56 Java_AutofillCreditCardFillingInfoBar_addDetail(
57 env, java_delegate.obj(),
58 ResourceMapper::MapFromChromiumId(delegate->issuer_icon_id()),
59 base::android::ConvertUTF16ToJavaString(env, delegate->card_label())
60 .obj(),
61 base::android::ConvertUTF16ToJavaString(env, delegate->card_sub_label())
62 .obj());
63
64 return java_delegate;
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698