| Index: chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.cc
|
| diff --git a/chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.cc b/chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2edc8a5385b393b0815516f564ada0fc92f0c493
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.cc
|
| @@ -0,0 +1,40 @@
|
| +// Copyright 2015 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/snackbars/auto_signin_prompt_controller.h"
|
| +
|
| +#include "base/android/jni_android.h"
|
| +#include "base/android/jni_string.h"
|
| +#include "chrome/browser/android/tab_android.h"
|
| +#include "chrome/browser/password_manager/auto_signin_first_run_infobar_delegate.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/grit/generated_resources.h"
|
| +#include "components/password_manager/core/browser/password_bubble_experiment.h"
|
| +#include "content/public/browser/web_contents.h"
|
| +#include "jni/AutoSigninSnackbarController_jni.h"
|
| +#include "ui/base/l10n/l10n_util.h"
|
| +
|
| +void ShowAutoSigninPrompt(content::WebContents* web_contents,
|
| + const base::string16& username) {
|
| + Profile* profile =
|
| + Profile::FromBrowserContext(web_contents->GetBrowserContext());
|
| + base::string16 message = l10n_util::GetStringFUTF16(
|
| + IDS_MANAGE_PASSWORDS_AUTO_SIGNIN_TITLE, username);
|
| +
|
| + if (password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience(
|
| + profile->GetPrefs())) {
|
| + AutoSigninFirstRunInfoBarDelegate::Create(web_contents, message);
|
| + } else {
|
| + JNIEnv* env = base::android::AttachCurrentThread();
|
| + TabAndroid* tab = TabAndroid::FromWebContents(web_contents);
|
| + ScopedJavaLocalRef<jstring> java_message =
|
| + base::android::ConvertUTF16ToJavaString(env, message);
|
| + Java_AutoSigninSnackbarController_showSnackbar(
|
| + env, tab->GetJavaObject().obj(), java_message.obj());
|
| + }
|
| +}
|
| +
|
| +bool RegisterAutoSigninSnackbarController(JNIEnv* env) {
|
| + return RegisterNativesImpl(env);
|
| +}
|
|
|