| 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 |
| 64 // Compensate for built-in vertical padding in the anchor view's image. | 68 // 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 | 69 // 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. | 70 // border thickness, as the bubble's top border should overlap it. |
| 71 // When anchor is controlled by the |anchor_point| this inset is ignored. |
| 67 set_anchor_view_insets(gfx::Insets( | 72 set_anchor_view_insets(gfx::Insets( |
| 68 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 73 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
| 69 } | 74 } |
| 70 | 75 |
| 76 LocationBarBubbleDelegateView::LocationBarBubbleDelegateView( |
| 77 views::View* anchor_view, |
| 78 content::WebContents* web_contents) |
| 79 : LocationBarBubbleDelegateView(anchor_view, gfx::Point(), web_contents) {} |
| 80 |
| 71 LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() {} | 81 LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() {} |
| 72 | 82 |
| 73 void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason) { | 83 void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason) { |
| 74 if (reason == USER_GESTURE) { | 84 if (reason == USER_GESTURE) { |
| 75 // In the USER_GESTURE case, the icon will be in an active state so the | 85 // In the USER_GESTURE case, the icon will be in an active state so the |
| 76 // bubble doesn't need an arrow. | 86 // bubble doesn't need an arrow. |
| 77 SetArrowPaintType(views::BubbleBorder::PAINT_TRANSPARENT); | 87 SetArrowPaintType(views::BubbleBorder::PAINT_TRANSPARENT); |
| 78 GetWidget()->Show(); | 88 GetWidget()->Show(); |
| 79 } else { | 89 } else { |
| 80 GetWidget()->ShowInactive(); | 90 GetWidget()->ShowInactive(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 103 if (GetAnchorView()) | 113 if (GetAnchorView()) |
| 104 return; | 114 return; |
| 105 | 115 |
| 106 const int kBubblePaddingFromScreenEdge = 20; | 116 const int kBubblePaddingFromScreenEdge = 20; |
| 107 int horizontal_offset = width() / 2 + kBubblePaddingFromScreenEdge; | 117 int horizontal_offset = width() / 2 + kBubblePaddingFromScreenEdge; |
| 108 const int x_pos = base::i18n::IsRTL() | 118 const int x_pos = base::i18n::IsRTL() |
| 109 ? (screen_bounds.x() + horizontal_offset) | 119 ? (screen_bounds.x() + horizontal_offset) |
| 110 : (screen_bounds.right() - horizontal_offset); | 120 : (screen_bounds.right() - horizontal_offset); |
| 111 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); | 121 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); |
| 112 } | 122 } |
| OLD | NEW |