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" |
| 11 #include "content/public/browser/notification_source.h" | 11 #include "content/public/browser/notification_source.h" |
| 12 #include "ui/base/material_design/material_design_controller.h" | |
| 12 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
| 13 | 14 |
| 14 LocationBarBubbleDelegateView::LocationBarBubbleDelegateView( | 15 LocationBarBubbleDelegateView::LocationBarBubbleDelegateView( |
| 15 views::View* anchor_view, | 16 views::View* anchor_view, |
| 16 content::WebContents* web_contents) | 17 content::WebContents* web_contents) |
| 17 : BubbleDelegateView(anchor_view, | 18 : BubbleDelegateView(anchor_view, |
| 18 anchor_view ? views::BubbleBorder::TOP_RIGHT | 19 anchor_view ? views::BubbleBorder::TOP_RIGHT |
| 19 : views::BubbleBorder::NONE) { | 20 : views::BubbleBorder::NONE) { |
| 20 // Add observer to close the bubble if the fullscreen state changes. | 21 // Add observer to close the bubble if the fullscreen state changes. |
| 21 if (web_contents) { | 22 if (web_contents) { |
| 22 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 23 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| 23 registrar_.Add( | 24 registrar_.Add( |
| 24 this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, | 25 this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
| 25 content::Source<FullscreenController>( | 26 content::Source<FullscreenController>( |
| 26 browser->exclusive_access_manager()->fullscreen_controller())); | 27 browser->exclusive_access_manager()->fullscreen_controller())); |
| 27 } | 28 } |
| 28 } | 29 } |
| 29 | 30 |
| 30 LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() {} | 31 LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() {} |
| 31 | 32 |
| 32 void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason) { | 33 void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason) { |
| 33 if (reason == USER_GESTURE) { | 34 if (reason == USER_GESTURE) { |
| 34 // TODO(estade): re-enable this when crbug.com/518941 is fixed. | 35 if (ui::MaterialDesignController::IsModeMaterial()) |
|
Peter Kasting
2016/03/03 20:43:28
Nit: I'd add a comment here, e.g. "Gesture-trigger
Evan Stade
2016/03/03 21:07:59
Done.
| |
| 35 // SetArrowPaintType(views::BubbleBorder::PAINT_TRANSPARENT); | 36 SetArrowPaintType(views::BubbleBorder::PAINT_TRANSPARENT); |
| 36 GetWidget()->Show(); | 37 GetWidget()->Show(); |
| 37 } else { | 38 } else { |
| 38 GetWidget()->ShowInactive(); | 39 GetWidget()->ShowInactive(); |
| 39 } | 40 } |
| 40 } | 41 } |
| 41 | 42 |
| 42 void LocationBarBubbleDelegateView::Observe( | 43 void LocationBarBubbleDelegateView::Observe( |
| 43 int type, | 44 int type, |
| 44 const content::NotificationSource& source, | 45 const content::NotificationSource& source, |
| 45 const content::NotificationDetails& details) { | 46 const content::NotificationDetails& details) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 59 if (GetAnchorView()) | 60 if (GetAnchorView()) |
| 60 return; | 61 return; |
| 61 | 62 |
| 62 const int kBubblePaddingFromScreenEdge = 20; | 63 const int kBubblePaddingFromScreenEdge = 20; |
| 63 int horizontal_offset = width() / 2 + kBubblePaddingFromScreenEdge; | 64 int horizontal_offset = width() / 2 + kBubblePaddingFromScreenEdge; |
| 64 const int x_pos = base::i18n::IsRTL() | 65 const int x_pos = base::i18n::IsRTL() |
| 65 ? (screen_bounds.x() + horizontal_offset) | 66 ? (screen_bounds.x() + horizontal_offset) |
| 66 : (screen_bounds.right() - horizontal_offset); | 67 : (screen_bounds.right() - horizontal_offset); |
| 67 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); | 68 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); |
| 68 } | 69 } |
| OLD | NEW |