OLD | NEW |
| (Empty) |
1 // Copyright 2015 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/auto_signin_first_run_infobar.h" | |
6 | |
7 #include <utility> | |
8 | |
9 #include "base/android/jni_android.h" | |
10 #include "base/android/jni_array.h" | |
11 #include "base/android/jni_string.h" | |
12 #include "components/password_manager/core/common/credential_manager_types.h" | |
13 #include "jni/AutoSigninFirstRunInfoBar_jni.h" | |
14 | |
15 AutoSigninFirstRunInfoBar::AutoSigninFirstRunInfoBar( | |
16 scoped_ptr<AutoSigninFirstRunInfoBarDelegate> delegate) | |
17 : ConfirmInfoBar(std::move(delegate)) {} | |
18 | |
19 AutoSigninFirstRunInfoBar::~AutoSigninFirstRunInfoBar() {} | |
20 | |
21 base::android::ScopedJavaLocalRef<jobject> | |
22 AutoSigninFirstRunInfoBar::CreateRenderInfoBar(JNIEnv* env) { | |
23 using base::android::ConvertUTF16ToJavaString; | |
24 using base::android::ScopedJavaLocalRef; | |
25 AutoSigninFirstRunInfoBarDelegate* auto_signin_infobar_delegate = | |
26 static_cast<AutoSigninFirstRunInfoBarDelegate*>(delegate()); | |
27 ScopedJavaLocalRef<jstring> ok_button_text = ConvertUTF16ToJavaString( | |
28 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_OK)); | |
29 ScopedJavaLocalRef<jstring> cancel_button_text = ConvertUTF16ToJavaString( | |
30 env, GetTextFor(ConfirmInfoBarDelegate::BUTTON_CANCEL)); | |
31 ScopedJavaLocalRef<jstring> explanation_text = ConvertUTF16ToJavaString( | |
32 env, auto_signin_infobar_delegate->GetExplanation()); | |
33 ScopedJavaLocalRef<jstring> message_text = ConvertUTF16ToJavaString( | |
34 env, auto_signin_infobar_delegate->GetMessageText()); | |
35 | |
36 return Java_AutoSigninFirstRunInfoBar_show( | |
37 env, message_text.obj(), ok_button_text.obj(), explanation_text.obj(), | |
38 auto_signin_infobar_delegate->message_link_range().start(), | |
39 auto_signin_infobar_delegate->message_link_range().end()); | |
40 } | |
41 | |
42 void AutoSigninFirstRunInfoBar::OnLinkClicked( | |
43 JNIEnv* env, | |
44 const JavaParamRef<jobject>& obj) { | |
45 GetDelegate()->LinkClicked(NEW_FOREGROUND_TAB); | |
46 } | |
47 | |
48 bool AutoSigninFirstRunInfoBar::Register(JNIEnv* env) { | |
49 return RegisterNativesImpl(env); | |
50 } | |
51 | |
52 scoped_ptr<infobars::InfoBar> CreateAutoSigninFirstRunInfoBar( | |
53 scoped_ptr<AutoSigninFirstRunInfoBarDelegate> delegate) { | |
54 return make_scoped_ptr(new AutoSigninFirstRunInfoBar(std::move(delegate))); | |
55 } | |
OLD | NEW |