Index: chrome/browser/ui/views/location_bar/zoom_bubble_view.cc |
diff --git a/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc b/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc |
index 7301f6de7cf80eb251c62062e818baa265970edb..2575c79f49b5f4e13d8bc70ecdc39243d5a03d48 100644 |
--- a/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc |
+++ b/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc |
@@ -47,8 +47,10 @@ void ZoomBubbleView::ShowBubble(content::WebContents* web_contents, |
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
bool is_fullscreen = browser->window()->IsFullscreen(); |
- views::View* anchor_view = is_fullscreen ? |
- NULL : browser_view->GetLocationBarView()->zoom_view(); |
+ bool anchor_to_view = !is_fullscreen || |
+ browser_view->immersive_mode_controller()->IsRevealed(); |
+ views::View* anchor_view = anchor_to_view ? |
+ browser_view->GetLocationBarView()->zoom_view() : NULL; |
// If the bubble is already showing in this window and its |auto_close_| value |
// is equal to |auto_close|, the bubble can be reused and only the label text |
@@ -63,14 +65,11 @@ void ZoomBubbleView::ShowBubble(content::WebContents* web_contents, |
// current bubble must be closed and a new one created. |
CloseBubble(); |
- zoom_bubble_ = new ZoomBubbleView(anchor_view, |
- web_contents, |
- auto_close, |
- browser->fullscreen_controller()); |
+ zoom_bubble_ = new ZoomBubbleView(anchor_view, web_contents, auto_close, |
+ browser_view); |
- // If we're fullscreen, there is no anchor view, so parent the bubble to |
- // the content area. |
- if (is_fullscreen) { |
+ // If we do not have an anchor view, parent the bubble to the content area. |
+ if (!anchor_to_view) { |
zoom_bubble_->set_parent_window( |
web_contents->GetView()->GetTopLevelNativeWindow()); |
} |
@@ -99,7 +98,7 @@ bool ZoomBubbleView::IsShowing() { |
ZoomBubbleView::ZoomBubbleView(views::View* anchor_view, |
content::WebContents* web_contents, |
bool auto_close, |
- FullscreenController* fullscreen_controller) |
+ BrowserView* browser_view) |
James Cook
2013/06/17 16:13:41
Can you just pass in immersive mode controller (an
|
: BubbleDelegateView(anchor_view, anchor_view ? |
views::BubbleBorder::TOP_RIGHT : views::BubbleBorder::NONE), |
label_(NULL), |
@@ -110,16 +109,36 @@ ZoomBubbleView::ZoomBubbleView(views::View* anchor_view, |
set_use_focusless(auto_close); |
set_notify_enter_exit_on_child(true); |
+ ImmersiveModeController* immersive_controller = |
+ browser_view->immersive_mode_controller(); |
+ if (anchor_view) { |
+ // If we are in immersive fullscreen and the top-of-window views are |
+ // already revealed, lock the top-of-window views in the revealed state |
+ // as long as the zoom bubble is visible. ImmersiveModeController does |
+ // not do this for us automatically because the zoom bubble is not |
+ // activatable. |
+ immersive_reveal_lock_.reset(immersive_controller->GetRevealedLock( |
+ ImmersiveModeController::ANIMATE_REVEAL_NO)); |
+ } |
+ |
+ // Add observers to close the bubble if the fullscreen state or immersive |
+ // fullscreen revealed state changes. |
registrar_.Add(this, |
chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
- content::Source<FullscreenController>(fullscreen_controller)); |
+ content::Source<FullscreenController>( |
+ browser_view->browser()->fullscreen_controller())); |
+ immersive_controller->AddObserver(this); |
} |
ZoomBubbleView::~ZoomBubbleView() { |
+ Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); |
+ BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); |
+ browser_view->immersive_mode_controller()->RemoveObserver(this); |
} |
void ZoomBubbleView::AdjustForFullscreen(const gfx::Rect& screen_bounds) { |
- DCHECK(!anchor_view()); |
+ if (anchor_view()) |
+ return; |
// TODO(dbeam): should RTL logic be done in views::BubbleDelegateView? |
const size_t bubble_half_width = width() / 2; |
@@ -218,6 +237,10 @@ void ZoomBubbleView::Observe(int type, |
CloseBubble(); |
} |
+void ZoomBubbleView::OnStartedImmersiveReveal() { |
+ CloseBubble(); |
+} |
+ |
void ZoomBubbleView::WindowClosing() { |
// |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't |
// call this right away). Only set to NULL when it's this bubble. |