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

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

Issue 2026353002: [Autofill] Credit Card Assist Infobar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed more comments 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_assist_infobar.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_assist_infobar_delegate_mobi le.h"
15 #include "components/autofill/core/browser/autofill_assist_infobar_mobile.h"
16 #include "jni/AutofillAssistInfoBar_jni.h"
17 #include "ui/gfx/android/java_bitmap.h"
18 #include "ui/gfx/image/image.h"
19 #include "url/gurl.h"
20
21 namespace autofill {
22
23 // Declaration is found in
24 // components/autofill/core/browser/autofill_assist_infobar_mobile.h
25 std::unique_ptr<infobars::InfoBar> CreateAssistInfoBar(
26 std::unique_ptr<AutofillAssistInfoBarDelegateMobile> delegate) {
27 return base::WrapUnique(new AutofillAssistInfoBar(std::move(delegate)));
28 }
29
30 } // namespace autofill
31
32 AutofillAssistInfoBar::AutofillAssistInfoBar(
33 std::unique_ptr<autofill::AutofillAssistInfoBarDelegateMobile> delegate)
34 : ConfirmInfoBar(std::move(delegate)) {}
35
36 AutofillAssistInfoBar::~AutofillAssistInfoBar() {}
gone 2016/08/01 20:35:54 Would be good to add a JNI call to the java side t
Mathieu 2016/08/01 22:16:57 actually looks like the pointer wasn't being used
37
38 // static
39 bool AutofillAssistInfoBar::Register(JNIEnv* env) {
40 return RegisterNativesImpl(env);
41 }
42
43 base::android::ScopedJavaLocalRef<jobject>
44 AutofillAssistInfoBar::CreateRenderInfoBar(JNIEnv* env) {
45 autofill::AutofillAssistInfoBarDelegateMobile* delegate =
46 static_cast<autofill::AutofillAssistInfoBarDelegateMobile*>(
47 GetDelegate());
48 ScopedJavaLocalRef<jobject> java_bitmap;
49 if (delegate->GetIconId() == infobars::InfoBarDelegate::kNoIconID &&
50 !delegate->GetIcon().IsEmpty()) {
51 java_bitmap = gfx::ConvertToJavaBitmap(delegate->GetIcon().ToSkBitmap());
52 }
53
54 base::android::ScopedJavaLocalRef<jobject> java_delegate =
55 Java_AutofillAssistInfoBar_create(
56 env, reinterpret_cast<intptr_t>(this), GetEnumeratedIconId(),
57 java_bitmap.obj(), base::android::ConvertUTF16ToJavaString(
gone 2016/08/01 20:35:54 nit: Does it look cleaner if you move the ConvertU
Mathieu 2016/08/01 22:16:57 Let's blame `git cl format' :)
58 env, delegate->GetMessageText())
59 .obj(),
60 base::android::ConvertUTF16ToJavaString(
61 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK))
62 .obj(),
63 base::android::ConvertUTF16ToJavaString(
64 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL))
65 .obj());
66
67 Java_AutofillAssistInfoBar_addDetail(
68 env, java_delegate.obj(),
69 ResourceMapper::MapFromChromiumId(delegate->issuer_icon_id()),
70 base::android::ConvertUTF16ToJavaString(env, delegate->card_label())
71 .obj(),
72 base::android::ConvertUTF16ToJavaString(env, delegate->card_sub_label())
73 .obj());
74
75 return java_delegate;
76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698