Commit 476edd35 authored by jdoerrie's avatar jdoerrie Committed by Commit Bot

[Passwords] Add PasswordManagerClient::NavigateToManagePasswordsPage()

As a follow up to r609674 this change adds NavigateToManagePasswordsPage
to PasswordManagerClient in order to remove the dependency on
ChromeAutofillClient. In addition, this change inlines
password_manager_util::UserTriggeredShowAllSavedPasswordsFromContextMenu

Bug: 904821
Change-Id: Ib66e5c20e8babcf84de3e07a0c031cf9e700e43d
Reviewed-on: https://chromium-review.googlesource.com/c/1344031
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609972}
parent f0c7b702
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
#include "chrome/browser/ui/passwords/password_generation_popup_controller_impl.h" #include "chrome/browser/ui/passwords/password_generation_popup_controller_impl.h"
#include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h" #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h"
#include "chrome/browser/vr/vr_tab_helper.h" #include "chrome/browser/vr/vr_tab_helper.h"
...@@ -87,6 +89,7 @@ ...@@ -87,6 +89,7 @@
#endif #endif
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "chrome/browser/android/preferences/preferences_launcher.h"
#include "chrome/browser/android/tab_android.h" #include "chrome/browser/android/tab_android.h"
#include "chrome/browser/password_manager/account_chooser_dialog_android.h" #include "chrome/browser/password_manager/account_chooser_dialog_android.h"
#include "chrome/browser/password_manager/auto_signin_first_run_dialog_android.h" #include "chrome/browser/password_manager/auto_signin_first_run_dialog_android.h"
...@@ -874,10 +877,6 @@ favicon::FaviconService* ChromePasswordManagerClient::GetFaviconService() { ...@@ -874,10 +877,6 @@ favicon::FaviconService* ChromePasswordManagerClient::GetFaviconService() {
profile_, ServiceAccessType::EXPLICIT_ACCESS); profile_, ServiceAccessType::EXPLICIT_ACCESS);
} }
void ChromePasswordManagerClient::UpdateFormManagers() {
password_manager_.UpdateFormManagers();
}
bool ChromePasswordManagerClient::IsUnderAdvancedProtection() const { bool ChromePasswordManagerClient::IsUnderAdvancedProtection() const {
#if defined(FULL_SAFE_BROWSING) #if defined(FULL_SAFE_BROWSING)
return safe_browsing::AdvancedProtectionStatusManager:: return safe_browsing::AdvancedProtectionStatusManager::
...@@ -887,6 +886,19 @@ bool ChromePasswordManagerClient::IsUnderAdvancedProtection() const { ...@@ -887,6 +886,19 @@ bool ChromePasswordManagerClient::IsUnderAdvancedProtection() const {
#endif #endif
} }
void ChromePasswordManagerClient::UpdateFormManagers() {
password_manager_.UpdateFormManagers();
}
void ChromePasswordManagerClient::NavigateToManagePasswordsPage() {
#if defined(OS_ANDROID)
chrome::android::PreferencesLauncher::ShowPasswordSettings(web_contents());
#else
::NavigateToManagePasswordsPage(
chrome::FindBrowserWithWebContents(web_contents()));
#endif
}
void ChromePasswordManagerClient::PasswordFormsParsed( void ChromePasswordManagerClient::PasswordFormsParsed(
const std::vector<autofill::PasswordForm>& forms) { const std::vector<autofill::PasswordForm>& forms) {
if (!password_manager::bad_message::CheckChildProcessSecurityPolicy( if (!password_manager::bad_message::CheckChildProcessSecurityPolicy(
......
...@@ -110,8 +110,9 @@ class ChromePasswordManagerClient ...@@ -110,8 +110,9 @@ class ChromePasswordManagerClient
password_manager::PasswordRequirementsService* password_manager::PasswordRequirementsService*
GetPasswordRequirementsService() override; GetPasswordRequirementsService() override;
favicon::FaviconService* GetFaviconService() override; favicon::FaviconService* GetFaviconService() override;
void UpdateFormManagers() override;
bool IsUnderAdvancedProtection() const override; bool IsUnderAdvancedProtection() const override;
void UpdateFormManagers() override;
void NavigateToManagePasswordsPage() override;
// autofill::mojom::PasswordManagerClient overrides. // autofill::mojom::PasswordManagerClient overrides.
void AutomaticGenerationStatusChanged( void AutomaticGenerationStatusChanged(
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include "chrome/browser/ui/browser_navigator_params.h" #include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/exclusive_access/keyboard_lock_controller.h" #include "chrome/browser/ui/exclusive_access/keyboard_lock_controller.h"
#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
#include "chrome/browser/ui/tab_contents/core_tab_helper.h" #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/web_applications/components/web_app_helpers.h" #include "chrome/browser/web_applications/components/web_app_helpers.h"
...@@ -85,6 +86,7 @@ ...@@ -85,6 +86,7 @@
#include "components/omnibox/browser/autocomplete_classifier.h" #include "components/omnibox/browser/autocomplete_classifier.h"
#include "components/omnibox/browser/autocomplete_match.h" #include "components/omnibox/browser/autocomplete_match.h"
#include "components/password_manager/content/browser/content_password_manager_driver.h" #include "components/password_manager/content/browser/content_password_manager_driver.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/password_manager/core/browser/password_manager_util.h" #include "components/password_manager/core/browser/password_manager_util.h"
#include "components/prefs/pref_member.h" #include "components/prefs/pref_member.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -2098,9 +2100,10 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) { ...@@ -2098,9 +2100,10 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
break; break;
case IDC_CONTENT_CONTEXT_SHOWALLSAVEDPASSWORDS: case IDC_CONTENT_CONTEXT_SHOWALLSAVEDPASSWORDS:
password_manager_util::UserTriggeredShowAllSavedPasswordsFromContextMenu( NavigateToManagePasswordsPage(GetBrowser());
autofill::ChromeAutofillClient::FromWebContents( password_manager::metrics_util::LogContextOfShowAllSavedPasswordsAccepted(
source_web_contents_)); password_manager::metrics_util::
SHOW_ALL_SAVED_PASSWORDS_CONTEXT_CONTEXT_MENU);
break; break;
case IDC_CONTENT_CONTEXT_PICTUREINPICTURE: case IDC_CONTENT_CONTEXT_PICTUREINPICTURE:
......
...@@ -525,15 +525,8 @@ bool ChromeAutofillClient::ShouldShowSigninPromo() { ...@@ -525,15 +525,8 @@ bool ChromeAutofillClient::ShouldShowSigninPromo() {
} }
void ChromeAutofillClient::ExecuteCommand(int id) { void ChromeAutofillClient::ExecuteCommand(int id) {
if (id == autofill::POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY) {
#if !defined(OS_ANDROID)
NavigateToManagePasswordsPage(
chrome::FindBrowserWithWebContents(web_contents()));
#else
chrome::android::PreferencesLauncher::ShowPasswordSettings(web_contents());
#endif
} else if (id == autofill::POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO) {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
if (id == autofill::POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO) {
auto* window = web_contents()->GetNativeView()->GetWindowAndroid(); auto* window = web_contents()->GetNativeView()->GetWindowAndroid();
if (window) { if (window) {
chrome::android::SigninPromoUtilAndroid:: chrome::android::SigninPromoUtilAndroid::
...@@ -541,8 +534,8 @@ void ChromeAutofillClient::ExecuteCommand(int id) { ...@@ -541,8 +534,8 @@ void ChromeAutofillClient::ExecuteCommand(int id) {
window, window,
signin_metrics::AccessPoint::ACCESS_POINT_AUTOFILL_DROPDOWN); signin_metrics::AccessPoint::ACCESS_POINT_AUTOFILL_DROPDOWN);
} }
#endif
} }
#endif
} }
Profile* ChromeAutofillClient::GetProfile() const { Profile* ChromeAutofillClient::GetProfile() const {
......
...@@ -200,12 +200,12 @@ void PasswordAutofillManager::DidAcceptSuggestion(const base::string16& value, ...@@ -200,12 +200,12 @@ void PasswordAutofillManager::DidAcceptSuggestion(const base::string16& value,
int position) { int position) {
using metrics_util::PasswordDropdownSelectedOption; using metrics_util::PasswordDropdownSelectedOption;
autofill_client_->ExecuteCommand(identifier);
if (identifier == autofill::POPUP_ITEM_ID_GENERATE_PASSWORD_ENTRY) { if (identifier == autofill::POPUP_ITEM_ID_GENERATE_PASSWORD_ENTRY) {
password_client_->GeneratePassword(); password_client_->GeneratePassword();
metrics_util::LogPasswordDropdownItemSelected( metrics_util::LogPasswordDropdownItemSelected(
PasswordDropdownSelectedOption::kGenerate); PasswordDropdownSelectedOption::kGenerate);
} else if (identifier == autofill::POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY) { } else if (identifier == autofill::POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY) {
password_client_->NavigateToManagePasswordsPage();
metrics_util::LogContextOfShowAllSavedPasswordsAccepted( metrics_util::LogContextOfShowAllSavedPasswordsAccepted(
metrics_util::SHOW_ALL_SAVED_PASSWORDS_CONTEXT_PASSWORD); metrics_util::SHOW_ALL_SAVED_PASSWORDS_CONTEXT_PASSWORD);
metrics_util::LogPasswordDropdownItemSelected( metrics_util::LogPasswordDropdownItemSelected(
......
...@@ -94,6 +94,7 @@ class TestPasswordManagerClient : public StubPasswordManagerClient { ...@@ -94,6 +94,7 @@ class TestPasswordManagerClient : public StubPasswordManagerClient {
MOCK_METHOD0(GeneratePassword, void()); MOCK_METHOD0(GeneratePassword, void());
MOCK_METHOD0(GetFaviconService, favicon::FaviconService*()); MOCK_METHOD0(GetFaviconService, favicon::FaviconService*());
MOCK_METHOD0(NavigateToManagePasswordsPage, void());
private: private:
MockPasswordManagerDriver driver_; MockPasswordManagerDriver driver_;
...@@ -652,9 +653,7 @@ TEST_F(PasswordAutofillManagerTest, ShowAllPasswordsOptionOnPasswordField) { ...@@ -652,9 +653,7 @@ TEST_F(PasswordAutofillManagerTest, ShowAllPasswordsOptionOnPasswordField) {
metrics_util::SHOW_ALL_SAVED_PASSWORDS_CONTEXT_PASSWORD, 1); metrics_util::SHOW_ALL_SAVED_PASSWORDS_CONTEXT_PASSWORD, 1);
// Clicking at the "Show all passwords row" should trigger a call to open // Clicking at the "Show all passwords row" should trigger a call to open
// the Password Manager settings page and hide the popup. // the Password Manager settings page and hide the popup.
EXPECT_CALL( EXPECT_CALL(*client, NavigateToManagePasswordsPage);
*autofill_client,
ExecuteCommand(autofill::POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY));
EXPECT_CALL(*autofill_client, HideAutofillPopup()); EXPECT_CALL(*autofill_client, HideAutofillPopup());
password_autofill_manager_->DidAcceptSuggestion( password_autofill_manager_->DidAcceptSuggestion(
base::string16(), autofill::POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY, 0); base::string16(), autofill::POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY, 0);
......
...@@ -268,6 +268,9 @@ class PasswordManagerClient { ...@@ -268,6 +268,9 @@ class PasswordManagerClient {
// again. Results in updating the fill information on the page. // again. Results in updating the fill information on the page.
virtual void UpdateFormManagers() {} virtual void UpdateFormManagers() {}
// Causes a navigation to the manage passwords page.
virtual void NavigateToManagePasswordsPage() {}
private: private:
DISALLOW_COPY_AND_ASSIGN(PasswordManagerClient); DISALLOW_COPY_AND_ASSIGN(PasswordManagerClient);
}; };
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/autofill/core/browser/autofill_client.h"
#include "components/autofill/core/browser/popup_item_ids.h" #include "components/autofill/core/browser/popup_item_ids.h"
#include "components/autofill/core/common/password_form.h" #include "components/autofill/core/common/password_form.h"
#include "components/autofill/core/common/password_generation_util.h" #include "components/autofill/core/common/password_generation_util.h"
...@@ -156,17 +155,6 @@ bool ShowAllSavedPasswordsContextMenuEnabled( ...@@ -156,17 +155,6 @@ bool ShowAllSavedPasswordsContextMenuEnabled(
return true; return true;
} }
void UserTriggeredShowAllSavedPasswordsFromContextMenu(
autofill::AutofillClient* autofill_client) {
if (!autofill_client)
return;
autofill_client->ExecuteCommand(
autofill::POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY);
password_manager::metrics_util::LogContextOfShowAllSavedPasswordsAccepted(
password_manager::metrics_util::
SHOW_ALL_SAVED_PASSWORDS_CONTEXT_CONTEXT_MENU);
}
void UserTriggeredManualGenerationFromContextMenu( void UserTriggeredManualGenerationFromContextMenu(
password_manager::PasswordManagerClient* password_manager_client) { password_manager::PasswordManagerClient* password_manager_client) {
password_manager_client->GeneratePassword(); password_manager_client->GeneratePassword();
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
namespace autofill { namespace autofill {
struct PasswordForm; struct PasswordForm;
class AutofillClient;
} }
namespace network { namespace network {
...@@ -79,10 +78,6 @@ bool ManualPasswordGenerationEnabled( ...@@ -79,10 +78,6 @@ bool ManualPasswordGenerationEnabled(
bool ShowAllSavedPasswordsContextMenuEnabled( bool ShowAllSavedPasswordsContextMenuEnabled(
password_manager::PasswordManagerDriver* driver); password_manager::PasswordManagerDriver* driver);
// Opens Password Manager setting page and records the metrics.
void UserTriggeredShowAllSavedPasswordsFromContextMenu(
autofill::AutofillClient* autofill_client);
// Triggers password generation flow and records the metrics. // Triggers password generation flow and records the metrics.
void UserTriggeredManualGenerationFromContextMenu( void UserTriggeredManualGenerationFromContextMenu(
password_manager::PasswordManagerClient* password_manager_client); password_manager::PasswordManagerClient* password_manager_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