Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar/browser_actions_container.h" | 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 | 302 |
| 303 int BrowserActionsContainer::GetChevronWidth() const { | 303 int BrowserActionsContainer::GetChevronWidth() const { |
| 304 return chevron_ ? | 304 return chevron_ ? |
| 305 chevron_->GetPreferredSize().width() + GetChevronSpacing() : 0; | 305 chevron_->GetPreferredSize().width() + GetChevronSpacing() : 0; |
| 306 } | 306 } |
| 307 | 307 |
| 308 void BrowserActionsContainer::ShowToolbarActionBubble( | 308 void BrowserActionsContainer::ShowToolbarActionBubble( |
| 309 std::unique_ptr<ToolbarActionsBarBubbleDelegate> controller) { | 309 std::unique_ptr<ToolbarActionsBarBubbleDelegate> controller) { |
| 310 // The container shouldn't be asked to show a bubble if it's animating. | 310 // The container shouldn't be asked to show a bubble if it's animating. |
| 311 DCHECK(!animating()); | 311 DCHECK(!animating()); |
| 312 DCHECK(!active_bubble_); | |
| 313 | |
| 312 views::View* anchor_view = nullptr; | 314 views::View* anchor_view = nullptr; |
| 313 if (!controller->GetAnchorActionId().empty()) { | 315 if (!controller->GetAnchorActionId().empty()) { |
| 314 ToolbarActionView* action_view = | 316 ToolbarActionView* action_view = |
| 315 GetViewForId(controller->GetAnchorActionId()); | 317 GetViewForId(controller->GetAnchorActionId()); |
| 316 anchor_view = | 318 if (action_view) { |
| 317 action_view->visible() ? action_view : GetOverflowReferenceView(); | 319 anchor_view = |
| 320 action_view->visible() ? action_view : GetOverflowReferenceView(); | |
| 321 } else { | |
| 322 anchor_view = BrowserView::GetBrowserViewForBrowser(browser_) | |
| 323 ->toolbar() | |
| 324 ->app_menu_button(); | |
| 325 } | |
| 318 } else { | 326 } else { |
| 319 anchor_view = this; | 327 anchor_view = this; |
| 320 } | 328 } |
| 321 ToolbarActionsBarBubbleViews* bubble = | |
| 322 new ToolbarActionsBarBubbleViews(anchor_view, std::move(controller)); | |
| 323 views::BubbleDelegateView::CreateBubble(bubble); | |
| 324 bubble->Show(); | |
| 325 } | |
| 326 | 329 |
| 327 void BrowserActionsContainer::ShowExtensionMessageBubble( | 330 // TODO(devlin): Clean up this type-specific mess. |
| 328 std::unique_ptr<extensions::ExtensionMessageBubbleController> controller, | 331 if (controller->IsExtensionMessageBubble()) { |
|
Devlin
2016/04/09 01:29:20
This is quite temporary - I have a followup patch
| |
| 329 ToolbarActionViewController* anchor_action) { | 332 extensions::ExtensionMessageBubbleView* bubble = |
| 330 // The container shouldn't be asked to show a bubble if it's animating. | 333 new extensions::ExtensionMessageBubbleView( |
| 331 DCHECK(!animating()); | 334 anchor_view, views::BubbleBorder::TOP_RIGHT, std::move(controller)); |
| 332 | 335 views::BubbleDelegateView::CreateBubble(bubble); |
| 333 views::View* reference_view = | 336 active_bubble_ = bubble; |
| 334 anchor_action | 337 active_bubble_->GetWidget()->AddObserver(this); |
| 335 ? static_cast<views::View*>(GetViewForId(anchor_action->GetId())) | 338 bubble->Show(); |
| 336 : BrowserView::GetBrowserViewForBrowser(browser_) | 339 } else { |
| 337 ->toolbar() | 340 ToolbarActionsBarBubbleViews* bubble = |
| 338 ->app_menu_button(); | 341 new ToolbarActionsBarBubbleViews(anchor_view, std::move(controller)); |
| 339 | 342 views::BubbleDelegateView::CreateBubble(bubble); |
| 340 extensions::ExtensionMessageBubbleView* bubble = | 343 active_bubble_ = bubble; |
| 341 new extensions::ExtensionMessageBubbleView(reference_view, | 344 active_bubble_->GetWidget()->AddObserver(this); |
| 342 views::BubbleBorder::TOP_RIGHT, | 345 bubble->Show(); |
| 343 std::move(controller)); | 346 } |
| 344 views::BubbleDelegateView::CreateBubble(bubble); | |
| 345 active_bubble_ = bubble; | |
| 346 active_bubble_->GetWidget()->AddObserver(this); | |
| 347 bubble->Show(); | |
| 348 } | 347 } |
| 349 | 348 |
| 350 void BrowserActionsContainer::OnWidgetClosing(views::Widget* widget) { | 349 void BrowserActionsContainer::OnWidgetClosing(views::Widget* widget) { |
| 351 ClearActiveBubble(widget); | 350 ClearActiveBubble(widget); |
| 352 } | 351 } |
| 353 | 352 |
| 354 void BrowserActionsContainer::OnWidgetDestroying(views::Widget* widget) { | 353 void BrowserActionsContainer::OnWidgetDestroying(views::Widget* widget) { |
| 355 ClearActiveBubble(widget); | 354 ClearActiveBubble(widget); |
| 356 } | 355 } |
| 357 | 356 |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 759 const int kWarningImages[] = IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT); | 758 const int kWarningImages[] = IMAGE_GRID(IDR_DEVELOPER_MODE_HIGHLIGHT); |
| 760 warning_highlight_painter_.reset( | 759 warning_highlight_painter_.reset( |
| 761 views::Painter::CreateImageGridPainter(kWarningImages)); | 760 views::Painter::CreateImageGridPainter(kWarningImages)); |
| 762 } | 761 } |
| 763 | 762 |
| 764 void BrowserActionsContainer::ClearActiveBubble(views::Widget* widget) { | 763 void BrowserActionsContainer::ClearActiveBubble(views::Widget* widget) { |
| 765 DCHECK(active_bubble_); | 764 DCHECK(active_bubble_); |
| 766 DCHECK_EQ(active_bubble_->GetWidget(), widget); | 765 DCHECK_EQ(active_bubble_->GetWidget(), widget); |
| 767 widget->RemoveObserver(this); | 766 widget->RemoveObserver(this); |
| 768 active_bubble_ = nullptr; | 767 active_bubble_ = nullptr; |
| 768 toolbar_actions_bar_->OnBubbleClosed(); | |
| 769 } | 769 } |
| OLD | NEW |