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

Add metadata for various View subclasses that lack it, 1/n

Bug: 1159562
Change-Id: I59929dd816008c69bd82930e6834529218fde15d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2644705
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846385}
parent 2966f7dc
......@@ -51,6 +51,8 @@
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/metadata/metadata_header_macros.h"
#include "ui/views/metadata/metadata_impl_macros.h"
#include "ui/views/style/typography.h"
#include "ui/views/style/typography_provider.h"
#include "ui/views/view.h"
......@@ -210,7 +212,10 @@ namespace {
// specified maximum.
class ConstrainedWidthView : public views::View {
public:
METADATA_HEADER(ConstrainedWidthView);
ConstrainedWidthView(std::unique_ptr<views::View> child, int max_width);
ConstrainedWidthView(const ConstrainedWidthView&) = delete;
ConstrainedWidthView& operator=(const ConstrainedWidthView&) = delete;
~ConstrainedWidthView() override = default;
private:
......@@ -218,8 +223,6 @@ class ConstrainedWidthView : public views::View {
gfx::Size CalculatePreferredSize() const override;
int max_width_;
DISALLOW_COPY_AND_ASSIGN(ConstrainedWidthView);
};
ConstrainedWidthView::ConstrainedWidthView(std::unique_ptr<views::View> child,
......@@ -236,11 +239,15 @@ gfx::Size ConstrainedWidthView::CalculatePreferredSize() const {
return gfx::Size(max_width_, GetHeightForWidth(max_width_));
}
BEGIN_METADATA(ConstrainedWidthView, views::View)
END_METADATA
// This represents a single selectable item. Subclasses distinguish between
// footer and suggestion rows, which are structurally similar but have
// distinct styling.
class AutofillPopupItemView : public AutofillPopupRowView {
public:
METADATA_HEADER(AutofillPopupItemView);
~AutofillPopupItemView() override = default;
// views::View:
......@@ -266,7 +273,7 @@ class AutofillPopupItemView : public AutofillPopupRowView {
void RefreshStyle() override;
std::unique_ptr<views::Background> CreateBackground() final;
int frontend_id() const { return frontend_id_; }
int GetFrontendId() const;
virtual int GetPrimaryTextStyle() = 0;
// Returns a value view. The label part is optional but allow caller to keep
......@@ -301,10 +308,22 @@ class AutofillPopupItemView : public AutofillPopupRowView {
std::vector<views::Label*> inner_labels_;
};
int AutofillPopupItemView::GetFrontendId() const {
return frontend_id_;
}
BEGIN_METADATA(AutofillPopupItemView, AutofillPopupRowView)
ADD_READONLY_PROPERTY_METADATA(int, FrontendId)
END_METADATA
// This represents a suggestion, i.e., a row containing data that will be filled
// into the page if selected.
class AutofillPopupSuggestionView : public AutofillPopupItemView {
public:
METADATA_HEADER(AutofillPopupSuggestionView);
AutofillPopupSuggestionView(const AutofillPopupSuggestionView&) = delete;
AutofillPopupSuggestionView& operator=(const AutofillPopupSuggestionView&) =
delete;
~AutofillPopupSuggestionView() override = default;
static AutofillPopupSuggestionView* Create(
......@@ -320,13 +339,18 @@ class AutofillPopupSuggestionView : public AutofillPopupItemView {
AutofillPopupSuggestionView(AutofillPopupViewNativeViews* popup_view,
int line_number,
int frontend_id);
DISALLOW_COPY_AND_ASSIGN(AutofillPopupSuggestionView);
};
BEGIN_METADATA(AutofillPopupSuggestionView, AutofillPopupItemView)
END_METADATA
// This represents a password suggestion row, i.e., a username and password.
class PasswordPopupSuggestionView : public AutofillPopupSuggestionView {
public:
METADATA_HEADER(PasswordPopupSuggestionView);
PasswordPopupSuggestionView(const PasswordPopupSuggestionView&) = delete;
PasswordPopupSuggestionView& operator=(const PasswordPopupSuggestionView&) =
delete;
~PasswordPopupSuggestionView() override = default;
static PasswordPopupSuggestionView* Create(
......@@ -347,14 +371,16 @@ class PasswordPopupSuggestionView : public AutofillPopupSuggestionView {
int frontend_id);
base::string16 origin_;
base::string16 masked_password_;
DISALLOW_COPY_AND_ASSIGN(PasswordPopupSuggestionView);
};
BEGIN_METADATA(PasswordPopupSuggestionView, AutofillPopupSuggestionView)
END_METADATA
// This represents an option which appears in the footer of the dropdown, such
// as a row which will open the Autofill settings page when selected.
class AutofillPopupFooterView : public AutofillPopupItemView {
public:
METADATA_HEADER(AutofillPopupFooterView);
~AutofillPopupFooterView() override = default;
static AutofillPopupFooterView* Create(
......@@ -375,11 +401,18 @@ class AutofillPopupFooterView : public AutofillPopupItemView {
int frontend_id);
};
BEGIN_METADATA(AutofillPopupFooterView, AutofillPopupItemView)
END_METADATA
// Draws a separator between sections of the dropdown, namely between datalist
// and Autofill suggestions. Note that this is NOT the same as the border on top
// of the footer section or the border between footer items.
class AutofillPopupSeparatorView : public AutofillPopupRowView {
public:
METADATA_HEADER(AutofillPopupSeparatorView);
AutofillPopupSeparatorView(const AutofillPopupSeparatorView&) = delete;
AutofillPopupSeparatorView& operator=(const AutofillPopupSeparatorView&) =
delete;
~AutofillPopupSeparatorView() override = default;
static AutofillPopupSeparatorView* Create(
......@@ -401,13 +434,17 @@ class AutofillPopupSeparatorView : public AutofillPopupRowView {
private:
AutofillPopupSeparatorView(AutofillPopupViewNativeViews* popup_view,
int line_number);
DISALLOW_COPY_AND_ASSIGN(AutofillPopupSeparatorView);
};
BEGIN_METADATA(AutofillPopupSeparatorView, AutofillPopupRowView)
END_METADATA
// Draws a row which contains a warning message.
class AutofillPopupWarningView : public AutofillPopupRowView {
public:
METADATA_HEADER(AutofillPopupWarningView);
AutofillPopupWarningView(const AutofillPopupWarningView&) = delete;
AutofillPopupWarningView& operator=(const AutofillPopupWarningView&) = delete;
~AutofillPopupWarningView() override = default;
static AutofillPopupWarningView* Create(
......@@ -429,15 +466,16 @@ class AutofillPopupWarningView : public AutofillPopupRowView {
AutofillPopupWarningView(AutofillPopupViewNativeViews* popup_view,
int line_number)
: AutofillPopupRowView(popup_view, line_number) {}
DISALLOW_COPY_AND_ASSIGN(AutofillPopupWarningView);
};
BEGIN_METADATA(AutofillPopupWarningView, AutofillPopupRowView)
END_METADATA
/************** AutofillPopupItemView **************/
void AutofillPopupItemView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
AutofillPopupController* controller = popup_view()->controller();
auto suggestion = controller->GetSuggestionAt(line_number());
auto suggestion = controller->GetSuggestionAt(GetLineNumber());
std::vector<base::string16> text;
text.push_back(suggestion.value);
......@@ -461,17 +499,17 @@ void AutofillPopupItemView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
// Options are selectable.
node_data->role = ax::mojom::Role::kListBoxOption;
node_data->AddBoolAttribute(ax::mojom::BoolAttribute::kSelected,
is_selected());
GetSelected());
// Compute set size and position in set, by checking the frontend_id of each
// row, summing the number of interactive rows, and subtracting the number
// of separators found before this row from its |pos_in_set|.
int set_size = 0;
int pos_in_set = line_number() + 1;
int pos_in_set = GetLineNumber() + 1;
for (int i = 0; i < controller->GetLineCount(); ++i) {
if (controller->GetSuggestionAt(i).frontend_id ==
autofill::POPUP_ITEM_ID_SEPARATOR) {
if (i < line_number())
if (i < GetLineNumber())
--pos_in_set;
} else {
++set_size;
......@@ -484,7 +522,7 @@ void AutofillPopupItemView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
void AutofillPopupItemView::OnMouseEntered(const ui::MouseEvent& event) {
AutofillPopupController* controller = popup_view()->controller();
if (controller)
controller->SetSelectedLine(line_number());
controller->SetSelectedLine(GetLineNumber());
}
void AutofillPopupItemView::OnMouseExited(const ui::MouseEvent& event) {
......@@ -497,7 +535,7 @@ void AutofillPopupItemView::OnMouseReleased(const ui::MouseEvent& event) {
AutofillPopupController* controller = popup_view()->controller();
if (controller && event.IsOnlyLeftMouseButton() &&
HitTestPoint(event.location())) {
controller->AcceptSuggestion(line_number());
controller->AcceptSuggestion(GetLineNumber());
}
}
......@@ -507,10 +545,10 @@ void AutofillPopupItemView::OnGestureEvent(ui::GestureEvent* event) {
return;
switch (event->type()) {
case ui::ET_GESTURE_TAP_DOWN:
controller->SetSelectedLine(line_number());
controller->SetSelectedLine(GetLineNumber());
break;
case ui::ET_GESTURE_TAP:
controller->AcceptSuggestion(line_number());
controller->AcceptSuggestion(GetLineNumber());
break;
case ui::ET_GESTURE_TAP_CANCEL:
case ui::ET_GESTURE_END:
......@@ -534,7 +572,7 @@ void AutofillPopupItemView::CreateContent() {
std::vector<Suggestion> suggestions = controller->GetSuggestions();
std::unique_ptr<views::ImageView> icon =
GetIconImageView(suggestions[line_number()]);
GetIconImageView(suggestions[GetLineNumber()]);
if (icon) {
AddChildView(std::move(icon));
......@@ -570,7 +608,7 @@ void AutofillPopupItemView::CreateContent() {
AddChildView(std::move(all_labels));
std::unique_ptr<views::ImageView> store_indicator_icon =
GetStoreIndicatorIconImageView(suggestions[line_number()]);
GetStoreIndicatorIconImageView(suggestions[GetLineNumber()]);
if (store_indicator_icon) {
AddSpacerWithSize(GetHorizontalMargin(),
/*resize=*/true, layout_manager);
......@@ -580,9 +618,9 @@ void AutofillPopupItemView::CreateContent() {
void AutofillPopupItemView::RefreshStyle() {
SetBackground(CreateBackground());
SkColor bk_color = is_selected() ? popup_view()->GetSelectedBackgroundColor()
SkColor bk_color = GetSelected() ? popup_view()->GetSelectedBackgroundColor()
: popup_view()->GetBackgroundColor();
SkColor fg_color = is_selected() ? popup_view()->GetSelectedForegroundColor()
SkColor fg_color = GetSelected() ? popup_view()->GetSelectedForegroundColor()
: popup_view()->GetForegroundColor();
for (views::Label* label : inner_labels_) {
label->SetAutoColorReadabilityEnabled(false);
......@@ -600,7 +638,7 @@ void AutofillPopupItemView::RefreshStyle() {
std::unique_ptr<views::Background> AutofillPopupItemView::CreateBackground() {
return views::CreateSolidBackground(
is_selected() ? popup_view()->GetSelectedBackgroundColor()
GetSelected() ? popup_view()->GetSelectedBackgroundColor()
: popup_view()->GetBackgroundColor());
}
......@@ -608,10 +646,10 @@ AutofillPopupItemView::ViewWithLabel AutofillPopupItemView::CreateValueLabel() {
// TODO(crbug.com/831603): Remove elision responsibilities from controller.
ViewWithLabel view_and_label;
base::string16 text =
popup_view()->controller()->GetSuggestionValueAt(line_number());
popup_view()->controller()->GetSuggestionValueAt(GetLineNumber());
if (popup_view()
->controller()
->GetSuggestionAt(line_number())
->GetSuggestionAt(GetLineNumber())
.is_value_secondary) {
std::unique_ptr<views::Label> label = CreateLabelWithStyleAndContext(
text, views::style::CONTEXT_DIALOG_BODY_TEXT,
......@@ -622,7 +660,7 @@ AutofillPopupItemView::ViewWithLabel AutofillPopupItemView::CreateValueLabel() {
}
auto text_label = CreateLabelWithStyleAndContext(
popup_view()->controller()->GetSuggestionValueAt(line_number()),
popup_view()->controller()->GetSuggestionValueAt(GetLineNumber()),
views::style::CONTEXT_DIALOG_BODY_TEXT, GetPrimaryTextStyle());
const gfx::Font::Weight font_weight = GetPrimaryTextWeight();
......@@ -708,9 +746,9 @@ AutofillPopupSuggestionView::AutofillPopupSuggestionView(
std::vector<AutofillPopupItemView::ViewWithLabel>
AutofillPopupSuggestionView::CreateSubtextLabels() {
const base::string16& second_row_label =
popup_view()->controller()->GetSuggestionAt(line_number()).label;
popup_view()->controller()->GetSuggestionAt(GetLineNumber()).label;
const base::string16& third_row_label =
popup_view()->controller()->GetSuggestionAt(line_number()).offer_label;
popup_view()->controller()->GetSuggestionAt(GetLineNumber()).offer_label;
std::vector<AutofillPopupItemView::ViewWithLabel> labels;
for (const base::string16& text : {second_row_label, third_row_label}) {
......@@ -819,11 +857,11 @@ void AutofillPopupFooterView::CreateContent() {
layout_manager->set_cross_axis_alignment(
views::BoxLayout::CrossAxisAlignment::kCenter);
const Suggestion suggestion = controller->GetSuggestions()[line_number()];
const Suggestion suggestion = controller->GetSuggestions()[GetLineNumber()];
std::unique_ptr<views::ImageView> icon = GetIconImageView(suggestion);
const bool use_leading_icon =
base::Contains(kItemTypesUsingLeadingIcons, frontend_id());
base::Contains(kItemTypesUsingLeadingIcons, GetFrontendId());
if (suggestion.is_loading) {
SetEnabled(false);
......@@ -949,7 +987,7 @@ void AutofillPopupWarningView::GetAccessibleNodeData(
if (!controller)
return;
node_data->SetName(controller->GetSuggestionAt(line_number()).value);
node_data->SetName(controller->GetSuggestionAt(GetLineNumber()).value);
node_data->role = ax::mojom::Role::kStaticText;
}
......@@ -964,7 +1002,7 @@ void AutofillPopupWarningView::CreateContent() {
gfx::Insets(vertical_margin, horizontal_margin)));
auto text_label = std::make_unique<views::Label>(
controller->GetSuggestionValueAt(line_number()),
controller->GetSuggestionValueAt(GetLineNumber()),
views::style::CONTEXT_DIALOG_BODY_TEXT, ChromeTextStyle::STYLE_RED);
text_label->SetEnabledColor(popup_view()->GetWarningColor());
text_label->SetMultiLine(true);
......@@ -982,14 +1020,15 @@ AutofillPopupWarningView::CreateBackground() {
/************** AutofillPopupRowView **************/
void AutofillPopupRowView::SetSelected(bool is_selected) {
if (is_selected == is_selected_)
void AutofillPopupRowView::SetSelected(bool selected) {
if (selected == selected_)
return;
is_selected_ = is_selected;
if (is_selected)
selected_ = selected;
if (selected)
popup_view_->NotifyAXSelection(this);
RefreshStyle();
OnPropertyChanged(&selected_, views::kPropertyEffectsNone);
}
void AutofillPopupRowView::OnThemeChanged() {
......@@ -1016,6 +1055,14 @@ void AutofillPopupRowView::Init() {
CreateContent();
}
int AutofillPopupRowView::GetLineNumber() const {
return line_number_;
}
bool AutofillPopupRowView::GetSelected() const {
return selected_;
}
bool AutofillPopupRowView::HandleAccessibleAction(
const ui::AXActionData& action_data) {
if (action_data.action == ax::mojom::Action::kFocus)
......@@ -1023,6 +1070,11 @@ bool AutofillPopupRowView::HandleAccessibleAction(
return View::HandleAccessibleAction(action_data);
}
BEGIN_METADATA(AutofillPopupRowView, views::View)
ADD_PROPERTY_METADATA(bool, Selected)
ADD_READONLY_PROPERTY_METADATA(int, LineNumber)
END_METADATA
/************** AutofillPopupViewNativeViews **************/
AutofillPopupViewNativeViews::AutofillPopupViewNativeViews(
......@@ -1306,6 +1358,9 @@ bool AutofillPopupViewNativeViews::DoUpdateBoundsAndRedrawPopup() {
return true;
}
BEGIN_METADATA(AutofillPopupViewNativeViews, AutofillPopupBaseView)
END_METADATA
// static
AutofillPopupView* AutofillPopupView::Create(
base::WeakPtr<AutofillPopupController> controller) {
......
......@@ -8,13 +8,13 @@
#include <memory>
#include <vector>
#include "base/macros.h"
#include "base/optional.h"
#include "chrome/browser/ui/autofill/autofill_popup_view.h"
#include "chrome/browser/ui/views/autofill/autofill_popup_base_view.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/font_list.h"
#include "ui/views/metadata/metadata_header_macros.h"
namespace views {
class BoxLayout;
......@@ -30,8 +30,11 @@ class AutofillPopupViewNativeViews;
// separators.
class AutofillPopupRowView : public views::View {
public:
METADATA_HEADER(AutofillPopupRowView);
AutofillPopupRowView(const AutofillPopupRowView&) = delete;
AutofillPopupRowView& operator=(const AutofillPopupRowView&) = delete;
~AutofillPopupRowView() override = default;
void SetSelected(bool is_selected);
void SetSelected(bool selected);
// views::View:
bool HandleAccessibleAction(const ui::AXActionData& action_data) override;
......@@ -52,8 +55,8 @@ class AutofillPopupRowView : public views::View {
void Init();
AutofillPopupViewNativeViews* popup_view() { return popup_view_; }
int line_number() const { return line_number_; }
bool is_selected() const { return is_selected_; }
int GetLineNumber() const;
bool GetSelected() const;
virtual void CreateContent() = 0;
virtual void RefreshStyle() = 0;
......@@ -62,9 +65,7 @@ class AutofillPopupRowView : public views::View {
private:
AutofillPopupViewNativeViews* popup_view_;
const int line_number_;
bool is_selected_ = false;
DISALLOW_COPY_AND_ASSIGN(AutofillPopupRowView);
bool selected_ = false;
};
// Views implementation for the autofill and password suggestion.
......@@ -72,8 +73,12 @@ class AutofillPopupRowView : public views::View {
class AutofillPopupViewNativeViews : public AutofillPopupBaseView,
public AutofillPopupView {
public:
METADATA_HEADER(AutofillPopupViewNativeViews);
AutofillPopupViewNativeViews(AutofillPopupController* controller,
views::Widget* parent_widget);
AutofillPopupViewNativeViews(const AutofillPopupViewNativeViews&) = delete;
AutofillPopupViewNativeViews& operator=(const AutofillPopupViewNativeViews&) =
delete;
~AutofillPopupViewNativeViews() override;
const std::vector<AutofillPopupRowView*>& GetRowsForTesting() {
......@@ -118,8 +123,6 @@ class AutofillPopupViewNativeViews : public AutofillPopupBaseView,
views::ScrollView* scroll_view_ = nullptr;
views::View* body_container_ = nullptr;
views::View* footer_container_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(AutofillPopupViewNativeViews);
};
} // namespace autofill
......
......@@ -48,6 +48,8 @@
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/metadata/metadata_header_macros.h"
#include "ui/views/metadata/metadata_impl_macros.h"
#include "ui/views/widget/widget.h"
namespace {
......@@ -171,6 +173,7 @@ bool CookiesTreeViewDrawingProvider::ShouldDrawIconForNode(
// A custom view that conditionally displays an infobar.
class InfobarView : public views::View {
public:
METADATA_HEADER(InfobarView);
InfobarView() {
info_image_ = AddChildView(std::make_unique<views::ImageView>());
info_image_->SetImage(gfx::CreateVectorIcon(vector_icons::kInfoOutlineIcon,
......@@ -196,7 +199,9 @@ class InfobarView : public views::View {
horizontal_spacing));
SetVisible(false);
}
~InfobarView() override {}
InfobarView(const InfobarView&) = delete;
InfobarView& operator=(const InfobarView&) = delete;
~InfobarView() override = default;
// Set the InfobarView label text based on content |setting| and
// |domain_name|. Ensure InfobarView is visible.
......@@ -230,10 +235,11 @@ class InfobarView : public views::View {
views::ImageView* info_image_;
// The label responsible for rendering the text.
views::Label* label_;
DISALLOW_COPY_AND_ASSIGN(InfobarView);
};
BEGIN_METADATA(InfobarView, views::View)
END_METADATA
///////////////////////////////////////////////////////////////////////////////
// CollectedCookiesViews, public:
......
......@@ -31,6 +31,7 @@
#include "ui/views/controls/throbber.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/metadata/metadata_impl_macros.h"
#include "ui/views/widget/widget.h"
DeviceChooserContentView::DeviceChooserContentView(
......@@ -379,3 +380,7 @@ views::Throbber* DeviceChooserContentView::ThrobberForTesting() {
views::Label* DeviceChooserContentView::ThrobberLabelForTesting() {
return throbber_label_;
}
BEGIN_METADATA(DeviceChooserContentView, views::View)
ADD_READONLY_PROPERTY_METADATA(base::string16, WindowTitle)
END_METADATA
......@@ -7,11 +7,11 @@
#include <memory>
#include "base/macros.h"
#include "base/strings/string16.h"
#include "chrome/browser/chooser_controller/chooser_controller.h"
#include "ui/base/models/table_model.h"
#include "ui/gfx/range/range.h"
#include "ui/views/metadata/metadata_header_macros.h"
#include "ui/views/view.h"
namespace views {
......@@ -29,9 +29,12 @@ class DeviceChooserContentView : public views::View,
public ui::TableModel,
public ChooserController::View {
public:
METADATA_HEADER(DeviceChooserContentView);
DeviceChooserContentView(
views::TableViewObserver* table_view_observer,
std::unique_ptr<ChooserController> chooser_controller);
DeviceChooserContentView(const DeviceChooserContentView&) = delete;
DeviceChooserContentView& operator=(const DeviceChooserContentView&) = delete;
~DeviceChooserContentView() override;
// views::View:
......@@ -91,8 +94,6 @@ class DeviceChooserContentView : public views::View,
bool is_initialized_ = false;
base::CallbackListSubscription select_all_subscription_;
DISALLOW_COPY_AND_ASSIGN(DeviceChooserContentView);
};
#endif // CHROME_BROWSER_UI_VIEWS_DEVICE_CHOOSER_CONTENT_VIEW_H_
......@@ -199,6 +199,8 @@
#include "ui/views/controls/webview/webview.h"
#include "ui/views/focus/external_focus_tracker.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/metadata/metadata_header_macros.h"
#include "ui/views/metadata/metadata_impl_macros.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/widget/native_widget.h"
#include "ui/views/widget/root_view.h"
......@@ -348,6 +350,7 @@ bool IsShowingWebContentsModalDialog(content::WebContents* web_contents) {
// immersive fullscreen reveal).
class TopContainerOverlayView : public views::View {
public:
METADATA_HEADER(TopContainerOverlayView);
explicit TopContainerOverlayView(base::WeakPtr<BrowserView> browser_view)
: browser_view_(std::move(browser_view)) {}
~TopContainerOverlayView() override = default;
......@@ -370,6 +373,9 @@ class TopContainerOverlayView : public views::View {
base::WeakPtr<BrowserView> browser_view_;
};
BEGIN_METADATA(TopContainerOverlayView, views::View)
END_METADATA
// A view targeter for the overlay view, which makes sure the overlay view
// itself is never a target for events, but its children (i.e. top_container)
// may be.
......@@ -394,6 +400,9 @@ class OverlayViewTargeterDelegate : public views::ViewTargeterDelegate {
};
class ContentsSeparator : public views::Separator {
public:
METADATA_HEADER(ContentsSeparator);
private:
// views::View:
void OnThemeChanged() override {
......@@ -411,6 +420,9 @@ class ContentsSeparator : public views::Separator {
}
};
BEGIN_METADATA(ContentsSeparator, views::Separator)
END_METADATA
bool ShouldShowWindowIcon(const Browser* browser) {
#if BUILDFLAG(IS_CHROMEOS_ASH)
// For Chrome OS only, trusted windows (apps and settings) do not show a
......
......@@ -24,6 +24,8 @@
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/metadata/metadata_header_macros.h"
#include "ui/views/metadata/metadata_impl_macros.h"
#include "ui/views/widget/widget.h"
namespace {
......@@ -39,6 +41,7 @@ constexpr int kPasswordGenerationMaxWidth = 480;
class PasswordGenerationPopupViewViews::GeneratedPasswordBox
: public views::View {
public:
METADATA_HEADER(GeneratedPasswordBox);
GeneratedPasswordBox() = default;
~GeneratedPasswordBox() override = default;
......@@ -155,6 +158,11 @@ void PasswordGenerationPopupViewViews::GeneratedPasswordBox::BuildColumnSet(
views::GridLayout::ColumnSize::kUsePreferred, 0, 0);
}
BEGIN_NESTED_METADATA(PasswordGenerationPopupViewViews,
GeneratedPasswordBox,
views::View)
END_METADATA
PasswordGenerationPopupViewViews::PasswordGenerationPopupViewViews(
PasswordGenerationPopupController* controller,
views::Widget* parent_widget)
......
......@@ -18,6 +18,8 @@
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/metadata/metadata_header_macros.h"
#include "ui/views/metadata/metadata_impl_macros.h"
#include "ui/views/style/typography.h"
#include "ui/views/widget/widget.h"
......@@ -52,13 +54,16 @@ const char kKeyNameDelimiter[] = "|";
// key (not just a simple label).
class SubtleNotificationView::InstructionView : public views::View {
public:
METADATA_HEADER(InstructionView);
// Creates an InstructionView with specific text. |text| may contain one or
// more segments delimited by a pair of pipes ('|'); each of these segments
// will be displayed as a keyboard key. e.g., "Press |Alt|+|Q| to exit" will
// have "Alt" and "Q" rendered as keys.
explicit InstructionView(const base::string16& text);
InstructionView(const InstructionView&) = delete;
InstructionView& operator=(const InstructionView&) = delete;
const base::string16 text() const { return text_; }
base::string16 GetText() const;
void SetText(const base::string16& text);
private:
......@@ -68,8 +73,6 @@ class SubtleNotificationView::InstructionView : public views::View {
void AddTextSegment(const base::string16& text, bool format_as_key);
base::string16 text_;
DISALLOW_COPY_AND_ASSIGN(InstructionView);
};
SubtleNotificationView::InstructionView::InstructionView(
......@@ -82,6 +85,10 @@ SubtleNotificationView::InstructionView::InstructionView(
SetText(text);
}
base::string16 SubtleNotificationView::InstructionView::GetText() const {
return text_;
}
void SubtleNotificationView::InstructionView::SetText(
const base::string16& text) {
// Avoid replacing the contents with the same text.
......@@ -139,6 +146,10 @@ void SubtleNotificationView::InstructionView::AddTextSegment(
AddChildView(key);
}
BEGIN_NESTED_METADATA(SubtleNotificationView, InstructionView, views::View)
ADD_PROPERTY_METADATA(base::string16, Text)
END_METADATA
SubtleNotificationView::SubtleNotificationView() : instruction_view_(nullptr) {
std::unique_ptr<views::BubbleBorder> bubble_border(new views::BubbleBorder(
views::BubbleBorder::NONE, views::BubbleBorder::NO_SHADOW,
......@@ -193,7 +204,10 @@ views::Widget* SubtleNotificationView::CreatePopupWidget(
void SubtleNotificationView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ax::mojom::Role::kAlert;
base::string16 accessible_name;
base::RemoveChars(instruction_view_->text(),
base::RemoveChars(instruction_view_->GetText(),
base::ASCIIToUTF16(kKeyNameDelimiter), &accessible_name);
node_data->SetName(accessible_name);
}
BEGIN_METADATA(SubtleNotificationView, views::View)
END_METADATA
......@@ -7,9 +7,9 @@
#include <memory>
#include "base/macros.h"
#include "base/strings/string16.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/metadata/metadata_header_macros.h"
#include "ui/views/view.h"
namespace views {
......@@ -24,7 +24,10 @@ class Widget;
// rounded rectangle).
class SubtleNotificationView : public views::View {
public:
METADATA_HEADER(SubtleNotificationView);
SubtleNotificationView();
SubtleNotificationView(const SubtleNotificationView&) = delete;
SubtleNotificationView& operator=(const SubtleNotificationView&) = delete;
~SubtleNotificationView() override;
// Display the |instruction_text| to the user. If |instruction_text| is
......@@ -43,8 +46,6 @@ class SubtleNotificationView : public views::View {
// Text displayed in the bubble, with optional keyboard keys.
InstructionView* instruction_view_;
DISALLOW_COPY_AND_ASSIGN(SubtleNotificationView);
};
#endif // CHROME_BROWSER_UI_VIEWS_SUBTLE_NOTIFICATION_VIEW_H_
......@@ -29,6 +29,7 @@
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/layout/flex_layout_types.h"
#include "ui/views/metadata/metadata_impl_macros.h"
#include "ui/views/view_class_properties.h"
namespace {
......@@ -279,3 +280,7 @@ void ColorPickerView::OnColorSelected(ColorPickerElementView* element) {
if (callback_)
callback_.Run();
}
BEGIN_METADATA(ColorPickerView, views::View)
ADD_READONLY_PROPERTY_METADATA(base::Optional<int>, SelectedElement)
END_METADATA
......@@ -14,6 +14,7 @@
#include "chrome/browser/ui/views/tabs/tab_group_editor_bubble_view.h"
#include "components/tab_groups/tab_group_color.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/metadata/metadata_header_macros.h"
#include "ui/views/view.h"
namespace views {
......@@ -28,6 +29,8 @@ class ColorPickerElementView;
// selection is made.
class ColorPickerView : public views::View {
public:
METADATA_HEADER(ColorPickerView);
using ColorSelectedCallback = base::RepeatingCallback<void()>;
// |colors| should contain the color values and accessible names. There should
......
......@@ -67,6 +67,8 @@
#include "ui/views/layout/flex_layout.h"
#include "ui/views/layout/flex_layout_types.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/metadata/metadata_header_macros.h"
#include "ui/views/metadata/metadata_impl_macros.h"
#include "ui/views/style/platform_style.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/widget/widget.h"
......@@ -77,14 +79,17 @@ namespace {
// button changes a layout is required.
class AdvancedViewContainer : public views::View {
public:
METADATA_HEADER(AdvancedViewContainer);
AdvancedViewContainer() {}
AdvancedViewContainer(const AdvancedViewContainer&) = delete;
AdvancedViewContainer& operator=(const AdvancedViewContainer&) = delete;
void ChildPreferredSizeChanged(views::View* child) override { Layout(); }
private:
DISALLOW_COPY_AND_ASSIGN(AdvancedViewContainer);
};
BEGIN_METADATA(AdvancedViewContainer, views::View)
END_METADATA
bool UseGoogleTranslateBranding() {
// Only use Google Translate branding in Chrome branded builds.
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
......
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