Commit 294f3f72 authored by jdoerrie's avatar jdoerrie Committed by Commit Bot

[Passwords] Conditionally Manage Passwords in P.G.C.

This change modifies previous browser links to the passwords settings
page to link to passwords.google.com instead, in case the the user
is syncing passwords with normal encryption and the corresponding
feature flag is set.

Bug: 904821
Change-Id: Id3c8591921f1277d098bb7d8677dabc57af28547
Reviewed-on: https://chromium-review.googlesource.com/c/1341509Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609674}
parent e8f16a5e
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/page_info/page_info_dialog.h" #include "chrome/browser/ui/page_info/page_info_dialog.h"
#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h" #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "chrome/browser/vr/vr_tab_helper.h" #include "chrome/browser/vr/vr_tab_helper.h"
#include "chrome/browser/web_data_service_factory.h" #include "chrome/browser/web_data_service_factory.h"
...@@ -526,9 +527,8 @@ bool ChromeAutofillClient::ShouldShowSigninPromo() { ...@@ -526,9 +527,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 (id == autofill::POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY) {
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
chrome::ShowSettingsSubPage( NavigateToManagePasswordsPage(
chrome::FindBrowserWithWebContents(web_contents()), chrome::FindBrowserWithWebContents(web_contents()));
chrome::kPasswordManagerSubPage);
#else #else
chrome::android::PreferencesLauncher::ShowPasswordSettings(web_contents()); chrome::android::PreferencesLauncher::ShowPasswordSettings(web_contents());
#endif #endif
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/location_bar/location_bar.h" #include "chrome/browser/ui/location_bar/location_bar.h"
#include "chrome/browser/ui/passwords/manage_passwords_icon_view.h" #include "chrome/browser/ui/passwords/manage_passwords_icon_view.h"
#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
#include "chrome/browser/ui/passwords/password_dialog_controller_impl.h" #include "chrome/browser/ui/passwords/password_dialog_controller_impl.h"
#include "chrome/browser/ui/passwords/password_dialog_prompts.h" #include "chrome/browser/ui/passwords/password_dialog_prompts.h"
#include "chrome/browser/ui/tab_dialogs.h" #include "chrome/browser/ui/tab_dialogs.h"
...@@ -450,17 +451,13 @@ void ManagePasswordsUIController::ChooseCredential( ...@@ -450,17 +451,13 @@ void ManagePasswordsUIController::ChooseCredential(
} }
void ManagePasswordsUIController::NavigateToPasswordManagerSettingsPage() { void ManagePasswordsUIController::NavigateToPasswordManagerSettingsPage() {
chrome::ShowSettingsSubPage( NavigateToManagePasswordsPage(
chrome::FindBrowserWithWebContents(web_contents()), chrome::FindBrowserWithWebContents(web_contents()));
chrome::kPasswordManagerSubPage);
} }
void ManagePasswordsUIController::NavigateToPasswordManagerAccountDashboard() { void ManagePasswordsUIController::NavigateToPasswordManagerAccountDashboard() {
GURL dashboard_link(l10n_util::GetStringUTF16(IDS_PASSWORDS_WEB_LINK)); NavigateToGooglePasswordManager(
NavigateParams params(chrome::FindBrowserWithWebContents(web_contents()), Profile::FromBrowserContext(web_contents()->GetBrowserContext()));
dashboard_link, ui::PAGE_TRANSITION_LINK);
params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
Navigate(&params);
} }
void ManagePasswordsUIController::EnableSync(const AccountInfo& account, void ManagePasswordsUIController::EnableSync(const AccountInfo& account,
......
...@@ -8,18 +8,30 @@ ...@@ -8,18 +8,30 @@
#include <algorithm> #include <algorithm>
#include "base/feature_list.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service_factory.h" #include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/chromium_strings.h" #include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/autofill/core/common/password_form.h" #include "components/autofill/core/common/password_form.h"
#include "components/browser_sync/profile_sync_service.h" #include "components/browser_sync/profile_sync_service.h"
#include "components/password_manager/core/browser/android_affiliation/affiliation_utils.h" #include "components/password_manager/core/browser/android_affiliation/affiliation_utils.h"
#include "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_manager_util.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "components/url_formatter/elide_url.h" #include "components/url_formatter/elide_url.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h" #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/page_transition_types.h"
#include "ui/base/window_open_disposition.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
...@@ -142,3 +154,26 @@ bool IsSyncingAutosignSetting(Profile* profile) { ...@@ -142,3 +154,26 @@ bool IsSyncingAutosignSetting(Profile* profile) {
sync_service->IsSyncFeatureActive() && sync_service->IsSyncFeatureActive() &&
sync_service->GetActiveDataTypes().Has(syncer::PRIORITY_PREFERENCES)); sync_service->GetActiveDataTypes().Has(syncer::PRIORITY_PREFERENCES));
} }
// Navigation is handled differently on Android.
#if !defined(OS_ANDROID)
void NavigateToGooglePasswordManager(Profile* profile) {
NavigateParams params(profile,
GURL(l10n_util::GetStringUTF16(IDS_PASSWORDS_WEB_LINK)),
ui::PAGE_TRANSITION_LINK);
params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB;
Navigate(&params);
}
void NavigateToManagePasswordsPage(Browser* browser) {
if (base::FeatureList::IsEnabled(
password_manager::features::kGooglePasswordManager) &&
password_manager_util::GetPasswordSyncState(
ProfileSyncServiceFactory::GetForProfile(browser->profile())) ==
password_manager::SYNCING_NORMAL_ENCRYPTION) {
NavigateToGooglePasswordManager(browser->profile());
} else {
chrome::ShowPasswordManager(browser);
}
}
#endif // !defined(OS_ANDROID)
...@@ -23,6 +23,7 @@ enum class PasswordTitleType { ...@@ -23,6 +23,7 @@ enum class PasswordTitleType {
UPDATE_PASSWORD, // update plain password UPDATE_PASSWORD, // update plain password
}; };
class Browser;
class Profile; class Profile;
// The desired width and height in pixels for an account avatar. // The desired width and height in pixels for an account avatar.
...@@ -72,4 +73,12 @@ base::string16 GetDisplayUsername(const autofill::PasswordForm& form); ...@@ -72,4 +73,12 @@ base::string16 GetDisplayUsername(const autofill::PasswordForm& form);
// syncs the PRIORITY_PREFERENCE). The view appearance might depend on it. // syncs the PRIORITY_PREFERENCE). The view appearance might depend on it.
bool IsSyncingAutosignSetting(Profile* profile); bool IsSyncingAutosignSetting(Profile* profile);
// Navigates to the Google Password Manager, i.e. passwords.google.com.
void NavigateToGooglePasswordManager(Profile* profile);
// Navigates to either the Google Password Manager or the Chrome Password
// Settings page, depending on the user's password syncing state and whether the
// corresponding feature flag is enabled.
void NavigateToManagePasswordsPage(Browser* browser);
#endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_VIEW_UTILS_H_ #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_VIEW_UTILS_H_
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
#include "chrome/browser/ui/profile_chooser_constants.h" #include "chrome/browser/ui/profile_chooser_constants.h"
#include "chrome/browser/ui/singleton_tabs.h" #include "chrome/browser/ui/singleton_tabs.h"
#include "chrome/browser/ui/sync/sync_promo_ui.h" #include "chrome/browser/ui/sync/sync_promo_ui.h"
...@@ -59,7 +60,6 @@ ...@@ -59,7 +60,6 @@
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h" #include "chrome/grit/theme_resources.h"
#include "components/browser_sync/profile_sync_service.h" #include "components/browser_sync/profile_sync_service.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/core/browser/account_tracker_service.h" #include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/gaia_cookie_manager_service.h" #include "components/signin/core/browser/gaia_cookie_manager_service.h"
...@@ -624,7 +624,7 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, ...@@ -624,7 +624,7 @@ void ProfileChooserView::ButtonPressed(views::Button* sender,
if (sender == passwords_button_) { if (sender == passwords_button_) {
base::RecordAction( base::RecordAction(
base::UserMetricsAction("ProfileChooser_PasswordsClicked")); base::UserMetricsAction("ProfileChooser_PasswordsClicked"));
chrome::ShowSettingsSubPage(browser_, chrome::kPasswordManagerSubPage); NavigateToManagePasswordsPage(browser_);
} else if (sender == credit_cards_button_) { } else if (sender == credit_cards_button_) {
base::RecordAction( base::RecordAction(
base::UserMetricsAction("ProfileChooser_PaymentsClicked")); base::UserMetricsAction("ProfileChooser_PaymentsClicked"));
......
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