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 { ...@@ -137,6 +137,11 @@ class PasswordCheckBridge {
mNativePasswordCheckBridge, credentials); mNativePasswordCheckBridge, credentials);
} }
void updateCredential(CompromisedCredential credential, String newPassword) {
PasswordCheckBridgeJni.get().updateCredential(
mNativePasswordCheckBridge, credential, newPassword);
}
void removeCredential(CompromisedCredential credential) { void removeCredential(CompromisedCredential credential) {
PasswordCheckBridgeJni.get().removeCredential(mNativePasswordCheckBridge, credential); PasswordCheckBridgeJni.get().removeCredential(mNativePasswordCheckBridge, credential);
} }
...@@ -163,6 +168,8 @@ class PasswordCheckBridge { ...@@ -163,6 +168,8 @@ class PasswordCheckBridge {
int getSavedPasswordsCount(long nativePasswordCheckBridge); int getSavedPasswordsCount(long nativePasswordCheckBridge);
void getCompromisedCredentials( void getCompromisedCredentials(
long nativePasswordCheckBridge, CompromisedCredential[] credentials); long nativePasswordCheckBridge, CompromisedCredential[] credentials);
void updateCredential(long nativePasswordCheckBridge, CompromisedCredential credential,
String newPassword);
void removeCredential(long nativePasswordCheckBridge, CompromisedCredential credentials); void removeCredential(long nativePasswordCheckBridge, CompromisedCredential credentials);
void destroy(long nativePasswordCheckBridge); void destroy(long nativePasswordCheckBridge);
} }
......
...@@ -73,6 +73,11 @@ class PasswordCheckImpl implements PasswordCheck, PasswordCheckObserver { ...@@ -73,6 +73,11 @@ class PasswordCheckImpl implements PasswordCheck, PasswordCheckObserver {
} }
} }
@Override
public void updateCredential(CompromisedCredential credential, String newPassword) {
mPasswordCheckBridge.updateCredential(credential, newPassword);
}
@Override @Override
public void removeCredential(CompromisedCredential credential) { public void removeCredential(CompromisedCredential credential) {
mPasswordCheckBridge.removeCredential(credential); mPasswordCheckBridge.removeCredential(credential);
......
...@@ -91,6 +91,13 @@ public interface PasswordCheck extends PasswordCheckComponentUi.Delegate { ...@@ -91,6 +91,13 @@ public interface PasswordCheck extends PasswordCheckComponentUi.Delegate {
*/ */
CompromisedCredential[] getCompromisedCredentials(); 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 * @return The latest available number of all saved passwords. If this is invoked before
* {@link Observer#onSavedPasswordsFetchCompleted}, the returned value is likely invalid. * {@link Observer#onSavedPasswordsFetchCompleted}, the returned value is likely invalid.
......
...@@ -85,6 +85,15 @@ void PasswordCheckBridge::GetCompromisedCredentials( ...@@ -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( void PasswordCheckBridge::RemoveCredential(
JNIEnv* env, JNIEnv* env,
const base::android::JavaParamRef<jobject>& credential) { const base::android::JavaParamRef<jobject>& credential) {
......
...@@ -39,6 +39,13 @@ class PasswordCheckBridge : public PasswordCheckManager::Observer { ...@@ -39,6 +39,13 @@ class PasswordCheckBridge : public PasswordCheckManager::Observer {
JNIEnv* env, JNIEnv* env,
const base::android::JavaParamRef<jobjectArray>& credentials); 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 // Called by Java to remove a single compromised credentials from the password
// store. // store.
void RemoveCredential( void RemoveCredential(
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chrome/browser/password_check/android/password_check_manager.h" #include "chrome/browser/password_check/android/password_check_manager.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/strings/string_piece.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/password_check/android/password_check_bridge.h" #include "chrome/browser/password_check/android/password_check_bridge.h"
#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h"
...@@ -118,6 +119,13 @@ PasswordCheckManager::GetCompromisedCredentials() const { ...@@ -118,6 +119,13 @@ PasswordCheckManager::GetCompromisedCredentials() const {
return ui_credentials; 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( void PasswordCheckManager::RemoveCredential(
const password_manager::CredentialView& credential) { const password_manager::CredentialView& credential) {
compromised_credentials_manager_.RemoveCompromisedCredential(credential); compromised_credentials_manager_.RemoveCompromisedCredential(credential);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define CHROME_BROWSER_PASSWORD_CHECK_ANDROID_PASSWORD_CHECK_MANAGER_H_ #define CHROME_BROWSER_PASSWORD_CHECK_ANDROID_PASSWORD_CHECK_MANAGER_H_
#include "base/memory/scoped_refptr.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_check/android/password_check_ui_status.h"
#include "chrome/browser/password_manager/bulk_leak_check_service_factory.h" #include "chrome/browser/password_manager/bulk_leak_check_service_factory.h"
#include "chrome/browser/password_manager/password_store_factory.h" #include "chrome/browser/password_manager/password_store_factory.h"
...@@ -70,7 +71,12 @@ class PasswordCheckManager ...@@ -70,7 +71,12 @@ class PasswordCheckManager
// Called by java to retrieve the compromised credentials. // Called by java to retrieve the compromised credentials.
std::vector<CompromisedCredentialForUI> GetCompromisedCredentials() const; 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. // UI update on completion.
void RemoveCredential(const password_manager::CredentialView& credential); 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