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