chromium 原生实现
3个关键类
SavePasswordsPreferences extends Fragment //password 界面
//负责和native层进行交互
public final class PasswordUIView {
//内部类, 代表一项password item
public static final class SavedPasswordEntry {
private final String mUrl;
private final String mName;
}
public interface PasswordListObserver {
/**
* Called when passwords list is updated.
* @param count Number of entries in the password list.
*/
void passwordListAvailable(int count);
/**
* Called when password exceptions list is updated.
* @param count Number of entries in the password exception list.
*/
void passwordExceptionListAvailable(int count);
}
private ObserverList<PasswordListObserver> mObservers =
new ObserverList<PasswordListObserver>();
//底层保存密码完后, jni调用java层的passwordListAvailable(), 进而通知所有的observer.
@CalledByNative
private void passwordListAvailable(int count) {
JLog.i(count);
for (PasswordListObserver observer : mObservers) {
observer.passwordListAvailable(count);
}
}
}
PasswordEntryEditor.java //Password entry editor that allows to view and delete passwords stored in Chrome.
项目自定义的实现
2个关键类
PasswordSettingActivity //保存密码的界面
PasswordAdapter //密码列表使用的adapter
保存密码的文件
chrome保存的位置:
/data/data/com.android.chrome/app_chrome/Default/Login Data
自己浏览器保存的位置:
/data/data/com.qihoo.browser/app_chrome/Default/Login Data
注意一点: 明文保存, 有一定的安全隐患.
-----DONE.-----