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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 resize_animation_->Reset(); | 253 resize_animation_->Reset(); |
254 } | 254 } |
255 | 255 |
256 void BrowserActionsContainer::ShowToolbarActionBubble( | 256 void BrowserActionsContainer::ShowToolbarActionBubble( |
257 std::unique_ptr<ToolbarActionsBarBubbleDelegate> controller) { | 257 std::unique_ptr<ToolbarActionsBarBubbleDelegate> controller) { |
258 // The container shouldn't be asked to show a bubble if it's animating. | 258 // The container shouldn't be asked to show a bubble if it's animating. |
259 DCHECK(!animating()); | 259 DCHECK(!animating()); |
260 DCHECK(!active_bubble_); | 260 DCHECK(!active_bubble_); |
261 | 261 |
262 views::View* anchor_view = nullptr; | 262 views::View* anchor_view = nullptr; |
| 263 bool anchored_to_action_view = false; |
263 if (!controller->GetAnchorActionId().empty()) { | 264 if (!controller->GetAnchorActionId().empty()) { |
264 ToolbarActionView* action_view = | 265 ToolbarActionView* action_view = |
265 GetViewForId(controller->GetAnchorActionId()); | 266 GetViewForId(controller->GetAnchorActionId()); |
266 if (action_view) { | 267 if (action_view) { |
267 anchor_view = | 268 anchor_view = |
268 action_view->visible() ? action_view : GetOverflowReferenceView(); | 269 action_view->visible() ? action_view : GetOverflowReferenceView(); |
| 270 anchored_to_action_view = true; |
269 } else { | 271 } else { |
270 anchor_view = BrowserView::GetBrowserViewForBrowser(browser_) | 272 anchor_view = BrowserView::GetBrowserViewForBrowser(browser_) |
271 ->toolbar() | 273 ->toolbar() |
272 ->app_menu_button(); | 274 ->app_menu_button(); |
273 } | 275 } |
274 } else { | 276 } else { |
275 anchor_view = this; | 277 anchor_view = this; |
276 } | 278 } |
277 | 279 |
278 ToolbarActionsBarBubbleViews* bubble = | 280 ToolbarActionsBarBubbleViews* bubble = new ToolbarActionsBarBubbleViews( |
279 new ToolbarActionsBarBubbleViews(anchor_view, std::move(controller)); | 281 anchor_view, gfx::Point(), anchored_to_action_view, |
| 282 std::move(controller)); |
280 active_bubble_ = bubble; | 283 active_bubble_ = bubble; |
281 views::BubbleDialogDelegateView::CreateBubble(bubble); | 284 views::BubbleDialogDelegateView::CreateBubble(bubble); |
282 bubble->GetWidget()->AddObserver(this); | 285 bubble->GetWidget()->AddObserver(this); |
283 bubble->Show(); | 286 bubble->Show(); |
284 } | 287 } |
285 | 288 |
286 void BrowserActionsContainer::OnWidgetClosing(views::Widget* widget) { | 289 void BrowserActionsContainer::OnWidgetClosing(views::Widget* widget) { |
287 ClearActiveBubble(widget); | 290 ClearActiveBubble(widget); |
288 } | 291 } |
289 | 292 |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 } | 660 } |
658 } | 661 } |
659 | 662 |
660 void BrowserActionsContainer::ClearActiveBubble(views::Widget* widget) { | 663 void BrowserActionsContainer::ClearActiveBubble(views::Widget* widget) { |
661 DCHECK(active_bubble_); | 664 DCHECK(active_bubble_); |
662 DCHECK_EQ(active_bubble_->GetWidget(), widget); | 665 DCHECK_EQ(active_bubble_->GetWidget(), widget); |
663 widget->RemoveObserver(this); | 666 widget->RemoveObserver(this); |
664 active_bubble_ = nullptr; | 667 active_bubble_ = nullptr; |
665 toolbar_actions_bar_->OnBubbleClosed(); | 668 toolbar_actions_bar_->OnBubbleClosed(); |
666 } | 669 } |
OLD | NEW |