Skip to content

Commit

Permalink
AboutThisSite: Remove infobar UI
Browse files Browse the repository at this point in the history
Remove AboutThisSite infobar UI and title view that was added to
confirm infobar. We will replace the UI with a bubble. This also
resolves some memory regression pinpoint is complaining about.

Bug: 1307295, 1309309
Change-Id: Ie61d7f2ea0cf0904c6a78984d03dcb279c7ec67a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3578871
Reviewed-by: Olesia Marukhno <olesiamarukhno@google.com>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#991027}
  • Loading branch information
xchrdw authored and Chromium LUCI CQ committed Apr 11, 2022
1 parent eb8a2fd commit f5d4151
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 178 deletions.
10 changes: 1 addition & 9 deletions chrome/browser/page_info/about_this_site_tab_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@

#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/ui/page_info/about_this_site_message_delegate_android.h"
#else
#include "chrome/browser/ui/page_info/about_this_site_infobar_delegate.h"
#include "components/infobars/content/content_infobar_manager.h"
#endif

using page_info::about_this_site_validation::AboutThisSiteStatus;
Expand Down Expand Up @@ -166,13 +163,8 @@ void AboutThisSiteTabHelper::ShowBanner(
AboutThisSiteMessageDelegateAndroid::Create(
web_contents(), std::move(banner_info), std::move(on_dimiss),
std::move(on_url_opened));
#else
infobars::ContentInfoBarManager* infobar_manager =
infobars::ContentInfoBarManager::FromWebContents(web_contents());
AboutThisSiteInfoBarDelegate::Create(infobar_manager, std::move(banner_info),
std::move(on_dimiss),
std::move(on_url_opened));
#endif
// TODO(crbug.com/1307295): Implement desktop UI.
}

WEB_CONTENTS_USER_DATA_KEY_IMPL(AboutThisSiteTabHelper);
2 changes: 0 additions & 2 deletions chrome/browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1174,8 +1174,6 @@ static_library("ui") {
"omnibox/omnibox_theme.cc",
"omnibox/omnibox_theme.h",
"page_action/page_action_icon_type.h",
"page_info/about_this_site_infobar_delegate.cc",
"page_info/about_this_site_infobar_delegate.h",
"page_info/chrome_accuracy_tip_ui.h",
"page_info/page_info_dialog.cc",
"page_info/page_info_dialog.h",
Expand Down
79 changes: 0 additions & 79 deletions chrome/browser/ui/page_info/about_this_site_infobar_delegate.cc

This file was deleted.

54 changes: 0 additions & 54 deletions chrome/browser/ui/page_info/about_this_site_infobar_delegate.h

This file was deleted.

19 changes: 3 additions & 16 deletions chrome/browser/ui/views/infobars/confirm_infobar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
ConfirmInfoBar::ConfirmInfoBar(std::unique_ptr<ConfirmInfoBarDelegate> delegate)
: InfoBarView(std::move(delegate)) {
auto* delegate_ptr = GetDelegate();
title_ = AddChildView(CreateTitle(delegate_ptr->GetTitleText()));

label_ = AddChildView(CreateLabel(delegate_ptr->GetMessageText()));
label_->SetElideBehavior(delegate_ptr->GetMessageElideBehavior());

Expand Down Expand Up @@ -94,20 +92,12 @@ void ConfirmInfoBar::Layout() {

int x = GetStartX();
Views views;
views.push_back(title_);
views.push_back(label_);
views.push_back(link_);
AssignWidths(&views, std::max(0, GetEndX() - x - NonLabelWidth()));

ChromeLayoutProvider* layout_provider = ChromeLayoutProvider::Get();

title_->SetPosition(gfx::Point(x, OffsetY(title_)));
if (!title_->GetText().empty()) {
x = title_->bounds().right() +
layout_provider->GetDistanceMetric(
views::DISTANCE_RELATED_LABEL_HORIZONTAL);
}

label_->SetPosition(gfx::Point(x, OffsetY(label_)));
if (!label_->GetText().empty()) {
x = label_->bounds().right() +
Expand Down Expand Up @@ -147,8 +137,8 @@ ConfirmInfoBarDelegate* ConfirmInfoBar::GetDelegate() {
}

int ConfirmInfoBar::GetContentMinimumWidth() const {
return title_->GetMinimumSize().width() + label_->GetMinimumSize().width() +
link_->GetMinimumSize().width() + NonLabelWidth();
return label_->GetMinimumSize().width() + link_->GetMinimumSize().width() +
NonLabelWidth();
}

int ConfirmInfoBar::NonLabelWidth() const {
Expand All @@ -159,12 +149,9 @@ int ConfirmInfoBar::NonLabelWidth() const {
const int button_spacing = layout_provider->GetDistanceMetric(
views::DISTANCE_RELATED_BUTTON_HORIZONTAL);

int width = ((title_->GetText().empty() && label_->GetText().empty()) ||
(!ok_button_ && !cancel_button_))
int width = (label_->GetText().empty() || (!ok_button_ && !cancel_button_))
? 0
: label_spacing;
if (!title_->GetText().empty() && !label_->GetText().empty())
width += label_spacing;
if (ok_button_)
width += ok_button_->width() + (cancel_button_ ? button_spacing : 0);
width += cancel_button_ ? cancel_button_->width() : 0;
Expand Down
5 changes: 2 additions & 3 deletions chrome/browser/ui/views/infobars/confirm_infobar.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ class ConfirmInfoBar : public InfoBarView {
void OkButtonPressed();
void CancelButtonPressed();

// Returns the width of all content other than the title, label and link.
// Layout() uses this to determine how much space the label and link can take.
// Returns the width of all content other than the label and link. Layout()
// uses this to determine how much space the label and link can take.
int NonLabelWidth() const;

raw_ptr<views::Label> title_ = nullptr;
raw_ptr<views::Label> label_ = nullptr;
raw_ptr<views::MdTextButton> ok_button_ = nullptr;
raw_ptr<views::MdTextButton> cancel_button_ = nullptr;
Expand Down
9 changes: 0 additions & 9 deletions chrome/browser/ui/views/infobars/infobar_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include "ui/views/controls/label.h"
#include "ui/views/controls/link.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/style/typography.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/view_utils.h"
#include "ui/views/widget/widget.h"
Expand Down Expand Up @@ -248,14 +247,6 @@ void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) {
}
}

std::unique_ptr<views::Label> InfoBarView::CreateTitle(
const std::u16string& text) const {
auto title = std::make_unique<views::Label>(
text, views::style::CONTEXT_DIALOG_BODY_TEXT, STYLE_EMPHASIZED);
SetLabelDetails(title.get());
return title;
}

std::unique_ptr<views::Label> InfoBarView::CreateLabel(
const std::u16string& text) const {
auto label = std::make_unique<views::Label>(
Expand Down
3 changes: 0 additions & 3 deletions chrome/browser/ui/views/infobars/infobar_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ class InfoBarView : public infobars::InfoBar,
protected:
using Labels = std::vector<views::Label*>;

// Creates a title with the appropriate font and color for an infobar.
std::unique_ptr<views::Label> CreateTitle(const std::u16string& text) const;

// Creates a label with the appropriate font and color for an infobar.
std::unique_ptr<views::Label> CreateLabel(const std::u16string& text) const;

Expand Down
2 changes: 1 addition & 1 deletion components/infobars/core/confirm_infobar_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ConfirmInfoBarDelegate : public infobars::InfoBarDelegate {
InfoBarAutomationType GetInfoBarAutomationType() const override;

// Returns the title string to be displayed for the InfoBar.
// Defaults to having not title. Currently only used on iOS and Desktop.
// Defaults to having not title. Currently only used on iOS.
virtual std::u16string GetTitleText() const;

// Returns the message string to be displayed for the InfoBar.
Expand Down
1 change: 0 additions & 1 deletion components/infobars/core/infobar_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ class InfoBarDelegate {
IOS_PERMISSIONS_INFOBAR_DELEGATE = 108,
SUPPORTED_LINKS_INFOBAR_DELEGATE_CHROMEOS = 109,
AUTOFILL_VIRTUAL_CARD_ENROLLMENT_INFOBAR_DELEGATE_MOBILE = 110,
ABOUT_THIS_SITE_INFOBAR_DELEGATE = 111,
};

// Describes navigation events, used to decide whether infobars should be
Expand Down
1 change: 0 additions & 1 deletion tools/metrics/histograms/enums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46811,7 +46811,6 @@ Called by update_gpu_driver_bug_workaround_entries.py.-->
<int value="109" label="SUPPORTED_LINKS_INFOBAR_DELEGATE_CHROMEOS"/>
<int value="110"
label="AUTOFILL_VIRTUAL_CARD_ENROLLMENT_INFOBAR_DELEGATE_MOBILE"/>
<int value="111" label="ABOUT_THIS_SITE_INFOBAR_DELEGATE"/>
</enum>

<enum name="InfoBarResponse">
Expand Down

0 comments on commit f5d4151

Please sign in to comment.