1 // Copyright 2014 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.
5 #include "chrome/browser/ui/android/infobars/generated_password_saved_infobar.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h"
9 #include "chrome/browser/infobars/infobar_service.h"
10 #include "content/public/browser/web_contents.h"
11 #include "jni/GeneratedPasswordSavedInfoBarDelegate_jni.h"
14 void GeneratedPasswordSavedInfoBarDelegateAndroid::Create(
15 content::WebContents
* web_contents
) {
16 InfoBarService::FromWebContents(web_contents
)
17 ->AddInfoBar(make_scoped_ptr(new GeneratedPasswordSavedInfoBar(
18 make_scoped_ptr(new GeneratedPasswordSavedInfoBarDelegateAndroid(
22 GeneratedPasswordSavedInfoBar::GeneratedPasswordSavedInfoBar(
23 scoped_ptr
<GeneratedPasswordSavedInfoBarDelegateAndroid
> delegate
)
24 : InfoBarAndroid(delegate
.Pass()) {
27 GeneratedPasswordSavedInfoBar::~GeneratedPasswordSavedInfoBar() {
30 base::android::ScopedJavaLocalRef
<jobject
>
31 GeneratedPasswordSavedInfoBar::CreateRenderInfoBar(JNIEnv
* env
) {
32 GeneratedPasswordSavedInfoBarDelegateAndroid
* infobar_delegate
=
33 static_cast<GeneratedPasswordSavedInfoBarDelegateAndroid
*>(delegate());
35 return Java_GeneratedPasswordSavedInfoBarDelegate_show(
36 env
, GetEnumeratedIconId(),
37 base::android::ConvertUTF16ToJavaString(
38 env
, infobar_delegate
->message_text()).obj(),
39 infobar_delegate
->inline_link_range().start(),
40 infobar_delegate
->inline_link_range().end(),
41 base::android::ConvertUTF16ToJavaString(
42 env
, infobar_delegate
->button_label()).obj());
45 void GeneratedPasswordSavedInfoBar::OnLinkClicked(JNIEnv
* env
, jobject obj
) {
49 static_cast<GeneratedPasswordSavedInfoBarDelegateAndroid
*>(delegate())
50 ->OnInlineLinkClicked();
54 void GeneratedPasswordSavedInfoBar::ProcessButton(
56 const std::string
& action_value
) {
63 bool RegisterGeneratedPasswordSavedInfoBarDelegate(JNIEnv
* env
) {
64 return RegisterNativesImpl(env
);