Chromium Code Reviews| 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..9b8e3482b7812b1e476d54765efba2018e707eeb | 
| --- /dev/null | 
| +++ b/chrome/browser/ui/android/infobars/autofill_assist_infobar.cc | 
| @@ -0,0 +1,76 @@ | 
| +// 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 { | 
| + | 
| +// Declaration is found in | 
| +// components/autofill/core/browser/autofill_assist_infobar_mobile.h | 
| +std::unique_ptr<infobars::InfoBar> CreateAssistInfoBar( | 
| + 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() {} | 
| 
 
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
 
 | 
| + | 
| +// static | 
| +bool AutofillAssistInfoBar::Register(JNIEnv* env) { | 
| + return RegisterNativesImpl(env); | 
| +} | 
| + | 
| +base::android::ScopedJavaLocalRef<jobject> | 
| +AutofillAssistInfoBar::CreateRenderInfoBar(JNIEnv* env) { | 
| + autofill::AutofillAssistInfoBarDelegateMobile* delegate = | 
| + static_cast<autofill::AutofillAssistInfoBarDelegateMobile*>( | 
| + GetDelegate()); | 
| + 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( | 
| 
 
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' :)
 
 | 
| + 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; | 
| +} |