OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 package org.chromium.chrome.browser.password_manager; | 5 package org.chromium.chrome.browser.password_manager; |
6 | 6 |
7 import org.chromium.base.CalledByNative; | 7 import org.chromium.base.CalledByNative; |
8 import org.chromium.chrome.browser.TabBase; | 8 import org.chromium.chrome.browser.Tab; |
9 | 9 |
10 /** | 10 /** |
11 * Allows embedders to authenticate the usage of passwords. | 11 * Allows embedders to authenticate the usage of passwords. |
12 */ | 12 */ |
13 public class PasswordAuthenticationManager { | 13 public class PasswordAuthenticationManager { |
14 | 14 |
15 /** | 15 /** |
16 * The delegate that allows embedders to control the authentication of passw
ords. | 16 * The delegate that allows embedders to control the authentication of passw
ords. |
17 */ | 17 */ |
18 public interface PasswordAuthenticationDelegate { | 18 public interface PasswordAuthenticationDelegate { |
19 /** | 19 /** |
20 * @return Whether password authentication is enabled. | 20 * @return Whether password authentication is enabled. |
21 */ | 21 */ |
22 boolean isPasswordAuthenticationEnabled(); | 22 boolean isPasswordAuthenticationEnabled(); |
23 | 23 |
24 /** | 24 /** |
25 * Requests password authentication be presented for the given tab. | 25 * Requests password authentication be presented for the given tab. |
26 * @param tab The tab containing the protected password. | 26 * @param tab The tab containing the protected password. |
27 * @param callback The callback to be triggered on authentication result
. | 27 * @param callback The callback to be triggered on authentication result
. |
28 */ | 28 */ |
29 void requestAuthentication(TabBase tab, PasswordAuthenticationCallback c
allback); | 29 void requestAuthentication(Tab tab, PasswordAuthenticationCallback callb
ack); |
30 | 30 |
31 /** | 31 /** |
32 * @return The message to be displayed in the save password infobar that
will allow | 32 * @return The message to be displayed in the save password infobar that
will allow |
33 * the user to opt-in to additional password authentication. | 33 * the user to opt-in to additional password authentication. |
34 */ | 34 */ |
35 String getPasswordProtectionString(); | 35 String getPasswordProtectionString(); |
36 } | 36 } |
37 | 37 |
38 /** | 38 /** |
39 * The callback to be triggered on success or failure of the password authen
tication. | 39 * The callback to be triggered on success or failure of the password authen
tication. |
(...skipping 25 matching lines...) Expand all Loading... |
65 } | 65 } |
66 | 66 |
67 private static class DefaultPasswordAuthenticationDelegate | 67 private static class DefaultPasswordAuthenticationDelegate |
68 implements PasswordAuthenticationDelegate { | 68 implements PasswordAuthenticationDelegate { |
69 @Override | 69 @Override |
70 public boolean isPasswordAuthenticationEnabled() { | 70 public boolean isPasswordAuthenticationEnabled() { |
71 return false; | 71 return false; |
72 } | 72 } |
73 | 73 |
74 @Override | 74 @Override |
75 public void requestAuthentication(TabBase tab, PasswordAuthenticationCal
lback callback) { | 75 public void requestAuthentication(Tab tab, PasswordAuthenticationCallbac
k callback) { |
76 callback.onResult(true); | 76 callback.onResult(true); |
77 } | 77 } |
78 | 78 |
79 @Override | 79 @Override |
80 public String getPasswordProtectionString() { | 80 public String getPasswordProtectionString() { |
81 return ""; | 81 return ""; |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 private static PasswordAuthenticationDelegate sDelegate; | 85 private static PasswordAuthenticationDelegate sDelegate; |
(...skipping 21 matching lines...) Expand all Loading... |
107 return getDelegate().isPasswordAuthenticationEnabled(); | 107 return getDelegate().isPasswordAuthenticationEnabled(); |
108 } | 108 } |
109 | 109 |
110 /** | 110 /** |
111 * Requests password authentication be presented for the given tab. | 111 * Requests password authentication be presented for the given tab. |
112 * @param tab The tab containing the protected password. | 112 * @param tab The tab containing the protected password. |
113 * @param callback The callback to be triggered on authentication result. | 113 * @param callback The callback to be triggered on authentication result. |
114 */ | 114 */ |
115 @CalledByNative | 115 @CalledByNative |
116 public static void requestAuthentication( | 116 public static void requestAuthentication( |
117 TabBase tab, PasswordAuthenticationCallback callback) { | 117 Tab tab, PasswordAuthenticationCallback callback) { |
118 getDelegate().requestAuthentication(tab, callback); | 118 getDelegate().requestAuthentication(tab, callback); |
119 } | 119 } |
120 | 120 |
121 /** | 121 /** |
122 * @return The message to be displayed in the save password infobar that wil
l allow the user | 122 * @return The message to be displayed in the save password infobar that wil
l allow the user |
123 * to opt-in to additional password authentication. | 123 * to opt-in to additional password authentication. |
124 */ | 124 */ |
125 public static String getPasswordProtectionString() { | 125 public static String getPasswordProtectionString() { |
126 return getDelegate().getPasswordProtectionString(); | 126 return getDelegate().getPasswordProtectionString(); |
127 } | 127 } |
128 | 128 |
129 private static native void nativeOnResult(long callbackPtr, boolean authenti
cated); | 129 private static native void nativeOnResult(long callbackPtr, boolean authenti
cated); |
130 } | 130 } |
OLD | NEW |