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

views: remove more anchor points from bubbles

This change removes all the remaining places where
LocationBarBubbleDelegateView's constructor is called with a value other
than an in-line gfx::Point(). The next CL of this series will remove
that parameter from LocationBarBubbleDelegateView itself and clean up
documentation and helper functions.

Bug: 989080
Change-Id: I524f836f898365ba662a677ca92118a11cdeb658
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1744638
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Auto-Submit: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#685554}
parent 23b06b3b
......@@ -1421,7 +1421,7 @@ send_tab_to_self::SendTabToSelfBubbleView* BrowserView::ShowSendTabToSelfBubble(
send_tab_to_self::SendTabToSelfBubbleViewImpl* bubble =
new send_tab_to_self::SendTabToSelfBubbleViewImpl(
GetLocationBarView(), gfx::Point(), web_contents, controller);
GetLocationBarView(), web_contents, controller);
views::BubbleDialogDelegateView::CreateBubble(bubble);
bubble->Show(send_tab_to_self::SendTabToSelfBubbleViewImpl::USER_GESTURE);
......
......@@ -186,7 +186,6 @@ ZoomBubbleView* ZoomBubbleView::zoom_bubble_ = nullptr;
// static
void ZoomBubbleView::ShowBubble(content::WebContents* web_contents,
const gfx::Point& anchor_point,
DisplayReason reason) {
Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
// |web_contents| could have been unloaded if a tab gets closed and a mouse
......@@ -206,8 +205,8 @@ void ZoomBubbleView::ShowBubble(content::WebContents* web_contents,
ImmersiveModeController* immersive_mode_controller =
GetImmersiveModeControllerForBrowser(browser);
zoom_bubble_ = new ZoomBubbleView(anchor_view, anchor_point, web_contents,
reason, immersive_mode_controller);
zoom_bubble_ = new ZoomBubbleView(anchor_view, web_contents, reason,
immersive_mode_controller);
const extensions::ExtensionZoomRequestClient* client =
GetExtensionZoomRequestClient(web_contents);
......@@ -286,11 +285,10 @@ void ZoomBubbleView::Refresh() {
ZoomBubbleView::ZoomBubbleView(
views::View* anchor_view,
const gfx::Point& anchor_point,
content::WebContents* web_contents,
DisplayReason reason,
ImmersiveModeController* immersive_mode_controller)
: LocationBarBubbleDelegateView(anchor_view, anchor_point, web_contents),
: LocationBarBubbleDelegateView(anchor_view, gfx::Point(), web_contents),
auto_close_duration_(kBubbleCloseDelayDefault),
auto_close_(reason == AUTOMATIC),
immersive_mode_controller_(immersive_mode_controller),
......
......@@ -36,7 +36,6 @@ class ZoomBubbleView : public LocationBarBubbleDelegateView,
// Shows the bubble and automatically closes it after a short time period if
// |reason| is AUTOMATIC.
static void ShowBubble(content::WebContents* web_contents,
const gfx::Point& anchor_point,
DisplayReason reason);
// If the bubble is being shown for the given |web_contents|, refreshes it.
......@@ -82,12 +81,11 @@ class ZoomBubbleView : public LocationBarBubbleDelegateView,
std::unique_ptr<const extensions::IconImage> icon_image;
};
// Constructs ZoomBubbleView. Anchors the bubble to |anchor_view| when it is
// not nullptr or alternatively, to |anchor_point|. The bubble will auto-close
// when |reason| is AUTOMATIC. If |immersive_mode_controller_| is present, the
// bubble will auto-close when the top-of-window views are revealed.
// Constructs ZoomBubbleView. Anchors the bubble to |anchor_view|, which must
// not be nullptr. The bubble will auto-close when |reason| is AUTOMATIC. If
// |immersive_mode_controller_| is present, the bubble will auto-close when
// the top-of-window views are revealed.
ZoomBubbleView(views::View* anchor_view,
const gfx::Point& anchor_point,
content::WebContents* web_contents,
DisplayReason reason,
ImmersiveModeController* immersive_mode_controller);
......
......@@ -35,8 +35,7 @@ namespace {
void ShowInActiveTab(Browser* browser) {
content::WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents();
ZoomBubbleView::ShowBubble(web_contents, gfx::Point(),
ZoomBubbleView::USER_GESTURE);
ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::USER_GESTURE);
EXPECT_TRUE(ZoomBubbleView::GetZoomBubble());
}
......@@ -53,8 +52,7 @@ IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, NonImmersiveFullscreen) {
content::WebContents* web_contents = browser_view->GetActiveWebContents();
// The zoom bubble should be anchored when not in fullscreen.
ZoomBubbleView::ShowBubble(web_contents, gfx::Point(),
ZoomBubbleView::AUTOMATIC);
ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::AUTOMATIC);
ASSERT_TRUE(ZoomBubbleView::GetZoomBubble());
const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubble();
EXPECT_TRUE(zoom_bubble->GetAnchorView());
......@@ -76,8 +74,7 @@ IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, NonImmersiveFullscreen) {
// The bubble should not be anchored when it is shown in non-immersive
// fullscreen.
ZoomBubbleView::ShowBubble(web_contents, gfx::Point(),
ZoomBubbleView::AUTOMATIC);
ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::AUTOMATIC);
ASSERT_TRUE(ZoomBubbleView::GetZoomBubble());
zoom_bubble = ZoomBubbleView::GetZoomBubble();
EXPECT_FALSE(zoom_bubble->GetAnchorView());
......@@ -115,8 +112,7 @@ IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, ImmersiveFullscreen) {
// The zoom bubble should not be anchored when it is shown in immersive
// fullscreen and the top-of-window views are not revealed.
ZoomBubbleView::ShowBubble(web_contents, gfx::Point(),
ZoomBubbleView::AUTOMATIC);
ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::AUTOMATIC);
ASSERT_TRUE(ZoomBubbleView::GetZoomBubble());
const ZoomBubbleView* zoom_bubble = ZoomBubbleView::GetZoomBubble();
EXPECT_FALSE(zoom_bubble->GetAnchorView());
......@@ -130,8 +126,7 @@ IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, ImmersiveFullscreen) {
// The zoom bubble should be anchored when it is shown in immersive fullscreen
// and the top-of-window views are revealed.
ZoomBubbleView::ShowBubble(web_contents, gfx::Point(),
ZoomBubbleView::AUTOMATIC);
ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::AUTOMATIC);
zoom_bubble = ZoomBubbleView::GetZoomBubble();
ASSERT_TRUE(zoom_bubble);
EXPECT_TRUE(zoom_bubble->GetAnchorView());
......@@ -160,13 +155,11 @@ IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, NoWebContentsIsSafe) {
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
ZoomBubbleView::ShowBubble(web_contents, gfx::Point(),
ZoomBubbleView::AUTOMATIC);
ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::AUTOMATIC);
// Close the current tab and try opening the zoom bubble with stale
// |web_contents|.
chrome::CloseTab(browser());
ZoomBubbleView::ShowBubble(web_contents, gfx::Point(),
ZoomBubbleView::AUTOMATIC);
ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::AUTOMATIC);
}
// Ensure a tab switch closes the bubble.
......@@ -342,8 +335,7 @@ IN_PROC_BROWSER_TEST_F(ZoomBubbleDialogTest, InvokeUi_default) {
IN_PROC_BROWSER_TEST_F(ZoomBubbleBrowserTest, FocusPreventsClose) {
content::WebContents* web_contents =
browser()->tab_strip_model()->GetActiveWebContents();
ZoomBubbleView::ShowBubble(web_contents, gfx::Point(),
ZoomBubbleView::AUTOMATIC);
ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::AUTOMATIC);
ZoomBubbleView* bubble = ZoomBubbleView::GetZoomBubble();
ASSERT_TRUE(bubble);
// |auto_close_timer_| is running so that the bubble is closed at the end.
......
......@@ -261,8 +261,8 @@ void NativeFileSystemUsageBubbleView::ShowBubble(
}
usage.readable_directories = readable_directories;
bubble_ = new NativeFileSystemUsageBubbleView(
anchor_view, gfx::Point(), web_contents, origin, std::move(usage));
bubble_ = new NativeFileSystemUsageBubbleView(anchor_view, web_contents,
origin, std::move(usage));
bubble_->SetHighlightedButton(anchor_view->GetPageActionIconView(
PageActionIconType::kNativeFileSystemAccess));
......@@ -285,11 +285,10 @@ NativeFileSystemUsageBubbleView* NativeFileSystemUsageBubbleView::GetBubble() {
NativeFileSystemUsageBubbleView::NativeFileSystemUsageBubbleView(
views::View* anchor_view,
const gfx::Point& anchor_point,
content::WebContents* web_contents,
const url::Origin& origin,
Usage usage)
: LocationBarBubbleDelegateView(anchor_view, anchor_point, web_contents),
: LocationBarBubbleDelegateView(anchor_view, gfx::Point(), web_contents),
origin_(origin),
usage_(std::move(usage)),
writable_paths_model_(usage_.writable_files, usage_.writable_directories),
......
......@@ -56,7 +56,6 @@ class NativeFileSystemUsageBubbleView : public LocationBarBubbleDelegateView,
};
NativeFileSystemUsageBubbleView(views::View* anchor_view,
const gfx::Point& anchor_point,
content::WebContents* web_contents,
const url::Origin& origin,
Usage usage);
......
......@@ -80,8 +80,7 @@ void ZoomView::ZoomChangedForActiveTab(bool can_show_bubble) {
SetVisible(true);
if (can_show_bubble) {
ZoomBubbleView::ShowBubble(web_contents, gfx::Point(),
ZoomBubbleView::AUTOMATIC);
ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::AUTOMATIC);
} else {
ZoomBubbleView::RefreshBubbleIfShowing(web_contents);
}
......@@ -95,8 +94,7 @@ void ZoomView::ZoomChangedForActiveTab(bool can_show_bubble) {
}
void ZoomView::OnExecuting(PageActionIconView::ExecuteSource source) {
ZoomBubbleView::ShowBubble(GetWebContents(), gfx::Point(),
ZoomBubbleView::USER_GESTURE);
ZoomBubbleView::ShowBubble(GetWebContents(), ZoomBubbleView::USER_GESTURE);
}
views::BubbleDialogDelegateView* ZoomView::GetBubble() const {
......
......@@ -51,7 +51,7 @@ views::Widget* RelaunchRecommendedBubbleView::ShowBubble(
->toolbar_button_provider()
->GetAppMenuButton();
auto* bubble_view = new RelaunchRecommendedBubbleView(
anchor_button, gfx::Point(), detection_time, std::move(on_accept));
anchor_button, detection_time, std::move(on_accept));
bubble_view->SetArrow(views::BubbleBorder::TOP_RIGHT);
#if defined(OS_MACOSX)
......@@ -169,10 +169,9 @@ void RelaunchRecommendedBubbleView::VisibilityChanged(
// title needs to be updated (e.g., from "2 days" to "3 days").
RelaunchRecommendedBubbleView::RelaunchRecommendedBubbleView(
views::Button* anchor_button,
const gfx::Point& anchor_point,
base::Time detection_time,
base::RepeatingClosure on_accept)
: LocationBarBubbleDelegateView(anchor_button, anchor_point, nullptr),
: LocationBarBubbleDelegateView(anchor_button, gfx::Point(), nullptr),
on_accept_(std::move(on_accept)),
body_label_(nullptr),
relaunch_recommended_timer_(
......
......@@ -52,7 +52,6 @@ class RelaunchRecommendedBubbleView : public LocationBarBubbleDelegateView {
private:
RelaunchRecommendedBubbleView(views::Button* anchor_button,
const gfx::Point& anchor_point,
base::Time detection_time,
base::RepeatingClosure on_accept);
......
......@@ -38,10 +38,9 @@ constexpr int kMaximumButtons = 5;
SendTabToSelfBubbleViewImpl::SendTabToSelfBubbleViewImpl(
views::View* anchor_view,
const gfx::Point& anchor_point,
content::WebContents* web_contents,
SendTabToSelfBubbleController* controller)
: LocationBarBubbleDelegateView(anchor_view, anchor_point, web_contents),
: LocationBarBubbleDelegateView(anchor_view, gfx::Point(), web_contents),
web_contents_(web_contents),
controller_(controller) {
DCHECK(controller);
......
......@@ -39,7 +39,6 @@ class SendTabToSelfBubbleViewImpl : public SendTabToSelfBubbleView,
public:
// Bubble will be anchored to |anchor_view|.
SendTabToSelfBubbleViewImpl(views::View* anchor_view,
const gfx::Point& anchor_point,
content::WebContents* web_contents,
SendTabToSelfBubbleController* controller);
......
......@@ -33,11 +33,9 @@ class SendTabToSelfBubbleControllerMock : public SendTabToSelfBubbleController {
class SendTabToSelfBubbleViewImplMock : public SendTabToSelfBubbleViewImpl {
public:
SendTabToSelfBubbleViewImplMock(views::View* anchor_view,
const gfx::Point& anchor_point,
content::WebContents* web_contents,
SendTabToSelfBubbleController* controller)
: SendTabToSelfBubbleViewImpl(anchor_view,
anchor_point,
web_contents,
controller) {}
~SendTabToSelfBubbleViewImplMock() override = default;
......@@ -65,8 +63,7 @@ class SendTabToSelfBubbleViewImplTest : public ChromeViewsTestBase {
profile_.reset(new TestingProfile);
controller_ = std::make_unique<SendTabToSelfBubbleControllerMock>();
bubble_ = std::make_unique<SendTabToSelfBubbleViewImplMock>(
anchor_widget_->GetContentsView(), gfx::Point(), nullptr,
controller_.get());
anchor_widget_->GetContentsView(), nullptr, controller_.get());
}
void TearDown() 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