OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/zoom_bubble_view.h" | 5 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/chrome_page_zoom.h" | 9 #include "chrome/browser/chrome_page_zoom.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 bool is_fullscreen = browser_view->IsFullscreen(); | 49 bool is_fullscreen = browser_view->IsFullscreen(); |
50 bool anchor_to_view = !is_fullscreen || | 50 bool anchor_to_view = !is_fullscreen || |
51 browser_view->immersive_mode_controller()->IsRevealed(); | 51 browser_view->immersive_mode_controller()->IsRevealed(); |
52 views::View* anchor_view = anchor_to_view ? | 52 views::View* anchor_view = anchor_to_view ? |
53 browser_view->GetLocationBarView()->zoom_view() : NULL; | 53 browser_view->GetLocationBarView()->zoom_view() : NULL; |
54 | 54 |
55 // If the bubble is already showing in this window and its |auto_close_| value | 55 // If the bubble is already showing in this window and its |auto_close_| value |
56 // is equal to |auto_close|, the bubble can be reused and only the label text | 56 // is equal to |auto_close|, the bubble can be reused and only the label text |
57 // needs to be updated. | 57 // needs to be updated. |
58 if (zoom_bubble_ && | 58 if (zoom_bubble_ && |
59 zoom_bubble_->anchor_view() == anchor_view && | 59 zoom_bubble_->GetAnchorView() == anchor_view && |
60 zoom_bubble_->auto_close_ == auto_close) { | 60 zoom_bubble_->auto_close_ == auto_close) { |
61 zoom_bubble_->Refresh(); | 61 zoom_bubble_->Refresh(); |
62 } else { | 62 } else { |
63 // If the bubble is already showing but its |auto_close_| value is not equal | 63 // If the bubble is already showing but its |auto_close_| value is not equal |
64 // to |auto_close|, the bubble's focus properties must change, so the | 64 // to |auto_close|, the bubble's focus properties must change, so the |
65 // current bubble must be closed and a new one created. | 65 // current bubble must be closed and a new one created. |
66 CloseBubble(); | 66 CloseBubble(); |
67 | 67 |
68 zoom_bubble_ = new ZoomBubbleView(anchor_view, | 68 zoom_bubble_ = new ZoomBubbleView(anchor_view, |
69 web_contents, | 69 web_contents, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 content::Source<FullscreenController>(fullscreen_controller)); | 128 content::Source<FullscreenController>(fullscreen_controller)); |
129 immersive_mode_controller_->AddObserver(this); | 129 immersive_mode_controller_->AddObserver(this); |
130 } | 130 } |
131 | 131 |
132 ZoomBubbleView::~ZoomBubbleView() { | 132 ZoomBubbleView::~ZoomBubbleView() { |
133 if (immersive_mode_controller_) | 133 if (immersive_mode_controller_) |
134 immersive_mode_controller_->RemoveObserver(this); | 134 immersive_mode_controller_->RemoveObserver(this); |
135 } | 135 } |
136 | 136 |
137 void ZoomBubbleView::AdjustForFullscreen(const gfx::Rect& screen_bounds) { | 137 void ZoomBubbleView::AdjustForFullscreen(const gfx::Rect& screen_bounds) { |
138 if (anchor_view()) | 138 if (GetAnchorView()) |
139 return; | 139 return; |
140 | 140 |
141 // TODO(dbeam): should RTL logic be done in views::BubbleDelegateView? | 141 // TODO(dbeam): should RTL logic be done in views::BubbleDelegateView? |
142 const size_t bubble_half_width = width() / 2; | 142 const size_t bubble_half_width = width() / 2; |
143 const int x_pos = base::i18n::IsRTL() ? | 143 const int x_pos = base::i18n::IsRTL() ? |
144 screen_bounds.x() + bubble_half_width + kFullscreenPaddingEnd : | 144 screen_bounds.x() + bubble_half_width + kFullscreenPaddingEnd : |
145 screen_bounds.right() - bubble_half_width - kFullscreenPaddingEnd; | 145 screen_bounds.right() - bubble_half_width - kFullscreenPaddingEnd; |
146 set_anchor_rect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); | 146 set_anchor_rect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); |
147 | 147 |
148 // Used to update |views::BubbleDelegate::anchor_rect_| in a semi-hacky way. | 148 // Used to update |views::BubbleDelegate::anchor_rect_| in a semi-hacky way. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 void ZoomBubbleView::OnImmersiveModeControllerDestroyed() { | 242 void ZoomBubbleView::OnImmersiveModeControllerDestroyed() { |
243 immersive_mode_controller_ = NULL; | 243 immersive_mode_controller_ = NULL; |
244 } | 244 } |
245 | 245 |
246 void ZoomBubbleView::WindowClosing() { | 246 void ZoomBubbleView::WindowClosing() { |
247 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't | 247 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't |
248 // call this right away). Only set to NULL when it's this bubble. | 248 // call this right away). Only set to NULL when it's this bubble. |
249 if (zoom_bubble_ == this) | 249 if (zoom_bubble_ == this) |
250 zoom_bubble_ = NULL; | 250 zoom_bubble_ = NULL; |
251 } | 251 } |
OLD | NEW |