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