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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 anchor_view ? views::BubbleBorder::TOP_RIGHT | 54 anchor_view ? views::BubbleBorder::TOP_RIGHT |
| 55 : views::BubbleBorder::NONE) { | 55 : views::BubbleBorder::NONE) { |
| 56 // Add observer to close the bubble if the fullscreen state changes. | 56 // Add observer to close the bubble if the fullscreen state changes. |
| 57 if (web_contents) { | 57 if (web_contents) { |
| 58 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 58 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| 59 registrar_.Add( | 59 registrar_.Add( |
| 60 this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, | 60 this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
| 61 content::Source<FullscreenController>( | 61 content::Source<FullscreenController>( |
| 62 browser->exclusive_access_manager()->fullscreen_controller())); | 62 browser->exclusive_access_manager()->fullscreen_controller())); |
| 63 } | 63 } |
| 64 // Compensate for built-in vertical padding in the anchor view's image. | 64 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) { |
| 65 set_anchor_view_insets(gfx::Insets( | 65 // The anchor is the location bar. The bubble's 1px border should overlap |
| 66 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 66 // the location bar's 1px border. |
| 67 set_anchor_view_insets(gfx::Insets(0, 0, 1, 0)); | |
|
msw
2016/10/07 22:13:53
Does this look right when the bubble is flipped ve
| |
| 68 } else { | |
| 69 // Compensate for built-in vertical padding in the anchor view's image. | |
| 70 set_anchor_view_insets(gfx::Insets( | |
| 71 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | |
| 72 } | |
| 67 } | 73 } |
| 68 | 74 |
| 69 LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() {} | 75 LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() {} |
| 70 | 76 |
| 71 void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason) { | 77 void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason) { |
| 72 if (reason == USER_GESTURE) { | 78 if (reason == USER_GESTURE) { |
| 73 // In the USER_GESTURE case, the icon will be in an active state so the | 79 // In the USER_GESTURE case, the icon will be in an active state so the |
| 74 // bubble doesn't need an arrow. | 80 // bubble doesn't need an arrow. |
| 75 if (ui::MaterialDesignController::IsModeMaterial()) | 81 if (ui::MaterialDesignController::IsModeMaterial()) |
| 76 SetArrowPaintType(views::BubbleBorder::PAINT_TRANSPARENT); | 82 SetArrowPaintType(views::BubbleBorder::PAINT_TRANSPARENT); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 102 if (GetAnchorView()) | 108 if (GetAnchorView()) |
| 103 return; | 109 return; |
| 104 | 110 |
| 105 const int kBubblePaddingFromScreenEdge = 20; | 111 const int kBubblePaddingFromScreenEdge = 20; |
| 106 int horizontal_offset = width() / 2 + kBubblePaddingFromScreenEdge; | 112 int horizontal_offset = width() / 2 + kBubblePaddingFromScreenEdge; |
| 107 const int x_pos = base::i18n::IsRTL() | 113 const int x_pos = base::i18n::IsRTL() |
| 108 ? (screen_bounds.x() + horizontal_offset) | 114 ? (screen_bounds.x() + horizontal_offset) |
| 109 : (screen_bounds.right() - horizontal_offset); | 115 : (screen_bounds.right() - horizontal_offset); |
| 110 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); | 116 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); |
| 111 } | 117 } |
| OLD | NEW |