| 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_page_zoom.h" | 8 #include "chrome/browser/chrome_page_zoom.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 ZoomBubbleView::ZoomBubbleView(views::View* anchor_view, | 98 ZoomBubbleView::ZoomBubbleView(views::View* anchor_view, |
| 99 content::WebContents* web_contents, | 99 content::WebContents* web_contents, |
| 100 bool auto_close, | 100 bool auto_close, |
| 101 FullscreenController* fullscreen_controller) | 101 FullscreenController* fullscreen_controller) |
| 102 : BubbleDelegateView(anchor_view, anchor_view ? | 102 : BubbleDelegateView(anchor_view, anchor_view ? |
| 103 views::BubbleBorder::TOP_RIGHT : views::BubbleBorder::NONE), | 103 views::BubbleBorder::TOP_RIGHT : views::BubbleBorder::NONE), |
| 104 label_(NULL), | 104 label_(NULL), |
| 105 web_contents_(web_contents), | 105 web_contents_(web_contents), |
| 106 auto_close_(auto_close) { | 106 auto_close_(auto_close) { |
| 107 // Compensate for built-in vertical padding in the anchor view's image. | 107 // Compensate for built-in vertical padding in the anchor view's image. |
| 108 set_anchor_insets(gfx::Insets(5, 0, 5, 0)); | 108 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); |
| 109 set_use_focusless(auto_close); | 109 set_use_focusless(auto_close); |
| 110 set_notify_enter_exit_on_child(true); | 110 set_notify_enter_exit_on_child(true); |
| 111 | 111 |
| 112 registrar_.Add(this, | 112 registrar_.Add(this, |
| 113 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | 113 chrome::NOTIFICATION_FULLSCREEN_CHANGED, |
| 114 content::Source<FullscreenController>(fullscreen_controller)); | 114 content::Source<FullscreenController>(fullscreen_controller)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 ZoomBubbleView::~ZoomBubbleView() { | 117 ZoomBubbleView::~ZoomBubbleView() { |
| 118 } | 118 } |
| 119 | 119 |
| 120 void ZoomBubbleView::AdjustForFullscreen(const gfx::Rect& screen_bounds) { | 120 void ZoomBubbleView::AdjustForFullscreen(const gfx::Rect& screen_bounds) { |
| 121 DCHECK(!anchor_view()); | 121 DCHECK(!anchor_view()); |
| 122 | 122 |
| 123 // TODO(dbeam): should RTL logic be done in views::BubbleDelegateView? | 123 // TODO(dbeam): should RTL logic be done in views::BubbleDelegateView? |
| 124 const size_t bubble_half_width = width() / 2; | 124 const size_t bubble_half_width = width() / 2; |
| 125 const int x_pos = base::i18n::IsRTL() ? | 125 const int x_pos = base::i18n::IsRTL() ? |
| 126 screen_bounds.x() + bubble_half_width + kFullscreenPaddingEnd : | 126 screen_bounds.x() + bubble_half_width + kFullscreenPaddingEnd : |
| 127 screen_bounds.right() - bubble_half_width - kFullscreenPaddingEnd; | 127 screen_bounds.right() - bubble_half_width - kFullscreenPaddingEnd; |
| 128 set_anchor_point(gfx::Point(x_pos, screen_bounds.y())); | 128 set_anchor_rect(gfx::Rect(x_pos, screen_bounds.y(), 0, 0)); |
| 129 | 129 |
| 130 // Used to update |views::BubbleDelegate::anchor_point_| in a semi-hacky way. | 130 // Used to update |views::BubbleDelegate::anchor_rect_| in a semi-hacky way. |
| 131 // TODO(dbeam): update only the bounds of this view or its border or frame. | 131 // TODO(dbeam): update only the bounds of this view or its border or frame. |
| 132 SizeToContents(); | 132 SizeToContents(); |
| 133 } | 133 } |
| 134 | 134 |
| 135 void ZoomBubbleView::Refresh() { | 135 void ZoomBubbleView::Refresh() { |
| 136 ZoomController* zoom_controller = | 136 ZoomController* zoom_controller = |
| 137 ZoomController::FromWebContents(web_contents_); | 137 ZoomController::FromWebContents(web_contents_); |
| 138 int zoom_percent = zoom_controller->zoom_percent(); | 138 int zoom_percent = zoom_controller->zoom_percent(); |
| 139 label_->SetText( | 139 label_->SetText( |
| 140 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); | 140 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); | 215 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); |
| 216 CloseBubble(); | 216 CloseBubble(); |
| 217 } | 217 } |
| 218 | 218 |
| 219 void ZoomBubbleView::WindowClosing() { | 219 void ZoomBubbleView::WindowClosing() { |
| 220 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't | 220 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't |
| 221 // call this right away). Only set to NULL when it's this bubble. | 221 // call this right away). Only set to NULL when it's this bubble. |
| 222 if (zoom_bubble_ == this) | 222 if (zoom_bubble_ == this) |
| 223 zoom_bubble_ = NULL; | 223 zoom_bubble_ = NULL; |
| 224 } | 224 } |
| OLD | NEW |