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

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: tests 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 std::unique_ptr<infobars::InfoBar> CreateAssistInfoBar(
please use gerrit instead 2016/07/27 17:02:26 Should we put a comment here akin to "Declared in
Mathieu 2016/07/27 21:35:52 Done.
24 std::unique_ptr<AutofillAssistInfoBarDelegateMobile> delegate) {
25 return base::WrapUnique(new AutofillAssistInfoBar(std::move(delegate)));
26 }
27
28 } // namespace autofill
29
30 AutofillAssistInfoBar::AutofillAssistInfoBar(
31 std::unique_ptr<autofill::AutofillAssistInfoBarDelegateMobile> delegate)
32 : ConfirmInfoBar(std::move(delegate)) {}
33
34 AutofillAssistInfoBar::~AutofillAssistInfoBar() {}
35
36 // static
37 bool AutofillAssistInfoBar::Register(JNIEnv* env) {
38 return RegisterNativesImpl(env);
39 }
40
41 base::android::ScopedJavaLocalRef<jobject>
42 AutofillAssistInfoBar::CreateRenderInfoBar(JNIEnv* env) {
43 autofill::AutofillAssistInfoBarDelegateMobile* delegate = GetAssistDelegate();
please use gerrit instead 2016/07/27 17:02:26 This function is called only once, so you can remo
Mathieu 2016/07/27 21:35:52 Done.
44 ScopedJavaLocalRef<jobject> java_bitmap;
45 if (delegate->GetIconId() == infobars::InfoBarDelegate::kNoIconID &&
46 !delegate->GetIcon().IsEmpty()) {
47 java_bitmap = gfx::ConvertToJavaBitmap(delegate->GetIcon().ToSkBitmap());
48 }
49
50 base::android::ScopedJavaLocalRef<jobject> java_delegate =
51 Java_AutofillAssistInfoBar_create(
52 env, reinterpret_cast<intptr_t>(this), GetEnumeratedIconId(),
53 java_bitmap.obj(), base::android::ConvertUTF16ToJavaString(
54 env, delegate->GetMessageText())
55 .obj(),
56 base::android::ConvertUTF16ToJavaString(
57 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK))
58 .obj(),
59 base::android::ConvertUTF16ToJavaString(
60 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL))
61 .obj());
62
63 Java_AutofillAssistInfoBar_addDetail(
64 env, java_delegate.obj(),
65 ResourceMapper::MapFromChromiumId(delegate->issuer_icon_id()),
66 base::android::ConvertUTF16ToJavaString(env, delegate->card_label())
67 .obj(),
68 base::android::ConvertUTF16ToJavaString(env, delegate->card_sub_label())
69 .obj());
70
71 return java_delegate;
72 }
73
74 autofill::AutofillAssistInfoBarDelegateMobile*
75 AutofillAssistInfoBar::GetAssistDelegate() {
please use gerrit instead 2016/07/27 17:02:26 Can be removed.
Mathieu 2016/07/27 21:35:52 Acknowledged.
76 return static_cast<autofill::AutofillAssistInfoBarDelegateMobile*>(
77 GetDelegate());
78 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698