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/snackbars/auto_signin_prompt_controller.h" |
| 6 |
| 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.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" |
| 12 #include "chrome/grit/generated_resources.h" |
| 13 #include "components/password_manager/core/browser/password_bubble_experiment.h" |
| 14 #include "content/public/browser/web_contents.h" |
| 15 #include "jni/AutoSigninSnackbarController_jni.h" |
| 16 #include "ui/base/l10n/l10n_util.h" |
| 17 |
| 18 void ShowAutoSigninPrompt(content::WebContents* web_contents, |
| 19 const base::string16& username) { |
| 20 Profile* profile = |
| 21 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 22 base::string16 message = l10n_util::GetStringFUTF16( |
| 23 IDS_MANAGE_PASSWORDS_AUTO_SIGNIN_TITLE, username); |
| 24 |
| 25 if (password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( |
| 26 profile->GetPrefs())) { |
| 27 AutoSigninFirstRunInfoBarDelegate::Create(web_contents, message); |
| 28 } else { |
| 29 JNIEnv* env = base::android::AttachCurrentThread(); |
| 30 TabAndroid* tab = TabAndroid::FromWebContents(web_contents); |
| 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 } |
| 37 |
| 38 bool RegisterAutoSigninSnackbarController(JNIEnv* env) { |
| 39 return RegisterNativesImpl(env); |
| 40 } |
OLD | NEW |