Commit 192d8c7a authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Passwords] Expose PasswordFeatureManager to the UI

Bug: 1012203
Change-Id: Ia9c8c9c5ff3b1af120490b52ff153313863ebfd5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1944470Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720500}
parent a8389ce5
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "components/password_manager/core/browser/statistics_table.h" #include "components/password_manager/core/browser/statistics_table.h"
#include "components/password_manager/core/common/credential_manager_types.h" #include "components/password_manager/core/common/credential_manager_types.h"
#include "content/public/browser/navigation_handle.h" #include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#if defined(OS_WIN) #if defined(OS_WIN)
...@@ -59,7 +60,8 @@ password_manager::PasswordStore* GetPasswordStore( ...@@ -59,7 +60,8 @@ password_manager::PasswordStore* GetPasswordStore(
content::WebContents* web_contents) { content::WebContents* web_contents) {
return PasswordStoreFactory::GetForProfile( return PasswordStoreFactory::GetForProfile(
Profile::FromBrowserContext(web_contents->GetBrowserContext()), Profile::FromBrowserContext(web_contents->GetBrowserContext()),
ServiceAccessType::EXPLICIT_ACCESS).get(); ServiceAccessType::EXPLICIT_ACCESS)
.get();
} }
std::vector<std::unique_ptr<autofill::PasswordForm>> CopyFormVector( std::vector<std::unique_ptr<autofill::PasswordForm>> CopyFormVector(
...@@ -315,12 +317,19 @@ ManagePasswordsUIController::GetPasswordFormMetricsRecorder() { ...@@ -315,12 +317,19 @@ ManagePasswordsUIController::GetPasswordFormMetricsRecorder() {
return form_manager ? form_manager->GetMetricsRecorder() : nullptr; return form_manager ? form_manager->GetMetricsRecorder() : nullptr;
} }
password_manager::PasswordFeatureManager*
ManagePasswordsUIController::GetPasswordFeatureManager() {
password_manager::PasswordManagerClient* client =
ChromePasswordManagerClient::FromWebContents(web_contents());
return client->GetPasswordFeatureManager();
}
password_manager::ui::State ManagePasswordsUIController::GetState() const { password_manager::ui::State ManagePasswordsUIController::GetState() const {
return passwords_data_.state(); return passwords_data_.state();
} }
const autofill::PasswordForm& ManagePasswordsUIController:: const autofill::PasswordForm& ManagePasswordsUIController::GetPendingPassword()
GetPendingPassword() const { const {
if (GetState() == password_manager::ui::AUTO_SIGNIN_STATE) if (GetState() == password_manager::ui::AUTO_SIGNIN_STATE)
return *GetCurrentForms()[0]; return *GetCurrentForms()[0];
......
...@@ -30,8 +30,9 @@ class WebContents; ...@@ -30,8 +30,9 @@ class WebContents;
namespace password_manager { namespace password_manager {
enum class CredentialType; enum class CredentialType;
struct InteractionsStats; struct InteractionsStats;
class PasswordFeatureManager;
class PasswordFormManagerForUI; class PasswordFormManagerForUI;
} } // namespace password_manager
class AccountChooserPrompt; class AccountChooserPrompt;
struct AccountInfo; struct AccountInfo;
...@@ -110,6 +111,8 @@ class ManagePasswordsUIController ...@@ -110,6 +111,8 @@ class ManagePasswordsUIController
const GURL& GetOrigin() const override; const GURL& GetOrigin() const override;
password_manager::PasswordFormMetricsRecorder* password_manager::PasswordFormMetricsRecorder*
GetPasswordFormMetricsRecorder() override; GetPasswordFormMetricsRecorder() override;
password_manager::PasswordFeatureManager* GetPasswordFeatureManager()
override;
password_manager::ui::State GetState() const override; password_manager::ui::State GetState() const override;
const autofill::PasswordForm& GetPendingPassword() const override; const autofill::PasswordForm& GetPendingPassword() const override;
password_manager::metrics_util::CredentialSourceType GetCredentialSource() password_manager::metrics_util::CredentialSourceType GetCredentialSource()
...@@ -148,8 +151,7 @@ class ManagePasswordsUIController ...@@ -148,8 +151,7 @@ class ManagePasswordsUIController
#endif // defined(UNIT_TEST) #endif // defined(UNIT_TEST)
protected: protected:
explicit ManagePasswordsUIController( explicit ManagePasswordsUIController(content::WebContents* web_contents);
content::WebContents* web_contents);
// Hides the bubble if opened. Mocked in the tests. // Hides the bubble if opened. Mocked in the tests.
virtual void HidePasswordBubble(); virtual void HidePasswordBubble();
......
...@@ -21,6 +21,7 @@ class WebContents; ...@@ -21,6 +21,7 @@ class WebContents;
} }
namespace password_manager { namespace password_manager {
struct InteractionsStats; struct InteractionsStats;
class PasswordFeatureManager;
class PasswordFormMetricsRecorder; class PasswordFormMetricsRecorder;
namespace metrics_util { namespace metrics_util {
enum class CredentialSourceType; enum class CredentialSourceType;
...@@ -44,6 +45,9 @@ class PasswordsModelDelegate { ...@@ -44,6 +45,9 @@ class PasswordsModelDelegate {
virtual password_manager::PasswordFormMetricsRecorder* virtual password_manager::PasswordFormMetricsRecorder*
GetPasswordFormMetricsRecorder() = 0; GetPasswordFormMetricsRecorder() = 0;
virtual password_manager::PasswordFeatureManager*
GetPasswordFeatureManager() = 0;
// Returns the URL of the site the current forms are retrieved for. // Returns the URL of the site the current forms are retrieved for.
virtual const GURL& GetOrigin() const = 0; virtual const GURL& GetOrigin() const = 0;
...@@ -131,7 +135,7 @@ class PasswordsModelDelegate { ...@@ -131,7 +135,7 @@ class PasswordsModelDelegate {
virtual ~PasswordsModelDelegate() = default; virtual ~PasswordsModelDelegate() = default;
}; };
base::WeakPtr<PasswordsModelDelegate> base::WeakPtr<PasswordsModelDelegate> PasswordsModelDelegateFromWebContents(
PasswordsModelDelegateFromWebContents(content::WebContents* web_contents); content::WebContents* web_contents);
#endif // CHROME_BROWSER_UI_PASSWORDS_PASSWORDS_MODEL_DELEGATE_H_ #endif // CHROME_BROWSER_UI_PASSWORDS_PASSWORDS_MODEL_DELEGATE_H_
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
class PasswordsModelDelegateMock class PasswordsModelDelegateMock
: public PasswordsModelDelegate, : public PasswordsModelDelegate,
public base::SupportsWeakPtr<PasswordsModelDelegateMock>{ public base::SupportsWeakPtr<PasswordsModelDelegateMock> {
public: public:
PasswordsModelDelegateMock(); PasswordsModelDelegateMock();
~PasswordsModelDelegateMock() override; ~PasswordsModelDelegateMock() override;
...@@ -23,6 +23,8 @@ class PasswordsModelDelegateMock ...@@ -23,6 +23,8 @@ class PasswordsModelDelegateMock
MOCK_CONST_METHOD0(GetWebContents, content::WebContents*()); MOCK_CONST_METHOD0(GetWebContents, content::WebContents*());
MOCK_METHOD0(GetPasswordFormMetricsRecorder, MOCK_METHOD0(GetPasswordFormMetricsRecorder,
password_manager::PasswordFormMetricsRecorder*()); password_manager::PasswordFormMetricsRecorder*());
MOCK_METHOD0(GetPasswordFeatureManager,
password_manager::PasswordFeatureManager*());
MOCK_CONST_METHOD0(GetOrigin, const GURL&()); MOCK_CONST_METHOD0(GetOrigin, const GURL&());
MOCK_CONST_METHOD0(GetState, password_manager::ui::State()); MOCK_CONST_METHOD0(GetState, password_manager::ui::State());
MOCK_CONST_METHOD0(GetPendingPassword, const autofill::PasswordForm&()); MOCK_CONST_METHOD0(GetPendingPassword, const autofill::PasswordForm&());
...@@ -43,8 +45,9 @@ class PasswordsModelDelegateMock ...@@ -43,8 +45,9 @@ class PasswordsModelDelegateMock
MOCK_METHOD0(OnPasswordsRevealed, void()); MOCK_METHOD0(OnPasswordsRevealed, void());
MOCK_METHOD2(SavePassword, MOCK_METHOD2(SavePassword,
void(const base::string16&, const base::string16&)); void(const base::string16&, const base::string16&));
MOCK_METHOD2(ChooseCredential, void(const autofill::PasswordForm&, MOCK_METHOD2(ChooseCredential,
password_manager::CredentialType)); void(const autofill::PasswordForm&,
password_manager::CredentialType));
MOCK_METHOD1(NavigateToPasswordManagerAccountDashboard, MOCK_METHOD1(NavigateToPasswordManagerAccountDashboard,
void(password_manager::ManagePasswordsReferrer)); void(password_manager::ManagePasswordsReferrer));
MOCK_METHOD1(NavigateToPasswordManagerSettingsPage, MOCK_METHOD1(NavigateToPasswordManagerSettingsPage,
......
...@@ -76,6 +76,12 @@ PasswordManager* PasswordManagerClient::GetPasswordManager() { ...@@ -76,6 +76,12 @@ PasswordManager* PasswordManagerClient::GetPasswordManager() {
static_cast<const PasswordManagerClient*>(this)->GetPasswordManager()); static_cast<const PasswordManagerClient*>(this)->GetPasswordManager());
} }
PasswordFeatureManager* PasswordManagerClient::GetPasswordFeatureManager() {
return const_cast<PasswordFeatureManager*>(
static_cast<const PasswordManagerClient*>(this)
->GetPasswordFeatureManager());
}
HttpAuthManager* PasswordManagerClient::GetHttpAuthManager() { HttpAuthManager* PasswordManagerClient::GetHttpAuthManager() {
return nullptr; return nullptr;
} }
......
...@@ -250,6 +250,7 @@ class PasswordManagerClient { ...@@ -250,6 +250,7 @@ class PasswordManagerClient {
PasswordManager* GetPasswordManager(); PasswordManager* GetPasswordManager();
virtual const PasswordManager* GetPasswordManager() const; virtual const PasswordManager* GetPasswordManager() const;
PasswordFeatureManager* GetPasswordFeatureManager();
virtual const PasswordFeatureManager* GetPasswordFeatureManager() const = 0; virtual const PasswordFeatureManager* GetPasswordFeatureManager() const = 0;
// Returns the HttpAuthManager associated with this client. // Returns the HttpAuthManager associated with this client.
......
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