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 package org.chromium.chrome.browser.infobar;
7 import android.widget.CheckBox;
9 import org.chromium.chrome.browser.password_manager.PasswordAuthenticationManager;
12 * The infobar that allows saving passwords for autofill.
14 public class SavePasswordInfoBar extends ConfirmInfoBar {
16 private final SavePasswordInfoBarDelegate mDelegate;
17 private final long mNativeInfoBar;
18 private CheckBox mUseAdditionalAuthenticationCheckbox;
20 public SavePasswordInfoBar(long nativeInfoBar, SavePasswordInfoBarDelegate delegate,
21 int iconDrawableId, String message, String primaryButtonText,
22 String secondaryButtonText) {
23 super(nativeInfoBar, null, iconDrawableId, message,
24 null, primaryButtonText, secondaryButtonText);
25 mNativeInfoBar = nativeInfoBar;
30 public void createContent(InfoBarLayout layout) {
31 if (PasswordAuthenticationManager.isPasswordAuthenticationEnabled()) {
32 mUseAdditionalAuthenticationCheckbox = new CheckBox(getContext());
33 mUseAdditionalAuthenticationCheckbox.setText(
34 PasswordAuthenticationManager.getPasswordProtectionString());
35 layout.setCustomContent(mUseAdditionalAuthenticationCheckbox);
38 super.createContent(layout);
42 public void onButtonClicked(boolean isPrimaryButton) {
43 if (isPrimaryButton && mUseAdditionalAuthenticationCheckbox != null
44 && mUseAdditionalAuthenticationCheckbox.isChecked()) {
45 mDelegate.setUseAdditionalAuthentication(mNativeInfoBar, true);
47 super.onButtonClicked(isPrimaryButton);