Commit ce8fa29b authored by Vasilii Sukhanov's avatar Vasilii Sukhanov Committed by Commit Bot

Add autofill home entries to the profile menu.

The profile avatar opens the Chrome profile menu. This change adds 3 new menu items there.
- Passwords -> chrome://settings/passwords
- Payment methods -> chrome://settings/autofill
- Addresses -> chrome://settings/autofill
It's expected for M69 that Payment methods and Addresses link to the same page.
The icon for addresses is just temporary.

Bug: 854562
Change-Id: I7f5b62914e49b8e3ae9d882a7d6eaaf05a532100
Reviewed-on: https://chromium-review.googlesource.com/1108097
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569231}
parent 8f183622
......@@ -6923,7 +6923,7 @@ I don't think this site should be blocked!
Passwords
</message>
<message name="IDS_PROFILES_CREDIT_CARDS_LINK" desc="Text of the menu item leading to the list of saved credit cards.">
Credit cards
Payment methods
</message>
<message name="IDS_PROFILES_ADDRESSES_LINK" desc="Text of the menu item leading to the list of autofill addresses.">
Addresses
......
......@@ -57,6 +57,7 @@
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.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/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/gaia_cookie_manager_service.h"
......@@ -110,6 +111,7 @@ constexpr int kButtonHeight = 32;
constexpr int kFixedAccountRemovalViewWidth = 280;
constexpr int kFixedMenuWidthPreDice = 240;
constexpr int kFixedMenuWidthDice = 288;
constexpr int kIconSize = 20;
// Spacing between the edge of the material design user menu and the
// top/bottom or left/right of the menu items.
......@@ -402,6 +404,9 @@ void ProfileChooserView::ResetView() {
account_removal_cancel_button_ = nullptr;
sync_to_another_account_button_ = nullptr;
dice_signin_button_view_ = nullptr;
passwords_button_ = nullptr;
credit_cards_button_ = nullptr;
addresses_button_ = nullptr;
}
void ProfileChooserView::Init() {
......@@ -596,7 +601,13 @@ bool ProfileChooserView::HandleContextMenu(
void ProfileChooserView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (sender == guest_profile_button_) {
if (sender == passwords_button_) {
chrome::ShowSettingsSubPage(browser_, chrome::kPasswordManagerSubPage);
} else if (sender == credit_cards_button_) {
chrome::ShowSettingsSubPage(browser_, chrome::kAutofillSubPage);
} else if (sender == addresses_button_) {
chrome::ShowSettingsSubPage(browser_, chrome::kAutofillSubPage);
} else if (sender == guest_profile_button_) {
PrefService* service = g_browser_process->local_state();
DCHECK(service);
DCHECK(service->GetBoolean(prefs::kBrowserGuestModeEnabled));
......@@ -780,10 +791,12 @@ views::View* ProfileChooserView::CreateProfileChooserView(
views::GridLayout* layout = CreateSingleColumnLayout(view, menu_width_);
// Separate items into active and alternatives.
Indexes other_profiles;
views::View* sync_error_view = NULL;
views::View* current_profile_view = NULL;
views::View* current_profile_accounts = NULL;
views::View* option_buttons_view = NULL;
views::View* sync_error_view = nullptr;
views::View* current_profile_view = nullptr;
views::View* current_profile_accounts = nullptr;
views::View* option_buttons_view = nullptr;
views::View* autofill_home_view = nullptr;
bool current_profile_signed_in = false;
for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) {
const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
if (item.active) {
......@@ -791,6 +804,8 @@ views::View* ProfileChooserView::CreateProfileChooserView(
item.signed_in && profiles::IsLockAvailable(browser_->profile()),
avatar_menu);
current_profile_view = CreateCurrentProfileView(item, false);
autofill_home_view = CreateAutofillHomeView();
current_profile_signed_in = item.signed_in;
if (!IsProfileChooser(view_mode_))
current_profile_accounts = CreateCurrentProfileAccountsView(item);
sync_error_view = CreateSyncErrorViewIfNeeded(item);
......@@ -830,6 +845,17 @@ views::View* ProfileChooserView::CreateProfileChooserView(
layout->AddView(CreateSupervisedUserDisclaimerView());
}
if (autofill_home_view) {
if (!current_profile_signed_in) {
// If the user is signed in then the autofill data is a part of the
// account logically. Otherwise, use a separator.
layout->StartRow(0, 0);
layout->AddView(new views::Separator());
}
layout->StartRow(0, 0);
layout->AddView(autofill_home_view);
}
layout->StartRow(0, 0);
layout->AddView(new views::Separator());
......@@ -869,7 +895,7 @@ views::View* ProfileChooserView::CreateSyncErrorViewIfNeeded(
// Adds the sync problem icon.
views::ImageView* sync_problem_icon = new views::ImageView();
sync_problem_icon->SetImage(
gfx::CreateVectorIcon(kSyncProblemIcon, 20, gfx::kGoogleRed700));
gfx::CreateVectorIcon(kSyncProblemIcon, kIconSize, gfx::kGoogleRed700));
view->AddChildView(sync_problem_icon);
// Adds a vertical view to organize the error title, message, and button.
......@@ -1217,7 +1243,6 @@ views::View* ProfileChooserView::CreateOptionsView(bool display_lock,
views::GridLayout* layout = CreateSingleColumnLayout(view, menu_width_);
const bool is_guest = browser_->profile()->IsGuestSession();
const int kIconSize = 20;
// Add the user switching buttons.
// Order them such that the active user profile comes first (for Dice).
layout->StartRowWithPadding(1, 0, 0, content_list_vert_spacing);
......@@ -1318,6 +1343,40 @@ views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() {
return view;
}
views::View* ProfileChooserView::CreateAutofillHomeView() {
if (!base::FeatureList::IsEnabled(
password_manager::features::kAutofillHome) ||
browser_->profile()->IsGuestSession()) {
return nullptr;
}
views::View* view = new views::View();
view->SetLayoutManager(
std::make_unique<views::BoxLayout>(views::BoxLayout::kVertical));
// Passwords.
passwords_button_ = new HoverButton(
this, gfx::CreateVectorIcon(kKeyIcon, kIconSize, gfx::kChromeIconGrey),
l10n_util::GetStringUTF16(IDS_PROFILES_PASSWORDS_LINK));
view->AddChildView(passwords_button_);
// Credit cards.
credit_cards_button_ = new HoverButton(
this,
gfx::CreateVectorIcon(kCreditCardIcon, kIconSize, gfx::kChromeIconGrey),
l10n_util::GetStringUTF16(IDS_PROFILES_CREDIT_CARDS_LINK));
view->AddChildView(credit_cards_button_);
// Addresses.
addresses_button_ =
new HoverButton(this,
gfx::CreateVectorIcon(vector_icons::kLocationOnIcon,
kIconSize, gfx::kChromeIconGrey),
l10n_util::GetStringUTF16(IDS_PROFILES_ADDRESSES_LINK));
view->AddChildView(addresses_button_);
return view;
}
views::View* ProfileChooserView::CreateCurrentProfileAccountsView(
const AvatarMenu::Item& avatar_item) {
DCHECK(avatar_item.signed_in);
......
......@@ -143,6 +143,7 @@ class ProfileChooserView : public content::WebContentsDelegate,
views::View* CreateGuestProfileView();
views::View* CreateOptionsView(bool display_lock, AvatarMenu* avatar_menu);
views::View* CreateSupervisedUserDisclaimerView();
views::View* CreateAutofillHomeView();
// Account Management view for the profile |avatar_item|.
views::View* CreateCurrentProfileAccountsView(
......@@ -218,6 +219,9 @@ class ProfileChooserView : public content::WebContentsDelegate,
views::LabelButton* lock_button_;
views::LabelButton* close_all_windows_button_;
views::Link* add_account_link_;
views::LabelButton* passwords_button_;
views::LabelButton* credit_cards_button_;
views::LabelButton* addresses_button_;
// Buttons displayed in the gaia signin view.
views::ImageButton* gaia_signin_cancel_button_;
......
......@@ -14,6 +14,11 @@ namespace features {
const base::Feature kAffiliationBasedMatching = {
"AffiliationBasedMatching", base::FEATURE_ENABLED_BY_DEFAULT};
// Enables links to the setting pages from the Chrome profile menu for Passwords
// and Autofill.
const base::Feature kAutofillHome = {"AutofillHome",
base::FEATURE_ENABLED_BY_DEFAULT};
// Use HTML based username detector.
const base::Feature kHtmlBasedUsernameDetector = {
"HtmlBaseUsernameDetector", base::FEATURE_ENABLED_BY_DEFAULT};
......
......@@ -18,6 +18,7 @@ namespace features {
// alongside the definition of their values in the .cc file.
extern const base::Feature kAffiliationBasedMatching;
extern const base::Feature kAutofillHome;
extern const base::Feature kHtmlBasedUsernameDetector;
extern const base::Feature kManualFallbacksFilling;
extern const base::Feature kManualFallbacksFillingStandalone;
......
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