Commit c4cc9e81 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[profile-menu] Mark removable code after ProfileMenuRevamp

Bug: 1021587, 993752
Change-Id: Id0b9adcfa72c5c9567a315dc7bada293a2bdbe52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1899880
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Auto-Submit: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720213}
parent 166a3912
......@@ -66,6 +66,7 @@ namespace {
constexpr float kShortcutIconToImageRatio = 9.0 / 16.0;
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// Number of times the Dice sign-in promo illustration should be shown.
constexpr int kDiceSigninPromoIllustrationShowCountMax = 10;
......@@ -77,6 +78,7 @@ ProfileAttributesEntry* GetProfileAttributesEntry(Profile* profile) {
return entry;
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
BadgedProfilePhoto::BadgeType GetProfileBadgeType(Profile* profile) {
if (profile->IsSupervised()) {
return profile->IsChild() ? BadgedProfilePhoto::BADGE_TYPE_CHILD
......@@ -114,6 +116,7 @@ bool AreSigninCookiesClearedOnExit(Profile* profile) {
return client->AreSigninCookiesDeletedOnExit();
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
// Returns the Google G icon in grey and with a padding of 2. The padding is
// needed to make the icon look smaller, otherwise it looks too big compared to
......@@ -182,11 +185,13 @@ ProfileMenuView::ProfileMenuView(views::Button* anchor_button,
ProfileMenuView::~ProfileMenuView() = default;
void ProfileMenuView::BuildMenu() {
// TODO(crbug.com/993752): Remove after ProfileMenuRevamp.
avatar_menu_ = std::make_unique<AvatarMenu>(
&g_browser_process->profile_manager()->GetProfileAttributesStorage(),
this, browser());
avatar_menu_->RebuildMenu();
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
if (!base::FeatureList::IsEnabled(features::kProfileMenuRevamp)) {
if (dice_enabled_) {
// Fetch DICE accounts. Note: This always includes the primary account if
......@@ -215,16 +220,18 @@ void ProfileMenuView::BuildMenu() {
BuildProfileManagementFeatureButtons();
}
// TODO(crbug.com/993752): Remove after ProfileMenuRevamp.
void ProfileMenuView::OnAvatarMenuChanged(
AvatarMenu* avatar_menu) {
// TODO(crbug.com/993752): Remove AvatarMenu observer.
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
void ProfileMenuView::FocusButtonOnKeyboardOpen() {
if (first_profile_button_)
first_profile_button_->RequestFocus();
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
void ProfileMenuView::OnWidgetClosing(views::Widget* /*widget*/) {
// Unsubscribe from everything early so that the updates do not reach the
// bubble and change its state.
......@@ -294,6 +301,7 @@ void ProfileMenuView::OnManageProfilesButtonClicked() {
PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER);
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
void ProfileMenuView::OnLockButtonClicked() {
RecordClick(ActionableItem::kLockButton);
profiles::LockProfile(browser()->profile());
......@@ -362,6 +370,7 @@ void ProfileMenuView::OnSyncErrorButtonClicked(
}
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
void ProfileMenuView::OnCurrentProfileCardClicked() {
RecordClick(ActionableItem::kCurrentProfileCard);
if (dice_enabled_ &&
......@@ -697,6 +706,7 @@ void ProfileMenuView::BuildProfileManagementFeatureButtons() {
}
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
void ProfileMenuView::AddProfileMenuView(AvatarMenu* avatar_menu) {
// Separate items into active and alternatives.
const AvatarMenu::Item* active_item = nullptr;
......@@ -735,6 +745,7 @@ void ProfileMenuView::AddProfileMenuView(AvatarMenu* avatar_menu) {
AddOptionsView(display_lock, avatar_menu);
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
bool ProfileMenuView::AddSyncErrorViewIfNeeded(
const AvatarMenu::Item& avatar_item) {
int content_string_id, button_string_id;
......@@ -754,6 +765,7 @@ bool ProfileMenuView::AddSyncErrorViewIfNeeded(
return true;
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
void ProfileMenuView::AddPreDiceSyncErrorView(
const AvatarMenu::Item& avatar_item,
sync_ui_util::AvatarSyncErrorType error,
......@@ -780,6 +792,7 @@ void ProfileMenuView::AddPreDiceSyncErrorView(
}
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
void ProfileMenuView::AddDiceSyncErrorView(
const AvatarMenu::Item& avatar_item,
sync_ui_util::AvatarSyncErrorType error,
......@@ -832,6 +845,7 @@ void ProfileMenuView::AddDiceSyncErrorView(
}
}
// TODO(crbug.com/1021587): Incorporate into ProfileMenuRevamp.
void ProfileMenuView::AddSyncPausedReasonCookiesClearedOnExit() {
base::string16 link_text = l10n_util::GetStringUTF16(
IDS_SYNC_PAUSED_REASON_CLEAR_COOKIES_ON_EXIT_LINK_TEXT);
......@@ -845,6 +859,7 @@ void ProfileMenuView::AddSyncPausedReasonCookiesClearedOnExit() {
base::Unretained(this)));
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
void ProfileMenuView::AddCurrentProfileView(
const AvatarMenu::Item& avatar_item,
bool is_guest) {
......
......@@ -28,6 +28,7 @@ class Browser;
// This bubble view is displayed when the user clicks on the avatar button.
// It displays a list of profiles and allows users to switch between profiles.
// TODO(crbug.com/993752): Remove AvatarMenuObserver after ProfileMenuRevamp.
class ProfileMenuView : public ProfileMenuViewBase, public AvatarMenuObserver {
public:
ProfileMenuView(views::Button* anchor_button,
......@@ -41,6 +42,7 @@ class ProfileMenuView : public ProfileMenuViewBase, public AvatarMenuObserver {
private:
friend class ProfileMenuViewExtensionsTest;
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// ProfileMenuViewBase:
void FocusButtonOnKeyboardOpen() override;
......@@ -55,11 +57,9 @@ class ProfileMenuView : public ProfileMenuViewBase, public AvatarMenuObserver {
void OnAddressesButtonClicked();
void OnGuestProfileButtonClicked();
void OnManageProfilesButtonClicked();
void OnLockButtonClicked();
void OnExitProfileButtonClicked();
void OnSyncSettingsButtonClicked();
void OnSyncErrorButtonClicked(sync_ui_util::AvatarSyncErrorType error);
void OnCurrentProfileCardClicked();
void OnSigninButtonClicked();
void OnSigninAccountButtonClicked(AccountInfo account);
void OnSignoutButtonClicked();
......@@ -68,6 +68,11 @@ class ProfileMenuView : public ProfileMenuViewBase, public AvatarMenuObserver {
void OnAddNewProfileButtonClicked();
void OnEditProfileButtonClicked();
// TODO(crbug.com/1021587): Remove methods after ProfileMenuRevamp.
void OnLockButtonClicked();
void OnCurrentProfileCardClicked();
// TODO(crbug.com/993752): Remove after ProfileMenuRevamp.
// AvatarMenuObserver:
void OnAvatarMenuChanged(AvatarMenu* avatar_menu) override;
......@@ -87,9 +92,11 @@ class ProfileMenuView : public ProfileMenuViewBase, public AvatarMenuObserver {
void BuildSelectableProfiles();
void BuildProfileManagementFeatureButtons();
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// Adds the profile chooser view.
void AddProfileMenuView(AvatarMenu* avatar_menu);
// TODO(crbug.com/1021587): Remove methods below after ProfileMenuRevamp.
// Adds the main profile card for the profile |avatar_item|. |is_guest| is
// used to determine whether to show any Sign in/Sign out/Manage accounts
// links.
......@@ -101,14 +108,17 @@ class ProfileMenuView : public ProfileMenuViewBase, public AvatarMenuObserver {
void AddAutofillHomeView();
void AddManageGoogleAccountButton();
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// Adds the DICE UI view to sign in and turn on sync. It includes an
// illustration, a promo and a button.
void AddDiceSigninView();
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// Adds a header for signin and sync error surfacing for the user menu.
// Returns true if header is created.
bool AddSyncErrorViewIfNeeded(const AvatarMenu::Item& avatar_item);
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// Adds a view showing a sync error and an error button, when dice is not
// enabled.
void AddPreDiceSyncErrorView(const AvatarMenu::Item& avatar_item,
......@@ -116,42 +126,53 @@ class ProfileMenuView : public ProfileMenuViewBase, public AvatarMenuObserver {
int button_string_id,
int content_string_id);
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// Adds a view showing the profile associated with |avatar_item| and an error
// button below, when dice is enabled.
void AddDiceSyncErrorView(const AvatarMenu::Item& avatar_item,
sync_ui_util::AvatarSyncErrorType error,
int button_string_id);
// TODO(crbug.com/1021587): Add to new profile menu.
// Add a view showing that the reason for the sync paused is in the cookie
// settings setup. On click, will direct to the cookie settings page.
void AddSyncPausedReasonCookiesClearedOnExit();
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// Adds a promo for signin, if dice is not enabled.
void AddPreDiceSigninPromo();
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// Adds a promo for signin, if dice is enabled.
void AddDiceSigninPromo();
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// Clean-up done after an action was performed in the ProfileChooser.
void PostActionPerformed(ProfileMetrics::ProfileDesktopMenu action_performed);
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// Methods to keep track of the number of times the Dice sign-in promo has
// been shown.
int GetDiceSigninPromoShowCount() const;
void IncrementDiceSigninPromoShowCount();
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
std::unique_ptr<AvatarMenu> avatar_menu_;
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// Button pointers used in tests.
views::Button* first_profile_button_ = nullptr;
views::Button* lock_button_ = nullptr;
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// The current access point of sign in.
const signin_metrics::AccessPoint access_point_;
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// Dice accounts used in the sync promo.
std::vector<AccountInfo> dice_accounts_;
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
const bool dice_enabled_;
DISALLOW_COPY_AND_ASSIGN(ProfileMenuView);
......
......@@ -162,6 +162,7 @@ std::unique_ptr<views::Button> CreateCircularImageButton(
} // namespace
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// MenuItems--------------------------------------------------------------------
ProfileMenuViewBase::MenuItems::MenuItems()
......@@ -246,6 +247,7 @@ ProfileMenuViewBase::~ProfileMenuViewBase() {
// Items stored for menu generation are removed after menu is finalized, hence
// it's not expected to have while destroying the object.
DCHECK(g_profile_bubble_ != this);
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
DCHECK(menu_item_groups_.empty());
}
......@@ -569,6 +571,7 @@ bool ProfileMenuViewBase::HandleContextMenu(
void ProfileMenuViewBase::Init() {
Reset();
BuildMenu();
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
if (!base::FeatureList::IsEnabled(features::kProfileMenuRevamp))
RepopulateViewFromMenuItems();
}
......@@ -617,6 +620,7 @@ int ProfileMenuViewBase::GetMaxHeight() const {
}
void ProfileMenuViewBase::Reset() {
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
if (!base::FeatureList::IsEnabled(features::kProfileMenuRevamp)) {
menu_item_groups_.clear();
return;
......@@ -683,6 +687,7 @@ void ProfileMenuViewBase::Reset() {
layout->AddView(std::move(scroll_view));
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
int ProfileMenuViewBase::GetMarginSize(GroupMarginSize margin_size) const {
switch (margin_size) {
case kNone:
......@@ -699,6 +704,7 @@ int ProfileMenuViewBase::GetMarginSize(GroupMarginSize margin_size) const {
}
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
void ProfileMenuViewBase::AddMenuGroup(bool add_separator) {
if (add_separator && !menu_item_groups_.empty()) {
DCHECK(!menu_item_groups_.back().items.empty());
......@@ -708,6 +714,7 @@ void ProfileMenuViewBase::AddMenuGroup(bool add_separator) {
menu_item_groups_.emplace_back();
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
void ProfileMenuViewBase::AddMenuItemInternal(std::unique_ptr<views::View> view,
MenuItems::ItemType item_type) {
DCHECK(!menu_item_groups_.empty());
......@@ -724,6 +731,7 @@ void ProfileMenuViewBase::AddMenuItemInternal(std::unique_ptr<views::View> view,
}
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
views::Button* ProfileMenuViewBase::CreateAndAddTitleCard(
std::unique_ptr<views::View> icon_view,
const base::string16& title,
......@@ -739,6 +747,7 @@ views::Button* ProfileMenuViewBase::CreateAndAddTitleCard(
return button_ptr;
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
views::Button* ProfileMenuViewBase::CreateAndAddButton(
const gfx::ImageSkia& icon,
const base::string16& title,
......@@ -751,6 +760,7 @@ views::Button* ProfileMenuViewBase::CreateAndAddButton(
return pointer;
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
views::Button* ProfileMenuViewBase::CreateAndAddBlueButton(
const base::string16& text,
bool md_style,
......@@ -772,6 +782,7 @@ views::Button* ProfileMenuViewBase::CreateAndAddBlueButton(
return pointer;
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
#if !defined(OS_CHROMEOS)
DiceSigninButtonView* ProfileMenuViewBase::CreateAndAddDiceSigninButton(
AccountInfo* account_info,
......@@ -796,6 +807,7 @@ DiceSigninButtonView* ProfileMenuViewBase::CreateAndAddDiceSigninButton(
}
#endif
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
views::Label* ProfileMenuViewBase::CreateAndAddLabel(const base::string16& text,
int text_context) {
std::unique_ptr<views::Label> label =
......@@ -816,6 +828,7 @@ views::Label* ProfileMenuViewBase::CreateAndAddLabel(const base::string16& text,
return pointer;
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
views::StyledLabel* ProfileMenuViewBase::CreateAndAddLabelWithLink(
const base::string16& text,
gfx::Range link_range,
......@@ -831,6 +844,7 @@ views::StyledLabel* ProfileMenuViewBase::CreateAndAddLabelWithLink(
return pointer;
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
void ProfileMenuViewBase::AddViewItem(std::unique_ptr<views::View> view) {
// Add margins.
std::unique_ptr<views::View> margined_view = std::make_unique<views::View>();
......@@ -847,6 +861,7 @@ void ProfileMenuViewBase::RegisterClickAction(views::View* clickable_view,
click_actions_[clickable_view] = std::move(action);
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
void ProfileMenuViewBase::RepopulateViewFromMenuItems() {
RemoveAllChildViews(true);
......@@ -941,11 +956,13 @@ void ProfileMenuViewBase::RepopulateViewFromMenuItems() {
}
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
gfx::ImageSkia ProfileMenuViewBase::CreateVectorIcon(
const gfx::VectorIcon& icon) {
return gfx::CreateVectorIcon(icon, kIconSize, GetDefaultIconColor());
}
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
int ProfileMenuViewBase::GetDefaultIconSize() {
return kIconSize;
}
......@@ -32,6 +32,7 @@ class Label;
} // namespace views
struct AccountInfo;
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
class DiceSigninButtonView;
// This class provides the UI for different menus that are created by user
......@@ -67,6 +68,7 @@ class ProfileMenuViewBase : public content::WebContentsDelegate,
kMaxValue = kEditProfileButton,
};
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// MenuItems struct keeps the menu items and meta data for a group of items in
// a menu. It takes the ownership of views and passes it to the menu when menu
// is constructed.
......@@ -93,6 +95,7 @@ class ProfileMenuViewBase : public content::WebContentsDelegate,
DISALLOW_COPY_AND_ASSIGN(MenuItems);
};
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
enum GroupMarginSize { kNone, kTiny, kSmall, kLarge };
// Shows the bubble if one is not already showing. This allows us to easily
......@@ -158,10 +161,12 @@ class ProfileMenuViewBase : public content::WebContentsDelegate,
// Should be called inside each button/link action.
void RecordClick(ActionableItem item);
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// Initializes a new group of menu items. A separator is added before them if
// |add_separator| is true.
void AddMenuGroup(bool add_separator = true);
// TODO(crbug.com/1021587): Remove methods below after ProfileMenuRevamp.
// The following functions add different menu items to the latest menu group.
// They pass the ownership of the generated item to |menu_item_groups_| and
// return a raw pointer to the object. The ownership is transferred to the
......@@ -200,16 +205,20 @@ class ProfileMenuViewBase : public content::WebContentsDelegate,
views::Button* anchor_button() const { return anchor_button_; }
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
gfx::ImageSkia CreateVectorIcon(const gfx::VectorIcon& icon);
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
int GetDefaultIconSize();
private:
friend class ProfileMenuViewExtensionsTest;
void Reset();
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
void RepopulateViewFromMenuItems();
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// Requests focus for a button when opened by keyboard.
virtual void FocusButtonOnKeyboardOpen() {}
......@@ -240,14 +249,17 @@ class ProfileMenuViewBase : public content::WebContentsDelegate,
void RegisterClickAction(views::View* clickable_view,
base::RepeatingClosure action);
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// Returns the size of different margin types.
int GetMarginSize(GroupMarginSize margin_size) const;
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
void AddMenuItemInternal(std::unique_ptr<views::View> view,
MenuItems::ItemType item_type);
Browser* const browser_;
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// ProfileMenuViewBase takes ownership of all menu_items and passes it to the
// underlying view when it is created.
std::vector<MenuItems> menu_item_groups_;
......
......@@ -155,6 +155,7 @@ Profile* SetupProfilesForLock(Profile* signed_in) {
} // namespace
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
class ProfileMenuViewExtensionsTest
: public SupportsTestDialog<extensions::ExtensionBrowserTest> {
public:
......@@ -266,6 +267,7 @@ class ProfileMenuViewExtensionsTest
DISALLOW_COPY_AND_ASSIGN(ProfileMenuViewExtensionsTest);
};
// TODO(crbug.com/1021587): Remove after ProfileMenuRevamp.
// TODO(crbug.com/932818): Remove this class after
// |kAutofillEnableToolbarStatusChip| is cleaned up. Otherwise we need it
// because the toolbar is init-ed before each test is set up. Thus need to
......
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