Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/views/managed_full_screen_bubble_delegate_view.h" | |
| 6 | |
| 7 #include "chrome/browser/chrome_notification_types.h" | |
| 8 #include "chrome/browser/ui/browser.h" | |
| 9 #include "chrome/browser/ui/browser_finder.h" | |
| 10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | |
| 11 #include "content/public/browser/notification_source.h" | |
| 12 #include "ui/gfx/geometry/rect.h" | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 // The bubble's padding from the screen edge, used in fullscreen. | |
| 17 const int kFullscreenPaddingEnd = 20; | |
|
Peter Kasting
2014/12/19 22:11:35
Nit: Declare this in the lone function where it's
Pritam Nikam
2014/12/22 08:19:09
Done.
| |
| 18 | |
| 19 } // namespace | |
| 20 | |
| 21 ManagedFullScreenBubbleDelegateView::ManagedFullScreenBubbleDelegateView( | |
| 22 views::View* anchor_view, | |
| 23 content::WebContents* web_contents) | |
| 24 : BubbleDelegateView(anchor_view, | |
| 25 (anchor_view ? views::BubbleBorder::TOP_RIGHT | |
| 26 : views::BubbleBorder::NONE)) { | |
|
Peter Kasting
2014/12/19 22:11:35
Nit: Wrap like:
: BubbleDelegateView(
Pritam Nikam
2014/12/22 08:19:09
Done.
| |
| 27 // Add observer to close the bubble if the fullscreen state changes. | |
| 28 if (web_contents) { | |
| 29 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | |
| 30 registrar_.Add(this, chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
| 31 content::Source<FullscreenController>( | |
| 32 browser->fullscreen_controller())); | |
| 33 } | |
| 34 } | |
| 35 | |
| 36 ManagedFullScreenBubbleDelegateView::~ManagedFullScreenBubbleDelegateView() { | |
| 37 } | |
| 38 | |
| 39 void ManagedFullScreenBubbleDelegateView::Observe( | |
| 40 int type, | |
| 41 const content::NotificationSource& source, | |
| 42 const content::NotificationDetails& details) { | |
| 43 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); | |
|
Peter Kasting
2014/12/19 22:11:35
Nit: (expected, actual)
Pritam Nikam
2014/12/22 08:19:10
Done.
| |
| 44 GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE); | |
| 45 Close(); | |
| 46 } | |
| 47 | |
| 48 void ManagedFullScreenBubbleDelegateView::AdjustForFullscreen( | |
| 49 const gfx::Rect& screen_bounds) { | |
| 50 if (GetAnchorView()) | |
| 51 return; | |
| 52 | |
| 53 const int bubble_half_width = width() / 2; | |
|
Peter Kasting
2014/12/19 22:11:35
Nit: While I'm fine with them, most Chromium code
Pritam Nikam
2014/12/22 08:19:09
Done.
| |
| 54 const int x_pos = | |
| 55 (base::i18n::IsRTL() | |
|
Peter Kasting
2014/12/19 22:11:35
Nit: Don't parenthesize entire RHS.
Pritam Nikam
2014/12/22 08:19:09
Done.
| |
| 56 ? (screen_bounds.x() + bubble_half_width + kFullscreenPaddingEnd) | |
| 57 : (screen_bounds.right() - bubble_half_width - | |
| 58 kFullscreenPaddingEnd)); | |
|
Peter Kasting
2014/12/19 22:11:35
Nit: Wrap like:
const int x_pos = base::i18n::I
Pritam Nikam
2014/12/22 08:19:09
Done.
| |
| 59 SetAnchorRect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); | |
| 60 } | |
| 61 | |
| 62 void ManagedFullScreenBubbleDelegateView::Close() { | |
| 63 GetWidget()->Close(); | |
| 64 } | |
| OLD | NEW |