| Index: ash/launcher/launcher_tooltip_manager.cc
|
| diff --git a/ash/launcher/launcher_tooltip_manager.cc b/ash/launcher/launcher_tooltip_manager.cc
|
| index a9b533cc3bfd37d20f89db2d533519183727cf48..a728ed90a3c6591648ed4081dc6b50d61d87d4fa 100644
|
| --- a/ash/launcher/launcher_tooltip_manager.cc
|
| +++ b/ash/launcher/launcher_tooltip_manager.cc
|
| @@ -7,6 +7,8 @@
|
| #include "ash/shell.h"
|
| #include "ash/shell_window_ids.h"
|
| #include "ash/wm/window_animations.h"
|
| +#include "base/bind.h"
|
| +#include "base/message_loop.h"
|
| #include "base/time.h"
|
| #include "base/timer.h"
|
| #include "ui/aura/window.h"
|
| @@ -102,13 +104,20 @@ void LauncherTooltipManager::LauncherTooltipBubble::WindowClosing() {
|
| host_->OnBubbleClosed(this);
|
| }
|
|
|
| -LauncherTooltipManager::LauncherTooltipManager(ShelfAlignment alignment)
|
| +LauncherTooltipManager::LauncherTooltipManager(
|
| + ShelfAlignment alignment, ShelfLayoutManager* shelf_layout_manager)
|
| : view_(NULL),
|
| anchor_(NULL),
|
| - alignment_(alignment) {}
|
| + alignment_(alignment),
|
| + shelf_layout_manager_(shelf_layout_manager) {
|
| + if (shelf_layout_manager)
|
| + shelf_layout_manager->AddObserver(this);
|
| +}
|
|
|
| LauncherTooltipManager::~LauncherTooltipManager() {
|
| Close();
|
| + if (shelf_layout_manager_)
|
| + shelf_layout_manager_->RemoveObserver(this);
|
| }
|
|
|
| void LauncherTooltipManager::ShowDelayed(views::View* anchor,
|
| @@ -120,6 +129,9 @@ void LauncherTooltipManager::ShowDelayed(views::View* anchor,
|
| Close();
|
| }
|
|
|
| + if (shelf_layout_manager_ && !shelf_layout_manager_->IsVisible())
|
| + return;
|
| +
|
| CreateBubble(anchor, text);
|
| gfx::NativeView native_view = view_->GetWidget()->GetNativeView();
|
| SetWindowVisibilityAnimationType(
|
| @@ -130,8 +142,14 @@ void LauncherTooltipManager::ShowDelayed(views::View* anchor,
|
|
|
| void LauncherTooltipManager::ShowImmediately(views::View* anchor,
|
| const string16& text) {
|
| - if (view_ && IsVisible())
|
| - Close();
|
| + if (view_) {
|
| + if (timer_.get() && timer_->IsRunning())
|
| + StopTimer();
|
| + Close();
|
| + }
|
| +
|
| + if (shelf_layout_manager_ && !shelf_layout_manager_->IsVisible())
|
| + return;
|
|
|
| CreateBubble(anchor, text);
|
| gfx::NativeView native_view = view_->GetWidget()->GetNativeView();
|
| @@ -169,6 +187,10 @@ void LauncherTooltipManager::ResetTimer() {
|
| return;
|
| }
|
|
|
| + // We don't start the timer if the shelf isn't visible.
|
| + if (shelf_layout_manager_ && !shelf_layout_manager_->IsVisible())
|
| + return;
|
| +
|
| base::OneShotTimer<LauncherTooltipManager>* new_timer =
|
| new base::OneShotTimer<LauncherTooltipManager>();
|
| new_timer->Start(
|
| @@ -190,6 +212,27 @@ bool LauncherTooltipManager::IsVisible() {
|
| return view_ && view_->GetWidget() && view_->GetWidget()->IsVisible();
|
| }
|
|
|
| +void LauncherTooltipManager::WillVisibilityStateChange(
|
| + ShelfLayoutManager::VisibilityState new_state) {
|
| + if (new_state == ShelfLayoutManager::HIDDEN) {
|
| + StopTimer();
|
| + Close();
|
| + }
|
| +}
|
| +
|
| +void LauncherTooltipManager::OnAutoHideStateChanged(
|
| + ShelfLayoutManager::AutoHideState new_state) {
|
| + if (new_state == ShelfLayoutManager::AUTO_HIDE_HIDDEN) {
|
| + StopTimer();
|
| + // AutoHide state change happens during an event filter, so immediate close
|
| + // may cause a crash in the HandleMouseEvent() after the filter. So we just
|
| + // schedule the Close here.
|
| + MessageLoopForUI::current()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&LauncherTooltipManager::Close, base::Unretained(this)));
|
| + }
|
| +}
|
| +
|
| void LauncherTooltipManager::ShowInternal() {
|
| if (view_)
|
| view_->Show();
|
|
|