Commit 55fda024 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS][Password-Breach] Call the command to start

Bug: 1008862
Change-Id: Ibbf2b068977cbaf34481f11faac85c3af830bd84
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1836502
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703266}
parent 9db7b347
...@@ -217,9 +217,8 @@ class PasswordManagerClient { ...@@ -217,9 +217,8 @@ class PasswordManagerClient {
const PasswordFormManagerForUI* form_manager); const PasswordFormManagerForUI* form_manager);
// Informs the embedder that user credentials were leaked. // Informs the embedder that user credentials were leaked.
virtual void NotifyUserCredentialsWereLeaked( virtual void NotifyUserCredentialsWereLeaked(CredentialLeakType leak_type,
password_manager::CredentialLeakType leak_type, const GURL& origin);
const GURL& origin);
// Gets prefs associated with this embedder. // Gets prefs associated with this embedder.
virtual PrefService* GetPrefs() const = 0; virtual PrefService* GetPrefs() const = 0;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <memory> #include <memory>
#include "base/macros.h" #include "base/macros.h"
#include "components/password_manager/core/browser/leak_detection_dialog_utils.h"
#include "components/password_manager/core/browser/password_feature_manager_impl.h" #include "components/password_manager/core/browser/password_feature_manager_impl.h"
#import "components/password_manager/core/browser/password_manager_client.h" #import "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_manager_client_helper.h" #include "components/password_manager/core/browser/password_manager_client_helper.h"
...@@ -33,6 +34,8 @@ namespace web { ...@@ -33,6 +34,8 @@ namespace web {
class WebState; class WebState;
} }
using password_manager::CredentialLeakType;
@protocol PasswordManagerClientDelegate @protocol PasswordManagerClientDelegate
// Shows UI to prompt the user to save the password. // Shows UI to prompt the user to save the password.
...@@ -47,6 +50,10 @@ class WebState; ...@@ -47,6 +50,10 @@ class WebState;
- (void)showAutosigninNotification: - (void)showAutosigninNotification:
(std::unique_ptr<autofill::PasswordForm>)formSignedIn; (std::unique_ptr<autofill::PasswordForm>)formSignedIn;
// Shows Password Breach for |URL| and |leakType|.
- (void)showPasswordBreachForLeakType:(CredentialLeakType)leakType
URL:(const GURL&)URL;
@property(readonly, nonatomic) web::WebState* webState; @property(readonly, nonatomic) web::WebState* webState;
@property(readonly, nonatomic) ios::ChromeBrowserState* browserState; @property(readonly, nonatomic) ios::ChromeBrowserState* browserState;
...@@ -109,6 +116,9 @@ class IOSChromePasswordManagerClient ...@@ -109,6 +116,9 @@ class IOSChromePasswordManagerClient
void NotifySuccessfulLoginWithExistingPassword( void NotifySuccessfulLoginWithExistingPassword(
const autofill::PasswordForm& form) override; const autofill::PasswordForm& form) override;
void NotifyStorePasswordCalled() override; void NotifyStorePasswordCalled() override;
void NotifyUserCredentialsWereLeaked(
password_manager::CredentialLeakType leak_type,
const GURL& origin) override;
bool IsSavingAndFillingEnabled(const GURL& url) const override; bool IsSavingAndFillingEnabled(const GURL& url) const override;
bool IsFillingEnabled(const GURL& url) const override; bool IsFillingEnabled(const GURL& url) const override;
const GURL& GetLastCommittedEntryURL() const override; const GURL& GetLastCommittedEntryURL() const override;
......
...@@ -188,6 +188,12 @@ void IOSChromePasswordManagerClient::NotifyStorePasswordCalled() { ...@@ -188,6 +188,12 @@ void IOSChromePasswordManagerClient::NotifyStorePasswordCalled() {
helper_.NotifyStorePasswordCalled(); helper_.NotifyStorePasswordCalled();
} }
void IOSChromePasswordManagerClient::NotifyUserCredentialsWereLeaked(
password_manager::CredentialLeakType leak_type,
const GURL& origin) {
[delegate_ showPasswordBreachForLeakType:leak_type URL:origin];
}
bool IOSChromePasswordManagerClient::IsSavingAndFillingEnabled( bool IOSChromePasswordManagerClient::IsSavingAndFillingEnabled(
const GURL& url) const { const GURL& url) const {
return *saving_passwords_enabled_ && !IsIncognito() && return *saving_passwords_enabled_ && !IsIncognito() &&
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
@protocol ApplicationCommands; @protocol ApplicationCommands;
@class NotifyUserAutoSigninViewController; @class NotifyUserAutoSigninViewController;
@protocol PasswordBreachCommands;
@protocol PasswordFormFiller; @protocol PasswordFormFiller;
@protocol PasswordsUiDelegate; @protocol PasswordsUiDelegate;
@class UIViewController; @class UIViewController;
...@@ -63,7 +64,8 @@ class PasswordManagerClient; ...@@ -63,7 +64,8 @@ class PasswordManagerClient;
// The dispatcher used for the PasswordController. This property can return nil // The dispatcher used for the PasswordController. This property can return nil
// even after being set to a non-nil object. // even after being set to a non-nil object.
@property(nonatomic, weak) id<ApplicationCommands> dispatcher; @property(nonatomic, weak) id<ApplicationCommands, PasswordBreachCommands>
dispatcher;
// Delegate used by this PasswordController to show UI on BVC. // Delegate used by this PasswordController to show UI on BVC.
@property(weak, nonatomic) id<PasswordControllerDelegate> delegate; @property(weak, nonatomic) id<PasswordControllerDelegate> delegate;
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include "ios/chrome/browser/sync/profile_sync_service_factory.h" #include "ios/chrome/browser/sync/profile_sync_service_factory.h"
#import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h" #import "ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.h"
#import "ios/chrome/browser/ui/commands/application_commands.h" #import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/commands/password_breach_commands.h"
#import "ios/chrome/browser/ui/infobars/coordinators/infobar_password_coordinator.h" #import "ios/chrome/browser/ui/infobars/coordinators/infobar_password_coordinator.h"
#import "ios/chrome/browser/ui/infobars/infobar_feature.h" #import "ios/chrome/browser/ui/infobars/infobar_feature.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
...@@ -185,8 +186,7 @@ NSString* const kSuggestionSuffix = @" ••••••••"; ...@@ -185,8 +186,7 @@ NSString* const kSuggestionSuffix = @" ••••••••";
} }
- (instancetype)initWithWebState:(web::WebState*)webState { - (instancetype)initWithWebState:(web::WebState*)webState {
self = [self initWithWebState:webState self = [self initWithWebState:webState client:nullptr];
client:nullptr];
return self; return self;
} }
...@@ -555,6 +555,11 @@ NSString* const kSuggestionSuffix = @" ••••••••"; ...@@ -555,6 +555,11 @@ NSString* const kSuggestionSuffix = @" ••••••••";
})); }));
} }
- (void)showPasswordBreachForLeakType:(CredentialLeakType)leakType
URL:(const GURL&)URL {
[self.dispatcher showPasswordBreachForLeakType:leakType URL:URL];
}
#pragma mark - PasswordManagerDriverDelegate #pragma mark - PasswordManagerDriverDelegate
- (void)fillPasswordForm:(const autofill::PasswordFormFillData&)formData - (void)fillPasswordForm:(const autofill::PasswordFormFillData&)formData
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
@protocol ApplicationCommands; @protocol ApplicationCommands;
@protocol FormSuggestionProvider; @protocol FormSuggestionProvider;
@class PasswordController; @class PasswordController;
@protocol PasswordBreachCommands;
@protocol PasswordControllerDelegate; @protocol PasswordControllerDelegate;
@protocol PasswordFormFiller; @protocol PasswordFormFiller;
@protocol PasswordsUiDelegate; @protocol PasswordsUiDelegate;
...@@ -35,7 +36,8 @@ class PasswordTabHelper : public web::WebStateObserver, ...@@ -35,7 +36,8 @@ class PasswordTabHelper : public web::WebStateObserver,
void SetBaseViewController(UIViewController* baseViewController); void SetBaseViewController(UIViewController* baseViewController);
// Sets the PasswordController dispatcher. // Sets the PasswordController dispatcher.
void SetDispatcher(id<ApplicationCommands> dispatcher); void SetDispatcher(
id<ApplicationCommands, PasswordBreachCommands> dispatcher);
// Sets the PasswordController delegate. // Sets the PasswordController delegate.
void SetPasswordControllerDelegate(id<PasswordControllerDelegate> delegate); void SetPasswordControllerDelegate(id<PasswordControllerDelegate> delegate);
......
...@@ -28,7 +28,8 @@ void PasswordTabHelper::SetBaseViewController( ...@@ -28,7 +28,8 @@ void PasswordTabHelper::SetBaseViewController(
controller_.baseViewController = baseViewController; controller_.baseViewController = baseViewController;
} }
void PasswordTabHelper::SetDispatcher(id<ApplicationCommands> dispatcher) { void PasswordTabHelper::SetDispatcher(
id<ApplicationCommands, PasswordBreachCommands> dispatcher) {
controller_.dispatcher = dispatcher; controller_.dispatcher = dispatcher;
} }
......
...@@ -20,6 +20,7 @@ class Browser; ...@@ -20,6 +20,7 @@ class Browser;
@class BrowserViewControllerDependencyFactory; @class BrowserViewControllerDependencyFactory;
@class CommandDispatcher; @class CommandDispatcher;
@protocol OmniboxFocuser; @protocol OmniboxFocuser;
@protocol PasswordBreachCommands;
@protocol PopupMenuCommands; @protocol PopupMenuCommands;
@protocol FakeboxFocuser; @protocol FakeboxFocuser;
@protocol SnackbarCommands; @protocol SnackbarCommands;
...@@ -61,6 +62,7 @@ class ChromeBrowserState; ...@@ -61,6 +62,7 @@ class ChromeBrowserState;
@property(nonatomic, readonly) id<ApplicationCommands, @property(nonatomic, readonly) id<ApplicationCommands,
BrowserCommands, BrowserCommands,
OmniboxFocuser, OmniboxFocuser,
PasswordBreachCommands,
PopupMenuCommands, PopupMenuCommands,
FakeboxFocuser, FakeboxFocuser,
SnackbarCommands, SnackbarCommands,
......
...@@ -831,13 +831,14 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -831,13 +831,14 @@ NSString* const kBrowserViewControllerSnackbarCategory =
- (id<ApplicationCommands, - (id<ApplicationCommands,
BrowserCommands, BrowserCommands,
OmniboxFocuser, OmniboxFocuser,
PasswordBreachCommands,
PopupMenuCommands, PopupMenuCommands,
FakeboxFocuser, FakeboxFocuser,
SnackbarCommands, SnackbarCommands,
ToolbarCommands>)dispatcher { ToolbarCommands>)dispatcher {
return static_cast< return static_cast<id<ApplicationCommands, BrowserCommands, OmniboxFocuser,
id<ApplicationCommands, BrowserCommands, OmniboxFocuser, PasswordBreachCommands, PopupMenuCommands,
PopupMenuCommands, FakeboxFocuser, SnackbarCommands, ToolbarCommands>>( FakeboxFocuser, SnackbarCommands, ToolbarCommands>>(
self.commandDispatcher); self.commandDispatcher);
} }
......
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