Index: chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc |
diff --git a/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc b/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc |
index 27543b4e2af1d075ea2066b1c7d8963483d8bd2a..8d344fe47de871e45cfdc9a03fe2dfe3d1928976 100644 |
--- a/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc |
+++ b/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc |
@@ -49,23 +49,23 @@ void LocationBarBubbleDelegateView::WebContentMouseHandler::OnTouchEvent( |
LocationBarBubbleDelegateView::LocationBarBubbleDelegateView( |
views::View* anchor_view, |
+ const gfx::Point& anchor_point, |
+ views::BubbleBorder::Arrow arrow, |
+ content::WebContents* web_contents) |
+ : BubbleDialogDelegateView( |
+ anchor_view, |
+ anchor_view ? views::BubbleBorder::TOP_RIGHT : arrow) { |
+ SetupAnchor(anchor_view, anchor_point, arrow, web_contents); |
+} |
+ |
+LocationBarBubbleDelegateView::LocationBarBubbleDelegateView( |
+ views::View* anchor_view, |
content::WebContents* web_contents) |
: BubbleDialogDelegateView(anchor_view, |
tapted
2017/04/12 05:08:42
Can the overload just delegate to the other constr
varkha
2017/04/12 09:16:43
Done.
|
anchor_view ? views::BubbleBorder::TOP_RIGHT |
: views::BubbleBorder::NONE) { |
- // Add observer to close the bubble if the fullscreen state changes. |
- if (web_contents) { |
- Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
- registrar_.Add( |
- this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
- content::Source<FullscreenController>( |
- browser->exclusive_access_manager()->fullscreen_controller())); |
- } |
- // Compensate for built-in vertical padding in the anchor view's image. |
- // In the case of Harmony, this is just compensating for the location bar's |
- // border thickness, as the bubble's top border should overlap it. |
- set_anchor_view_insets(gfx::Insets( |
- GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
+ SetupAnchor(anchor_view, gfx::Point(), views::BubbleBorder::NONE, |
+ web_contents); |
} |
LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() {} |
@@ -94,6 +94,31 @@ void LocationBarBubbleDelegateView::Observe( |
CloseBubble(); |
} |
+void LocationBarBubbleDelegateView::SetupAnchor( |
+ views::View* anchor_view, |
+ const gfx::Point& anchor_point, |
+ views::BubbleBorder::Arrow arrow, |
+ content::WebContents* web_contents) { |
+ // Add observer to close the bubble if the fullscreen state changes. |
+ if (web_contents) { |
+ Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
+ registrar_.Add( |
+ this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
+ content::Source<FullscreenController>( |
+ browser->exclusive_access_manager()->fullscreen_controller())); |
+ } |
+ if (!anchor_view) { |
+ SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); |
+ return; |
+ } |
+ |
+ // Compensate for built-in vertical padding in the anchor view's image. |
+ // In the case of Harmony, this is just compensating for the location bar's |
+ // border thickness, as the bubble's top border should overlap it. |
+ set_anchor_view_insets(gfx::Insets( |
+ GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
+} |
+ |
void LocationBarBubbleDelegateView::CloseBubble() { |
GetWidget()->Close(); |
} |