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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/android/infobars/autofill_assist_infobar.cc
diff --git a/chrome/browser/ui/android/infobars/autofill_assist_infobar.cc b/chrome/browser/ui/android/infobars/autofill_assist_infobar.cc
new file mode 100644
index 0000000000000000000000000000000000000000..679025babc7f3b951b4246e1e3dfef2da3784452
--- /dev/null
+++ b/chrome/browser/ui/android/infobars/autofill_assist_infobar.cc
@@ -0,0 +1,78 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/android/infobars/autofill_assist_infobar.h"
+
+#include <utility>
+
+#include "base/android/jni_android.h"
+#include "base/android/jni_string.h"
+#include "base/memory/ptr_util.h"
+#include "chrome/browser/android/resource_mapper.h"
+#include "chrome/browser/infobars/infobar_service.h"
+#include "components/autofill/core/browser/autofill_assist_infobar_delegate_mobile.h"
+#include "components/autofill/core/browser/autofill_assist_infobar_mobile.h"
+#include "jni/AutofillAssistInfoBar_jni.h"
+#include "ui/gfx/android/java_bitmap.h"
+#include "ui/gfx/image/image.h"
+#include "url/gurl.h"
+
+namespace autofill {
+
+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.
+ std::unique_ptr<AutofillAssistInfoBarDelegateMobile> delegate) {
+ return base::WrapUnique(new AutofillAssistInfoBar(std::move(delegate)));
+}
+
+} // namespace autofill
+
+AutofillAssistInfoBar::AutofillAssistInfoBar(
+ std::unique_ptr<autofill::AutofillAssistInfoBarDelegateMobile> delegate)
+ : ConfirmInfoBar(std::move(delegate)) {}
+
+AutofillAssistInfoBar::~AutofillAssistInfoBar() {}
+
+// static
+bool AutofillAssistInfoBar::Register(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+base::android::ScopedJavaLocalRef<jobject>
+AutofillAssistInfoBar::CreateRenderInfoBar(JNIEnv* env) {
+ 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.
+ ScopedJavaLocalRef<jobject> java_bitmap;
+ if (delegate->GetIconId() == infobars::InfoBarDelegate::kNoIconID &&
+ !delegate->GetIcon().IsEmpty()) {
+ java_bitmap = gfx::ConvertToJavaBitmap(delegate->GetIcon().ToSkBitmap());
+ }
+
+ base::android::ScopedJavaLocalRef<jobject> java_delegate =
+ Java_AutofillAssistInfoBar_create(
+ env, reinterpret_cast<intptr_t>(this), GetEnumeratedIconId(),
+ java_bitmap.obj(), base::android::ConvertUTF16ToJavaString(
+ env, delegate->GetMessageText())
+ .obj(),
+ base::android::ConvertUTF16ToJavaString(
+ env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK))
+ .obj(),
+ base::android::ConvertUTF16ToJavaString(
+ env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL))
+ .obj());
+
+ Java_AutofillAssistInfoBar_addDetail(
+ env, java_delegate.obj(),
+ ResourceMapper::MapFromChromiumId(delegate->issuer_icon_id()),
+ base::android::ConvertUTF16ToJavaString(env, delegate->card_label())
+ .obj(),
+ base::android::ConvertUTF16ToJavaString(env, delegate->card_sub_label())
+ .obj());
+
+ return java_delegate;
+}
+
+autofill::AutofillAssistInfoBarDelegateMobile*
+AutofillAssistInfoBar::GetAssistDelegate() {
please use gerrit instead 2016/07/27 17:02:26 Can be removed.
Mathieu 2016/07/27 21:35:52 Acknowledged.
+ return static_cast<autofill::AutofillAssistInfoBarDelegateMobile*>(
+ GetDelegate());
+}

Powered by Google App Engine
This is Rietveld 408576698