| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/toolbar/toolbar_actions_bar.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/location.h" |
| 8 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
| 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/thread_task_runner_handle.h" |
| 9 #include "chrome/browser/extensions/extension_action_manager.h" | 12 #include "chrome/browser/extensions/extension_action_manager.h" |
| 10 #include "chrome/browser/extensions/extension_message_bubble_controller.h" | 13 #include "chrome/browser/extensions/extension_message_bubble_controller.h" |
| 11 #include "chrome/browser/extensions/extension_util.h" | 14 #include "chrome/browser/extensions/extension_util.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/sessions/session_tab_helper.h" | 16 #include "chrome/browser/sessions/session_tab_helper.h" |
| 14 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
| 16 #include "chrome/browser/ui/extensions/extension_action_view_controller.h" | 19 #include "chrome/browser/ui/extensions/extension_action_view_controller.h" |
| 17 #include "chrome/browser/ui/extensions/extension_message_bubble_factory.h" | 20 #include "chrome/browser/ui/extensions/extension_message_bubble_factory.h" |
| 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 372 |
| 370 // CreateActions() can be called multiple times, so we need to make sure we | 373 // CreateActions() can be called multiple times, so we need to make sure we |
| 371 // haven't already shown the bubble. | 374 // haven't already shown the bubble. |
| 372 if (!checked_extension_bubble_) { | 375 if (!checked_extension_bubble_) { |
| 373 checked_extension_bubble_ = true; | 376 checked_extension_bubble_ = true; |
| 374 // CreateActions() can be called as part of the browser window set up, which | 377 // CreateActions() can be called as part of the browser window set up, which |
| 375 // we need to let finish before showing the actions. | 378 // we need to let finish before showing the actions. |
| 376 scoped_ptr<extensions::ExtensionMessageBubbleController> controller = | 379 scoped_ptr<extensions::ExtensionMessageBubbleController> controller = |
| 377 ExtensionMessageBubbleFactory(browser_->profile()).GetController(); | 380 ExtensionMessageBubbleFactory(browser_->profile()).GetController(); |
| 378 if (controller) { | 381 if (controller) { |
| 379 base::MessageLoop::current()->PostTask( | 382 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 380 FROM_HERE, | 383 FROM_HERE, base::Bind(&ToolbarActionsBar::MaybeShowExtensionBubble, |
| 381 base::Bind(&ToolbarActionsBar::MaybeShowExtensionBubble, | 384 weak_ptr_factory_.GetWeakPtr(), |
| 382 weak_ptr_factory_.GetWeakPtr(), | 385 base::Passed(controller.Pass()))); |
| 383 base::Passed(controller.Pass()))); | |
| 384 } | 386 } |
| 385 } | 387 } |
| 386 } | 388 } |
| 387 | 389 |
| 388 void ToolbarActionsBar::DeleteActions() { | 390 void ToolbarActionsBar::DeleteActions() { |
| 389 HideActivePopup(); | 391 HideActivePopup(); |
| 390 delegate_->RemoveAllViews(); | 392 delegate_->RemoveAllViews(); |
| 391 toolbar_actions_.clear(); | 393 toolbar_actions_.clear(); |
| 392 } | 394 } |
| 393 | 395 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 if (needs_redraw) { | 469 if (needs_redraw) { |
| 468 // We suppress animation for this draw, because we need the action to get | 470 // We suppress animation for this draw, because we need the action to get |
| 469 // into position immediately, since it's about to show its popup. | 471 // into position immediately, since it's about to show its popup. |
| 470 base::AutoReset<bool> layout_resetter(&suppress_animation_, false); | 472 base::AutoReset<bool> layout_resetter(&suppress_animation_, false); |
| 471 delegate_->Redraw(true); | 473 delegate_->Redraw(true); |
| 472 } | 474 } |
| 473 | 475 |
| 474 ResizeDelegate(gfx::Tween::LINEAR, false); | 476 ResizeDelegate(gfx::Tween::LINEAR, false); |
| 475 if (!delegate_->IsAnimating()) { | 477 if (!delegate_->IsAnimating()) { |
| 476 // Don't call the closure re-entrantly. | 478 // Don't call the closure re-entrantly. |
| 477 base::MessageLoop::current()->PostTask(FROM_HERE, closure); | 479 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); |
| 478 } else { | 480 } else { |
| 479 popped_out_closure_ = closure; | 481 popped_out_closure_ = closure; |
| 480 } | 482 } |
| 481 } | 483 } |
| 482 | 484 |
| 483 void ToolbarActionsBar::UndoPopOut() { | 485 void ToolbarActionsBar::UndoPopOut() { |
| 484 DCHECK(popped_out_action_); | 486 DCHECK(popped_out_action_); |
| 485 ToolbarActionViewController* controller = popped_out_action_; | 487 ToolbarActionViewController* controller = popped_out_action_; |
| 486 popped_out_action_ = nullptr; | 488 popped_out_action_ = nullptr; |
| 487 popped_out_closure_.Reset(); | 489 popped_out_closure_.Reset(); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 for (ToolbarActionViewController* action : toolbar_actions_) { | 738 for (ToolbarActionViewController* action : toolbar_actions_) { |
| 737 if (action->GetId() == id) | 739 if (action->GetId() == id) |
| 738 return action; | 740 return action; |
| 739 } | 741 } |
| 740 return nullptr; | 742 return nullptr; |
| 741 } | 743 } |
| 742 | 744 |
| 743 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() { | 745 content::WebContents* ToolbarActionsBar::GetCurrentWebContents() { |
| 744 return browser_->tab_strip_model()->GetActiveWebContents(); | 746 return browser_->tab_strip_model()->GetActiveWebContents(); |
| 745 } | 747 } |
| OLD | NEW |