Commit 849cd419 authored by Jan Wilken Dörrie's avatar Jan Wilken Dörrie Committed by Commit Bot

[Passwords] Add native bindings for UpdateCredential

This change adds native bindings in the Password Check to be able to
update a compromised credential.

Bug: 1114720
Change-Id: I6a3de9a4f79b88f17c7594a181d8b7e10c9e10bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2352927
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Auto-Submit: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarFriedrich [CET] <fhorschig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798133}
parent b87824dd
......@@ -137,6 +137,11 @@ class PasswordCheckBridge {
mNativePasswordCheckBridge, credentials);
}
void updateCredential(CompromisedCredential credential, String newPassword) {
PasswordCheckBridgeJni.get().updateCredential(
mNativePasswordCheckBridge, credential, newPassword);
}
void removeCredential(CompromisedCredential credential) {
PasswordCheckBridgeJni.get().removeCredential(mNativePasswordCheckBridge, credential);
}
......@@ -163,6 +168,8 @@ class PasswordCheckBridge {
int getSavedPasswordsCount(long nativePasswordCheckBridge);
void getCompromisedCredentials(
long nativePasswordCheckBridge, CompromisedCredential[] credentials);
void updateCredential(long nativePasswordCheckBridge, CompromisedCredential credential,
String newPassword);
void removeCredential(long nativePasswordCheckBridge, CompromisedCredential credentials);
void destroy(long nativePasswordCheckBridge);
}
......
......@@ -73,6 +73,11 @@ class PasswordCheckImpl implements PasswordCheck, PasswordCheckObserver {
}
}
@Override
public void updateCredential(CompromisedCredential credential, String newPassword) {
mPasswordCheckBridge.updateCredential(credential, newPassword);
}
@Override
public void removeCredential(CompromisedCredential credential) {
mPasswordCheckBridge.removeCredential(credential);
......
......@@ -91,6 +91,13 @@ public interface PasswordCheck extends PasswordCheckComponentUi.Delegate {
*/
CompromisedCredential[] getCompromisedCredentials();
/**
* Update the given credential in the password store.
* @param credential A {@link CompromisedCredential}.
* @param newPassword The new password for the credential.
*/
void updateCredential(CompromisedCredential credential, String newPassword);
/**
* @return The latest available number of all saved passwords. If this is invoked before
* {@link Observer#onSavedPasswordsFetchCompleted}, the returned value is likely invalid.
......
......@@ -85,6 +85,15 @@ void PasswordCheckBridge::GetCompromisedCredentials(
}
}
void PasswordCheckBridge::UpdateCredential(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& credential,
const base::android::JavaParamRef<jstring>& new_password) {
check_manager_.UpdateCredential(
ConvertJavaObjectToCredentialView(env, credential),
base::android::ConvertJavaStringToUTF8(new_password));
}
void PasswordCheckBridge::RemoveCredential(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& credential) {
......
......@@ -39,6 +39,13 @@ class PasswordCheckBridge : public PasswordCheckManager::Observer {
JNIEnv* env,
const base::android::JavaParamRef<jobjectArray>& credentials);
// Called by Java to update a single compromised credential in the password
// store.
void UpdateCredential(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& credential,
const base::android::JavaParamRef<jstring>& new_password);
// Called by Java to remove a single compromised credentials from the password
// store.
void RemoveCredential(
......
......@@ -5,6 +5,7 @@
#include "chrome/browser/password_check/android/password_check_manager.h"
#include "base/feature_list.h"
#include "base/strings/string_piece.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/password_check/android/password_check_bridge.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
......@@ -118,6 +119,13 @@ PasswordCheckManager::GetCompromisedCredentials() const {
return ui_credentials;
}
void PasswordCheckManager::UpdateCredential(
const password_manager::CredentialView& credential,
base::StringPiece new_password) {
compromised_credentials_manager_.UpdateCompromisedCredentials(credential,
new_password);
}
void PasswordCheckManager::RemoveCredential(
const password_manager::CredentialView& credential) {
compromised_credentials_manager_.RemoveCompromisedCredential(credential);
......
......@@ -6,6 +6,7 @@
#define CHROME_BROWSER_PASSWORD_CHECK_ANDROID_PASSWORD_CHECK_MANAGER_H_
#include "base/memory/scoped_refptr.h"
#include "base/strings/string_piece_forward.h"
#include "chrome/browser/password_check/android/password_check_ui_status.h"
#include "chrome/browser/password_manager/bulk_leak_check_service_factory.h"
#include "chrome/browser/password_manager/password_store_factory.h"
......@@ -70,7 +71,12 @@ class PasswordCheckManager
// Called by java to retrieve the compromised credentials.
std::vector<CompromisedCredentialForUI> GetCompromisedCredentials() const;
// Called by java to remove the given compromised |credential| and trigger a
// Called by java to update the given compromised `credential` and set its
// password to `new_password`.
void UpdateCredential(const password_manager::CredentialView& credential,
base::StringPiece new_password);
// Called by java to remove the given compromised `credential` and trigger a
// UI update on completion.
void RemoveCredential(const password_manager::CredentialView& credential);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment