OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view .h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view .h" |
6 | 6 |
7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 } | 42 } |
43 | 43 |
44 void LocationBarBubbleDelegateView::WebContentMouseHandler::OnTouchEvent( | 44 void LocationBarBubbleDelegateView::WebContentMouseHandler::OnTouchEvent( |
45 ui::TouchEvent* event) { | 45 ui::TouchEvent* event) { |
46 if (event->type() == ui::ET_TOUCH_PRESSED) | 46 if (event->type() == ui::ET_TOUCH_PRESSED) |
47 bubble_->CloseBubble(); | 47 bubble_->CloseBubble(); |
48 } | 48 } |
49 | 49 |
50 LocationBarBubbleDelegateView::LocationBarBubbleDelegateView( | 50 LocationBarBubbleDelegateView::LocationBarBubbleDelegateView( |
51 views::View* anchor_view, | 51 views::View* anchor_view, |
52 const gfx::Point& anchor_point, | |
52 content::WebContents* web_contents) | 53 content::WebContents* web_contents) |
53 : BubbleDialogDelegateView(anchor_view, | 54 : BubbleDialogDelegateView(anchor_view, |
54 anchor_view ? views::BubbleBorder::TOP_RIGHT | 55 anchor_view ? views::BubbleBorder::TOP_RIGHT |
55 : views::BubbleBorder::NONE) { | 56 : views::BubbleBorder::NONE) { |
56 // Add observer to close the bubble if the fullscreen state changes. | 57 // Add observer to close the bubble if the fullscreen state changes. |
57 if (web_contents) { | 58 if (web_contents) { |
58 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 59 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
59 registrar_.Add( | 60 registrar_.Add( |
60 this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, | 61 this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
61 content::Source<FullscreenController>( | 62 content::Source<FullscreenController>( |
62 browser->exclusive_access_manager()->fullscreen_controller())); | 63 browser->exclusive_access_manager()->fullscreen_controller())); |
63 } | 64 } |
65 if (!anchor_view) { | |
66 SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); | |
67 return; | |
tapted
2017/04/19 03:31:06
I think we don't want this early return (i.e. we s
varkha
2017/04/19 08:34:16
Done.
| |
68 } | |
69 | |
64 // Compensate for built-in vertical padding in the anchor view's image. | 70 // Compensate for built-in vertical padding in the anchor view's image. |
65 // In the case of Harmony, this is just compensating for the location bar's | 71 // In the case of Harmony, this is just compensating for the location bar's |
66 // border thickness, as the bubble's top border should overlap it. | 72 // border thickness, as the bubble's top border should overlap it. |
67 set_anchor_view_insets(gfx::Insets( | 73 set_anchor_view_insets(gfx::Insets( |
68 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 74 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
69 } | 75 } |
70 | 76 |
77 LocationBarBubbleDelegateView::LocationBarBubbleDelegateView( | |
78 views::View* anchor_view, | |
79 content::WebContents* web_contents) | |
80 : LocationBarBubbleDelegateView(anchor_view, gfx::Point(), web_contents) {} | |
81 | |
71 LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() {} | 82 LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() {} |
72 | 83 |
73 void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason) { | 84 void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason) { |
74 if (reason == USER_GESTURE) { | 85 if (reason == USER_GESTURE) { |
75 // In the USER_GESTURE case, the icon will be in an active state so the | 86 // In the USER_GESTURE case, the icon will be in an active state so the |
76 // bubble doesn't need an arrow. | 87 // bubble doesn't need an arrow. |
77 SetArrowPaintType(views::BubbleBorder::PAINT_TRANSPARENT); | 88 SetArrowPaintType(views::BubbleBorder::PAINT_TRANSPARENT); |
78 GetWidget()->Show(); | 89 GetWidget()->Show(); |
79 } else { | 90 } else { |
80 GetWidget()->ShowInactive(); | 91 GetWidget()->ShowInactive(); |
(...skipping 22 matching lines...) Expand all Loading... | |
103 if (GetAnchorView()) | 114 if (GetAnchorView()) |
104 return; | 115 return; |
105 | 116 |
106 const int kBubblePaddingFromScreenEdge = 20; | 117 const int kBubblePaddingFromScreenEdge = 20; |
107 int horizontal_offset = width() / 2 + kBubblePaddingFromScreenEdge; | 118 int horizontal_offset = width() / 2 + kBubblePaddingFromScreenEdge; |
108 const int x_pos = base::i18n::IsRTL() | 119 const int x_pos = base::i18n::IsRTL() |
109 ? (screen_bounds.x() + horizontal_offset) | 120 ? (screen_bounds.x() + horizontal_offset) |
110 : (screen_bounds.right() - horizontal_offset); | 121 : (screen_bounds.right() - horizontal_offset); |
111 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); | 122 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); |
112 } | 123 } |
OLD | NEW |