Commit 627b8453 authored by Peter Kasting's avatar Peter Kasting Committed by Chromium LUCI CQ

Add metadata to classes in c/b/ui/views/page_action/.

Bug: 1159562
Change-Id: Iab73f6f6cdacb1bf8cddd69c17e6117511d3acc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2618980
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842160}
parent bbd6f6d3
......@@ -30,6 +30,7 @@
#include "ui/views/border.h"
#include "ui/views/controls/highlight_path_generator.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/metadata/metadata_impl_macros.h"
#include "ui/views/widget/widget.h"
namespace {
......@@ -439,10 +440,6 @@ int IconLabelBubbleView::GetEndPaddingWithSeparator() const {
return end_padding;
}
const char* IconLabelBubbleView::GetClassName() const {
return "IconLabelBubbleView";
}
void IconLabelBubbleView::SetUpForAnimation() {
SetInkDropMode(InkDropMode::ON);
SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY);
......@@ -566,3 +563,12 @@ void IconLabelBubbleView::UpdateBorder() {
gfx::Insets(GetLayoutConstant(LOCATION_BAR_CHILD_INTERIOR_PADDING),
GetLayoutInsets(LOCATION_BAR_ICON_INTERIOR_PADDING).left())));
}
BEGIN_METADATA(IconLabelBubbleView, views::LabelButton)
ADD_READONLY_PROPERTY_METADATA(SkColor, ForegroundColor)
ADD_READONLY_PROPERTY_METADATA(double, AnimationValue)
ADD_READONLY_PROPERTY_METADATA(int, InternalSpacing)
ADD_READONLY_PROPERTY_METADATA(int, ExtraInternalSpacing)
ADD_READONLY_PROPERTY_METADATA(int, WidthBetweenIconAndSeparator)
ADD_READONLY_PROPERTY_METADATA(int, EndPaddingWithSeparator)
END_METADATA
......@@ -20,6 +20,7 @@
#include "ui/views/animation/ink_drop_observer.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/label.h"
#include "ui/views/metadata/metadata_header_macros.h"
#include "ui/views/widget/widget_observer.h"
namespace gfx {
......@@ -41,6 +42,8 @@ class ImageView;
class IconLabelBubbleView : public views::InkDropObserver,
public views::LabelButton {
public:
METADATA_HEADER(IconLabelBubbleView);
static constexpr int kTrailingPaddingPreMd = 2;
class Delegate {
......@@ -172,10 +175,6 @@ class IconLabelBubbleView : public views::InkDropObserver,
// the animation is set to fully shown or fully hidden.
void ResetSlideAnimation(bool show);
// Returns true iff the slide animation has started, has not ended and is
// currently paused.
bool is_animation_paused() const { return is_animation_paused_; }
// Slide animation for label.
gfx::SlideAnimation slide_animation_{this};
......@@ -218,9 +217,6 @@ class IconLabelBubbleView : public views::InkDropObserver,
// separator width.
int GetEndPaddingWithSeparator() const;
// views::View:
const char* GetClassName() const override;
// Disables highlights and calls Show on the slide animation, should not be
// called directly, use AnimateIn() instead, which handles label visibility.
void ShowAnimation();
......
......@@ -77,7 +77,7 @@ void StarView::ExecuteCommand(ExecuteSource source) {
OnExecuting(source);
if (base::FeatureList::IsEnabled(reading_list::switches::kReadLater)) {
menu_model_ = std::make_unique<StarMenuModel>(
this, active(), chrome::CanMoveActiveTabToReadLater(browser_),
this, GetActive(), chrome::CanMoveActiveTabToReadLater(browser_),
chrome::IsCurrentTabUnreadInReadLater(browser_));
menu_runner_ = std::make_unique<views::MenuRunner>(
menu_model_.get(),
......@@ -95,12 +95,12 @@ views::BubbleDialogDelegate* StarView::GetBubble() const {
}
const gfx::VectorIcon& StarView::GetVectorIcon() const {
return active() ? omnibox::kStarActiveIcon : omnibox::kStarIcon;
return GetActive() ? omnibox::kStarActiveIcon : omnibox::kStarIcon;
}
base::string16 StarView::GetTextForTooltipAndAccessibleName() const {
return l10n_util::GetStringUTF16(active() ? IDS_TOOLTIP_STARRED
: IDS_TOOLTIP_STAR);
return l10n_util::GetStringUTF16(GetActive() ? IDS_TOOLTIP_STARRED
: IDS_TOOLTIP_STAR);
}
const char* StarView::GetClassName() const {
......
......@@ -66,7 +66,7 @@ IN_PROC_BROWSER_TEST_F(StarViewTest, BookmarksUrlOnPress) {
// The page should not initiall be bookmarked.
EXPECT_FALSE(bookmark_model->IsBookmarked(current_url));
EXPECT_FALSE(star_icon->active());
EXPECT_FALSE(star_icon->GetActive());
ui::MouseEvent pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(),
ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
......@@ -79,7 +79,7 @@ IN_PROC_BROWSER_TEST_F(StarViewTest, BookmarksUrlOnPress) {
static_cast<views::View*>(star_icon)->OnMouseReleased(released_event);
EXPECT_TRUE(bookmark_model->IsBookmarked(current_url));
EXPECT_TRUE(star_icon->active());
EXPECT_TRUE(star_icon->GetActive());
}
// Verify that clicking the bookmark star a second time hides the bookmark
......@@ -176,13 +176,13 @@ IN_PROC_BROWSER_TEST_F(StarViewTestWithReadLaterEnabled,
// The page should not initially be bookmarked.
EXPECT_FALSE(bookmark_model->IsBookmarked(current_url));
EXPECT_FALSE(star_icon->active());
EXPECT_FALSE(star_icon->GetActive());
OpenStarViewMenu(star_icon);
// The page should not be bookmarked when the menu is opened.
EXPECT_FALSE(bookmark_model->IsBookmarked(current_url));
EXPECT_FALSE(star_icon->active());
EXPECT_FALSE(star_icon->GetActive());
StarMenuModel* menu_model = star_icon->menu_model_for_test();
......@@ -193,7 +193,7 @@ IN_PROC_BROWSER_TEST_F(StarViewTestWithReadLaterEnabled,
menu_model->ActivatedAt(bookmark_command_index);
EXPECT_TRUE(bookmark_model->IsBookmarked(current_url));
EXPECT_TRUE(star_icon->active());
EXPECT_TRUE(star_icon->GetActive());
}
// Verifies clicking the Read Later button in the StarView's menu saves the page
......@@ -212,13 +212,13 @@ IN_PROC_BROWSER_TEST_F(StarViewTestWithReadLaterEnabled,
// The page should not initially be in model.
EXPECT_EQ(reading_list_model->GetEntryByURL(current_url), nullptr);
EXPECT_FALSE(star_icon->active());
EXPECT_FALSE(star_icon->GetActive());
OpenStarViewMenu(star_icon);
// The page should not be bookmarked when the menu is opened.
EXPECT_EQ(reading_list_model->GetEntryByURL(current_url), nullptr);
EXPECT_FALSE(star_icon->active());
EXPECT_FALSE(star_icon->GetActive());
StarMenuModel* menu_model = star_icon->menu_model_for_test();
......@@ -229,7 +229,7 @@ IN_PROC_BROWSER_TEST_F(StarViewTestWithReadLaterEnabled,
menu_model->ActivatedAt(read_later_command_index);
EXPECT_NE(reading_list_model->GetEntryByURL(current_url), nullptr);
EXPECT_FALSE(star_icon->active());
EXPECT_FALSE(star_icon->GetActive());
}
} // namespace
......@@ -7,11 +7,7 @@
#include "chrome/browser/ui/views/page_action/page_action_icon_controller.h"
#include "chrome/browser/ui/views/page_action/page_action_icon_params.h"
#include "ui/views/layout/box_layout.h"
// static
const char
PageActionIconContainerView::kPageActionIconContainerViewClassName[] =
"PageActionIconContainerView";
#include "ui/views/metadata/metadata_impl_macros.h"
PageActionIconContainerView::PageActionIconContainerView(
const PageActionIconParams& params)
......@@ -28,10 +24,6 @@ PageActionIconContainerView::PageActionIconContainerView(
PageActionIconContainerView::~PageActionIconContainerView() = default;
const char* PageActionIconContainerView::GetClassName() const {
return kPageActionIconContainerViewClassName;
}
void PageActionIconContainerView::ChildPreferredSizeChanged(
views::View* child) {
PreferredSizeChanged();
......@@ -40,3 +32,6 @@ void PageActionIconContainerView::ChildPreferredSizeChanged(
void PageActionIconContainerView::AddPageActionIcon(views::View* icon) {
AddChildView(icon);
}
BEGIN_METADATA(PageActionIconContainerView, views::View)
END_METADATA
......@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_VIEWS_PAGE_ACTION_PAGE_ACTION_ICON_CONTAINER_H_
#define CHROME_BROWSER_UI_VIEWS_PAGE_ACTION_PAGE_ACTION_ICON_CONTAINER_H_
#include "ui/views/metadata/metadata_header_macros.h"
#include "ui/views/view.h"
class PageActionIconController;
......@@ -22,16 +23,15 @@ class PageActionIconContainer {
class PageActionIconContainerView : public views::View,
public PageActionIconContainer {
public:
METADATA_HEADER(PageActionIconContainerView);
explicit PageActionIconContainerView(const PageActionIconParams& params);
PageActionIconContainerView(const PageActionIconContainerView&) = delete;
PageActionIconContainerView& operator=(const PageActionIconContainerView&) =
delete;
~PageActionIconContainerView() override;
PageActionIconController* controller() { return controller_.get(); }
// views::View:
const char* GetClassName() const override;
static const char kPageActionIconContainerViewClassName[];
private:
// views::View:
void ChildPreferredSizeChanged(views::View* child) override;
......@@ -40,8 +40,6 @@ class PageActionIconContainerView : public views::View,
void AddPageActionIcon(views::View* icon) override;
std::unique_ptr<PageActionIconController> controller_;
DISALLOW_COPY_AND_ASSIGN(PageActionIconContainerView);
};
#endif // CHROME_BROWSER_UI_VIEWS_PAGE_ACTION_PAGE_ACTION_ICON_CONTAINER_H_
......@@ -24,6 +24,7 @@
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/controls/button/button_controller.h"
#include "ui/views/controls/focus_ring.h"
#include "ui/views/metadata/metadata_impl_macros.h"
#include "ui/views/style/platform_style.h"
float PageActionIconView::Delegate::GetPageActionInkDropVisibleOpacity() const {
......@@ -181,13 +182,16 @@ void PageActionIconView::OnTouchUiChanged() {
IconLabelBubbleView::OnTouchUiChanged();
}
const char* PageActionIconView::GetClassName() const {
return "PageActionIconView";
}
void PageActionIconView::SetIconColor(SkColor icon_color) {
if (icon_color_ == icon_color)
return;
icon_color_ = icon_color;
UpdateIconImage();
OnPropertyChanged(&icon_color_, views::kPropertyEffectsNone);
}
SkColor PageActionIconView::GetIconColor() const {
return icon_color_;
}
void PageActionIconView::SetActive(bool active) {
......@@ -195,6 +199,11 @@ void PageActionIconView::SetActive(bool active) {
return;
active_ = active;
UpdateIconImage();
OnPropertyChanged(&active_, views::kPropertyEffectsNone);
}
bool PageActionIconView::GetActive() const {
return active_;
}
void PageActionIconView::Update() {
......@@ -247,3 +256,8 @@ void PageActionIconView::UpdateBorder() {
if (new_insets != GetInsets())
SetBorder(views::CreateEmptyBorder(new_insets));
}
BEGIN_METADATA(PageActionIconView, IconLabelBubbleView)
ADD_PROPERTY_METADATA(SkColor, IconColor)
ADD_PROPERTY_METADATA(bool, Active)
END_METADATA
......@@ -7,7 +7,6 @@
#include <memory>
#include "base/macros.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/omnibox/omnibox_theme.h"
#include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h"
......@@ -16,6 +15,7 @@
#include "ui/gfx/image/image_skia.h"
#include "ui/views/animation/ink_drop_host_view.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/metadata/metadata_header_macros.h"
class CommandUpdater;
class OmniboxView;
......@@ -37,6 +37,8 @@ class BubbleDialogDelegate;
// shows a bubble when clicked.
class PageActionIconView : public IconLabelBubbleView {
public:
METADATA_HEADER(PageActionIconView);
class Delegate {
public:
// Gets the opacity to use for the ink highlight.
......@@ -56,15 +58,18 @@ class PageActionIconView : public IconLabelBubbleView {
virtual const OmniboxView* GetOmniboxView() const;
};
PageActionIconView(const PageActionIconView&) = delete;
PageActionIconView& operator=(const PageActionIconView&) = delete;
~PageActionIconView() override;
// Updates the color of the icon, this must be set before the icon is drawn.
void SetIconColor(SkColor icon_color);
SkColor GetIconColor() const;
// Sets the active state of the icon. An active icon will be displayed in a
// "call to action" color.
void SetActive(bool active);
bool active() const { return active_; }
bool GetActive() const;
// Hide the icon on user input in progress and invokes UpdateImpl().
void Update();
......@@ -135,7 +140,6 @@ class PageActionIconView : public IconLabelBubbleView {
// IconLabelBubbleView:
void OnTouchUiChanged() override;
const char* GetClassName() const override;
// Updates the icon image after some state has changed.
virtual void UpdateIconImage();
......@@ -181,8 +185,6 @@ class PageActionIconView : public IconLabelBubbleView {
// The loading indicator, showing a throbber animation on top of the icon.
PageActionIconLoadingIndicatorView* loading_indicator_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(PageActionIconView);
};
#endif // CHROME_BROWSER_UI_VIEWS_PAGE_ACTION_PAGE_ACTION_ICON_VIEW_H_
......@@ -30,6 +30,7 @@
#include "components/omnibox/browser/vector_icons.h"
#include "components/webapps/installable/installable_metrics.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/metadata/metadata_impl_macros.h"
namespace {
......@@ -188,10 +189,6 @@ base::string16 PwaInstallView::GetTextForTooltipAndAccessibleName() const {
webapps::AppBannerManager::GetInstallableWebAppName(web_contents));
}
const char* PwaInstallView::GetClassName() const {
return "PwaInstallView";
}
bool PwaInstallView::ShouldShowIph(content::WebContents* web_contents,
webapps::AppBannerManager* manager) {
auto start_url = manager->GetManifestStartUrl();
......@@ -207,3 +204,6 @@ bool PwaInstallView::ShouldShowIph(content::WebContents* web_contents,
return score > kIphSiteEngagementThresholdParam.Get() &&
web_app::ShouldShowIph(profile->GetPrefs(), app_id);
}
BEGIN_METADATA(PwaInstallView, PageActionIconView)
END_METADATA
......@@ -5,8 +5,8 @@
#ifndef CHROME_BROWSER_UI_VIEWS_PAGE_ACTION_PWA_INSTALL_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_PAGE_ACTION_PWA_INSTALL_VIEW_H_
#include "base/macros.h"
#include "chrome/browser/ui/views/page_action/page_action_icon_view.h"
#include "ui/views/metadata/metadata_header_macros.h"
namespace webapps {
class AppBannerManager;
......@@ -16,10 +16,13 @@ class AppBannerManager;
// installability checks and can be installed.
class PwaInstallView : public PageActionIconView {
public:
METADATA_HEADER(PwaInstallView);
explicit PwaInstallView(
CommandUpdater* command_updater,
IconLabelBubbleView::Delegate* icon_label_bubble_delegate,
PageActionIconView::Delegate* page_action_icon_delegate);
PwaInstallView(const PwaInstallView&) = delete;
PwaInstallView& operator=(const PwaInstallView&) = delete;
~PwaInstallView() override;
protected:
......@@ -29,7 +32,6 @@ class PwaInstallView : public PageActionIconView {
views::BubbleDialogDelegate* GetBubble() const override;
const gfx::VectorIcon& GetVectorIcon() const override;
base::string16 GetTextForTooltipAndAccessibleName() const override;
const char* GetClassName() const override;
private:
// Called when IPH is closed.
......@@ -43,8 +45,6 @@ class PwaInstallView : public PageActionIconView {
webapps::AppBannerManager* manager);
base::WeakPtrFactory<PwaInstallView> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(PwaInstallView);
};
#endif // CHROME_BROWSER_UI_VIEWS_PAGE_ACTION_PWA_INSTALL_VIEW_H_
......@@ -15,6 +15,7 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/events/event.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/metadata/metadata_impl_macros.h"
ZoomView::ZoomView(IconLabelBubbleView::Delegate* icon_label_bubble_delegate,
PageActionIconView::Delegate* page_action_icon_delegate)
......@@ -113,6 +114,5 @@ base::string16 ZoomView::GetTextForTooltipAndAccessibleName() const {
base::FormatPercent(current_zoom_percent_));
}
const char* ZoomView::GetClassName() const {
return "ZoomView";
}
BEGIN_METADATA(ZoomView, PageActionIconView)
END_METADATA
......@@ -5,18 +5,21 @@
#ifndef CHROME_BROWSER_UI_VIEWS_PAGE_ACTION_ZOOM_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_PAGE_ACTION_ZOOM_VIEW_H_
#include "base/macros.h"
#include "chrome/browser/ui/views/page_action/page_action_icon_view.h"
#include "ui/views/metadata/metadata_header_macros.h"
// View for the zoom icon in the Omnibox.
class ZoomView : public PageActionIconView {
public:
METADATA_HEADER(ZoomView);
// Clicking on the ZoomView shows a ZoomBubbleView, which requires the current
// WebContents. Because the current WebContents changes as the user switches
// tabs, a LocationBarView::Delegate is supplied to queried for the current
// WebContents when needed.
ZoomView(IconLabelBubbleView::Delegate* icon_label_bubble_delegate,
PageActionIconView::Delegate* page_action_icon_delegate);
ZoomView(const ZoomView&) = delete;
ZoomView& operator=(const ZoomView&) = delete;
~ZoomView() override;
// Updates the image and its tooltip appropriately, hiding or showing the icon
......@@ -30,7 +33,6 @@ class ZoomView : public PageActionIconView {
views::BubbleDialogDelegate* GetBubble() const override;
const gfx::VectorIcon& GetVectorIcon() const override;
base::string16 GetTextForTooltipAndAccessibleName() const override;
const char* GetClassName() const override;
private:
bool ShouldBeVisible(bool can_show_bubble) const;
......@@ -39,8 +41,6 @@ class ZoomView : public PageActionIconView {
const gfx::VectorIcon* icon_ = nullptr;
int current_zoom_percent_ = 100;
DISALLOW_COPY_AND_ASSIGN(ZoomView);
};
#endif // CHROME_BROWSER_UI_VIEWS_PAGE_ACTION_ZOOM_VIEW_H_
......@@ -126,12 +126,12 @@ void ReaderModeIconView::UpdateImpl() {
}
const gfx::VectorIcon& ReaderModeIconView::GetVectorIcon() const {
return active() ? kReaderModeIcon : kReaderModeDisabledIcon;
return GetActive() ? kReaderModeIcon : kReaderModeDisabledIcon;
}
base::string16 ReaderModeIconView::GetTextForTooltipAndAccessibleName() const {
return l10n_util::GetStringUTF16(active() ? IDS_EXIT_DISTILLED_PAGE
: IDS_DISTILL_PAGE);
return l10n_util::GetStringUTF16(GetActive() ? IDS_EXIT_DISTILLED_PAGE
: IDS_DISTILL_PAGE);
}
const char* ReaderModeIconView::GetClassName() const {
......@@ -146,7 +146,7 @@ views::BubbleDialogDelegate* ReaderModeIconView::GetBubble() const {
void ReaderModeIconView::OnExecuting(
PageActionIconView::ExecuteSource execute_source) {
if (active()) {
if (GetActive()) {
dom_distiller::UMAHelper::RecordReaderModeExit(
dom_distiller::UMAHelper::ReaderModeEntryPoint::kOmniboxIcon);
} else {
......
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