Chromium Code Reviews| 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, | |
| 53 views::BubbleBorder::Arrow arrow, | |
| 52 content::WebContents* web_contents) | 54 content::WebContents* web_contents) |
| 53 : BubbleDialogDelegateView(anchor_view, | 55 : BubbleDialogDelegateView( |
| 54 anchor_view ? views::BubbleBorder::TOP_RIGHT | 56 anchor_view, |
| 55 : views::BubbleBorder::NONE) { | 57 anchor_view ? views::BubbleBorder::TOP_RIGHT : arrow) { |
| 56 // Add observer to close the bubble if the fullscreen state changes. | 58 // Add observer to close the bubble if the fullscreen state changes. |
| 57 if (web_contents) { | 59 if (web_contents) { |
| 58 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 60 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| 59 registrar_.Add( | 61 registrar_.Add( |
| 60 this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, | 62 this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
| 61 content::Source<FullscreenController>( | 63 content::Source<FullscreenController>( |
| 62 browser->exclusive_access_manager()->fullscreen_controller())); | 64 browser->exclusive_access_manager()->fullscreen_controller())); |
| 63 } | 65 } |
| 66 if (!anchor_view) { | |
| 67 SetAnchorRect(gfx::Rect(anchor_point, gfx::Size())); | |
| 68 return; | |
| 69 } | |
| 70 | |
| 64 // Compensate for built-in vertical padding in the anchor view's image. | 71 // 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 | 72 // 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. | 73 // border thickness, as the bubble's top border should overlap it. |
| 67 set_anchor_view_insets(gfx::Insets( | 74 set_anchor_view_insets(gfx::Insets( |
| 68 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 75 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
| 69 } | 76 } |
| 70 | 77 |
| 78 LocationBarBubbleDelegateView::LocationBarBubbleDelegateView( | |
| 79 views::View* anchor_view, | |
| 80 content::WebContents* web_contents) | |
| 81 : BubbleDialogDelegateView(anchor_view, | |
| 82 anchor_view ? views::BubbleBorder::TOP_RIGHT | |
| 83 : views::BubbleBorder::NONE) { | |
| 84 LocationBarBubbleDelegateView(anchor_view, gfx::Point(), | |
|
tapted
2017/04/11 07:48:58
this looks odd - is this just creating a temporary
varkha
2017/04/12 01:57:28
Yes, not really sure what I thought I was doing he
| |
| 85 views::BubbleBorder::NONE, web_contents); | |
| 86 } | |
| 87 | |
| 71 LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() {} | 88 LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() {} |
| 72 | 89 |
| 73 void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason) { | 90 void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason) { |
| 74 if (reason == USER_GESTURE) { | 91 if (reason == USER_GESTURE) { |
| 75 // In the USER_GESTURE case, the icon will be in an active state so the | 92 // In the USER_GESTURE case, the icon will be in an active state so the |
| 76 // bubble doesn't need an arrow. | 93 // bubble doesn't need an arrow. |
| 77 SetArrowPaintType(views::BubbleBorder::PAINT_TRANSPARENT); | 94 SetArrowPaintType(views::BubbleBorder::PAINT_TRANSPARENT); |
| 78 GetWidget()->Show(); | 95 GetWidget()->Show(); |
| 79 } else { | 96 } else { |
| 80 GetWidget()->ShowInactive(); | 97 GetWidget()->ShowInactive(); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 103 if (GetAnchorView()) | 120 if (GetAnchorView()) |
| 104 return; | 121 return; |
| 105 | 122 |
| 106 const int kBubblePaddingFromScreenEdge = 20; | 123 const int kBubblePaddingFromScreenEdge = 20; |
| 107 int horizontal_offset = width() / 2 + kBubblePaddingFromScreenEdge; | 124 int horizontal_offset = width() / 2 + kBubblePaddingFromScreenEdge; |
| 108 const int x_pos = base::i18n::IsRTL() | 125 const int x_pos = base::i18n::IsRTL() |
| 109 ? (screen_bounds.x() + horizontal_offset) | 126 ? (screen_bounds.x() + horizontal_offset) |
| 110 : (screen_bounds.right() - horizontal_offset); | 127 : (screen_bounds.right() - horizontal_offset); |
| 111 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); | 128 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); |
| 112 } | 129 } |
| OLD | NEW |