OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.h" | 5 #include "chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.h" |
6 | 6 |
7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
9 #include "chrome/browser/android/tab_android.h" | 9 #include "chrome/browser/android/tab_android.h" |
10 #include "chrome/browser/password_manager/auto_signin_first_run_infobar_delegate
.h" | |
11 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
13 #include "components/password_manager/core/browser/password_bubble_experiment.h" | 12 #include "components/password_manager/core/browser/password_bubble_experiment.h" |
14 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
15 #include "jni/AutoSigninSnackbarController_jni.h" | 14 #include "jni/AutoSigninSnackbarController_jni.h" |
16 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
17 | 16 |
18 void ShowAutoSigninPrompt(content::WebContents* web_contents, | 17 void ShowAutoSigninPrompt(content::WebContents* web_contents, |
19 const base::string16& username) { | 18 const base::string16& username) { |
20 Profile* profile = | |
21 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | |
22 base::string16 message = l10n_util::GetStringFUTF16( | 19 base::string16 message = l10n_util::GetStringFUTF16( |
23 IDS_MANAGE_PASSWORDS_AUTO_SIGNIN_TITLE, username); | 20 IDS_MANAGE_PASSWORDS_AUTO_SIGNIN_TITLE, username); |
24 | 21 |
25 if (password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( | 22 JNIEnv* env = base::android::AttachCurrentThread(); |
26 profile->GetPrefs())) { | 23 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); |
27 AutoSigninFirstRunInfoBarDelegate::Create(web_contents, message); | 24 ScopedJavaLocalRef<jstring> java_message = |
28 } else { | 25 base::android::ConvertUTF16ToJavaString(env, message); |
29 JNIEnv* env = base::android::AttachCurrentThread(); | 26 Java_AutoSigninSnackbarController_showSnackbar( |
30 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); | 27 env, tab->GetJavaObject().obj(), java_message.obj()); |
31 ScopedJavaLocalRef<jstring> java_message = | |
32 base::android::ConvertUTF16ToJavaString(env, message); | |
33 Java_AutoSigninSnackbarController_showSnackbar( | |
34 env, tab->GetJavaObject().obj(), java_message.obj()); | |
35 } | |
36 } | 28 } |
37 | 29 |
38 bool RegisterAutoSigninSnackbarController(JNIEnv* env) { | 30 bool RegisterAutoSigninSnackbarController(JNIEnv* env) { |
39 return RegisterNativesImpl(env); | 31 return RegisterNativesImpl(env); |
40 } | 32 } |
OLD | NEW |