Chromium Code Reviews| 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 "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/chrome_page_zoom.h" | 10 #include "chrome/browser/chrome_page_zoom.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 const ZoomBubbleView* ZoomBubbleView::GetZoomBubbleForTest() { | 124 const ZoomBubbleView* ZoomBubbleView::GetZoomBubbleForTest() { |
| 125 return zoom_bubble_; | 125 return zoom_bubble_; |
| 126 } | 126 } |
| 127 | 127 |
| 128 ZoomBubbleView::ZoomBubbleView( | 128 ZoomBubbleView::ZoomBubbleView( |
| 129 views::View* anchor_view, | 129 views::View* anchor_view, |
| 130 content::WebContents* web_contents, | 130 content::WebContents* web_contents, |
| 131 bool auto_close, | 131 bool auto_close, |
| 132 ImmersiveModeController* immersive_mode_controller, | 132 ImmersiveModeController* immersive_mode_controller, |
| 133 FullscreenController* fullscreen_controller) | 133 FullscreenController* fullscreen_controller) |
| 134 : BubbleDelegateView(anchor_view, anchor_view ? | 134 : ManagedFullScreenBubbleDelegateView(anchor_view, web_contents), |
| 135 views::BubbleBorder::TOP_RIGHT : views::BubbleBorder::NONE), | |
| 136 image_button_(NULL), | 135 image_button_(NULL), |
| 137 label_(NULL), | 136 label_(NULL), |
| 138 web_contents_(web_contents), | 137 web_contents_(web_contents), |
| 139 auto_close_(auto_close), | 138 auto_close_(auto_close), |
| 140 immersive_mode_controller_(immersive_mode_controller) { | 139 immersive_mode_controller_(immersive_mode_controller) { |
| 141 // Compensate for built-in vertical padding in the anchor view's image. | 140 // Compensate for built-in vertical padding in the anchor view's image. |
| 142 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); | 141 set_anchor_view_insets(gfx::Insets(5, 0, 5, 0)); |
| 143 set_notify_enter_exit_on_child(true); | 142 set_notify_enter_exit_on_child(true); |
| 144 | 143 |
| 145 // Add observers to close the bubble if the fullscreen state or immersive | 144 // Add observers immersive fullscreen revealed state changes. |
|
vasilii
2014/12/17 13:40:11
nit: grammar.
Pritam Nikam
2014/12/17 16:06:26
Done.
| |
| 146 // fullscreen revealed state changes. | |
| 147 registrar_.Add(this, | |
| 148 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
| 149 content::Source<FullscreenController>(fullscreen_controller)); | |
| 150 immersive_mode_controller_->AddObserver(this); | 145 immersive_mode_controller_->AddObserver(this); |
| 151 } | 146 } |
| 152 | 147 |
| 153 ZoomBubbleView::~ZoomBubbleView() { | 148 ZoomBubbleView::~ZoomBubbleView() { |
| 154 if (immersive_mode_controller_) | 149 if (immersive_mode_controller_) |
| 155 immersive_mode_controller_->RemoveObserver(this); | 150 immersive_mode_controller_->RemoveObserver(this); |
| 156 } | 151 } |
| 157 | 152 |
| 158 void ZoomBubbleView::AdjustForFullscreen(const gfx::Rect& screen_bounds) { | 153 void ZoomBubbleView::AdjustForFullscreen(const gfx::Rect& screen_bounds) { |
| 159 if (GetAnchorView()) | 154 if (GetAnchorView()) |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 } | 283 } |
| 289 | 284 |
| 290 void ZoomBubbleView::Init() { | 285 void ZoomBubbleView::Init() { |
| 291 // Set up the layout of the zoom bubble. A grid layout is used because | 286 // Set up the layout of the zoom bubble. A grid layout is used because |
| 292 // sometimes an extension icon is shown next to the zoom label. | 287 // sometimes an extension icon is shown next to the zoom label. |
| 293 views::GridLayout* grid_layout = new views::GridLayout(this); | 288 views::GridLayout* grid_layout = new views::GridLayout(this); |
| 294 SetLayoutManager(grid_layout); | 289 SetLayoutManager(grid_layout); |
| 295 views::ColumnSet* columns = grid_layout->AddColumnSet(0); | 290 views::ColumnSet* columns = grid_layout->AddColumnSet(0); |
| 296 // First row. | 291 // First row. |
| 297 if (extension_info_.icon_image) { | 292 if (extension_info_.icon_image) { |
| 298 columns->AddColumn(views::GridLayout::CENTER,views::GridLayout::CENTER, 2, | 293 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, 2, |
| 299 views::GridLayout::USE_PREF, 0, 0); | 294 views::GridLayout::USE_PREF, 0, 0); |
| 300 } | 295 } |
| 301 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | 296 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
| 302 views::GridLayout::USE_PREF, 0, 0); | 297 views::GridLayout::USE_PREF, 0, 0); |
| 303 grid_layout->StartRow(0, 0); | 298 grid_layout->StartRow(0, 0); |
| 304 | 299 |
| 305 // If this zoom change was initiated by an extension, that extension will be | 300 // If this zoom change was initiated by an extension, that extension will be |
| 306 // attributed by showing its icon in the zoom bubble. | 301 // attributed by showing its icon in the zoom bubble. |
| 307 if (extension_info_.icon_image) { | 302 if (extension_info_.icon_image) { |
| 308 image_button_ = new views::ImageButton(this); | 303 image_button_ = new views::ImageButton(this); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 335 // Add "Reset to Default" button. | 330 // Add "Reset to Default" button. |
| 336 views::LabelButton* set_default_button = new views::LabelButton( | 331 views::LabelButton* set_default_button = new views::LabelButton( |
| 337 this, l10n_util::GetStringUTF16(IDS_ZOOM_SET_DEFAULT)); | 332 this, l10n_util::GetStringUTF16(IDS_ZOOM_SET_DEFAULT)); |
| 338 set_default_button->SetStyle(views::Button::STYLE_BUTTON); | 333 set_default_button->SetStyle(views::Button::STYLE_BUTTON); |
| 339 set_default_button->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 334 set_default_button->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 340 grid_layout->AddView(set_default_button); | 335 grid_layout->AddView(set_default_button); |
| 341 | 336 |
| 342 StartTimerIfNecessary(); | 337 StartTimerIfNecessary(); |
| 343 } | 338 } |
| 344 | 339 |
| 345 void ZoomBubbleView::Observe(int type, | |
| 346 const content::NotificationSource& source, | |
| 347 const content::NotificationDetails& details) { | |
| 348 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); | |
| 349 CloseBubble(); | |
| 350 } | |
| 351 | |
| 352 void ZoomBubbleView::OnImmersiveRevealStarted() { | 340 void ZoomBubbleView::OnImmersiveRevealStarted() { |
| 353 CloseBubble(); | 341 CloseBubble(); |
| 354 } | 342 } |
| 355 | 343 |
| 356 void ZoomBubbleView::OnImmersiveModeControllerDestroyed() { | 344 void ZoomBubbleView::OnImmersiveModeControllerDestroyed() { |
| 357 immersive_mode_controller_ = NULL; | 345 immersive_mode_controller_ = NULL; |
| 358 } | 346 } |
| 359 | 347 |
| 360 void ZoomBubbleView::WindowClosing() { | 348 void ZoomBubbleView::WindowClosing() { |
| 361 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't | 349 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't |
| 362 // call this right away). Only set to NULL when it's this bubble. | 350 // call this right away). Only set to NULL when it's this bubble. |
| 363 if (zoom_bubble_ == this) | 351 if (zoom_bubble_ == this) |
| 364 zoom_bubble_ = NULL; | 352 zoom_bubble_ = NULL; |
| 365 } | 353 } |
| 366 | 354 |
| 367 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} | 355 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} |
| 368 | 356 |
| 369 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} | 357 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} |
| OLD | NEW |