Commit da2bf7b5 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

cbui: remove SharingDialogView CreateFootnoteView

This change moves CreateFootnoteView into an anonymous namespace,
and passes in the instance variables it needs. While the
SharingDialogData member is not itself const, none of the members
that CreateFootnoteView depends on change during the lifetime of
SharingDialogView. Unfortunately the member cannot be const since
it contains some callbacks that need to be run, and the members of
SharingDialogData cannot be made const because they are iteratively
filled in by other code before the dialog is created.

Bug: 1011446
Change-Id: I3af6a9a3d3c2e5aa2f1d50dbb560182ccff945c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1901432Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713433}
parent 29dab844
......@@ -156,13 +156,32 @@ std::unique_ptr<views::View> MaybeCreateImageView(
return image_view;
}
std::unique_ptr<views::View> CreateFootnoteView(
const SharingDialogData& data,
content::WebContents* web_contents,
views::StyledLabelListener* listener) {
bool show_origin = ShouldShowOrigin(data, web_contents);
switch (data.type) {
case SharingDialogType::kDialogWithoutDevicesWithApp:
return CreateHelpText(data, listener, show_origin);
case SharingDialogType::kDialogWithDevicesMaybeApps:
return show_origin ? CreateOriginView(data) : nullptr;
case SharingDialogType::kErrorDialog:
case SharingDialogType::kEducationalDialog:
return nullptr;
}
}
} // namespace
SharingDialogView::SharingDialogView(views::View* anchor_view,
content::WebContents* web_contents,
SharingDialogData data)
: LocationBarBubbleDelegateView(anchor_view, web_contents),
data_(std::move(data)) {}
data_(std::move(data)) {
DialogDelegate::SetFootnoteView(
::CreateFootnoteView(data_, web_contents, this));
}
SharingDialogView::~SharingDialogView() = default;
......@@ -174,19 +193,6 @@ int SharingDialogView::GetDialogButtons() const {
return ui::DIALOG_BUTTON_NONE;
}
std::unique_ptr<views::View> SharingDialogView::CreateFootnoteView() {
bool show_origin = ShouldShowOrigin(data_, web_contents());
switch (GetDialogType()) {
case SharingDialogType::kDialogWithoutDevicesWithApp:
return CreateHelpText(data_, this, show_origin);
case SharingDialogType::kDialogWithDevicesMaybeApps:
return show_origin ? CreateOriginView(data_) : nullptr;
case SharingDialogType::kErrorDialog:
case SharingDialogType::kEducationalDialog:
return nullptr;
}
}
void SharingDialogView::StyledLabelLinkClicked(views::StyledLabel* label,
const gfx::Range& range,
int event_flags) {
......
......@@ -44,7 +44,6 @@ class SharingDialogView : public SharingDialog,
void WindowClosing() override;
void WebContentsDestroyed() override;
int GetDialogButtons() const override;
std::unique_ptr<views::View> CreateFootnoteView() override;
gfx::Size CalculatePreferredSize() const override;
void AddedToWidget() override;
void OnThemeChanged() override;
......
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