Upstream version 11.39.266.0
[platform/framework/web/crosswalk.git] / src / chrome / android / java / src / org / chromium / chrome / browser / infobar / SavePasswordInfoBarDelegate.java
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.
4
5 package org.chromium.chrome.browser.infobar;
6
7 import org.chromium.base.CalledByNative;
8 import org.chromium.chrome.browser.ResourceId;
9
10 /**
11  * Provides JNI methods for SavePasswordInfoBars.
12  */
13 public class SavePasswordInfoBarDelegate {
14     private SavePasswordInfoBarDelegate() {
15     }
16
17     @CalledByNative
18     public static SavePasswordInfoBarDelegate create() {
19         return new SavePasswordInfoBarDelegate();
20     }
21
22     /**
23      * Creates and begins the process for showing a SavePasswordInfoBarDelegate.
24      * @param nativeInfoBar Pointer to the C++ InfoBar corresponding to the Java InfoBar.
25      * @param enumeratedIconId ID corresponding to the icon that will be shown for the InfoBar.
26      *                         The ID must have been mapped using the ResourceMapper class before
27      *                         passing it to this function.
28      * @param message Message to display to the user indicating what the InfoBar is for.
29      * @param buttonOk String to display on the OK button.
30      * @param buttonCancel String to display on the Cancel button.
31      */
32     @CalledByNative
33     InfoBar showSavePasswordInfoBar(long nativeInfoBar, int enumeratedIconId, String message,
34             String buttonOk, String buttonCancel) {
35         int drawableId = ResourceId.mapToDrawableId(enumeratedIconId);
36         SavePasswordInfoBar infoBar = new SavePasswordInfoBar(
37                 nativeInfoBar, this, drawableId, message, buttonOk, buttonCancel);
38         return infoBar;
39     }
40
41     /**
42      * Sets whether additional authentication should be required before this password can be
43      * autofilled into a form.
44      *
45      * @param nativeInfoBar The native infobar pointer.
46      * @param useAdditionalAuthencation Whether additional authentication should be required.
47      */
48     void setUseAdditionalAuthentication(long nativeInfoBar, boolean useAdditionalAuthencation) {
49         nativeSetUseAdditionalAuthentication(nativeInfoBar, useAdditionalAuthencation);
50     }
51
52     private native void nativeSetUseAdditionalAuthentication(
53             long nativeSavePasswordInfoBar, boolean useAdditionalAuthentication);
54 }