Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2549)

Unified Diff: ash/launcher/launcher_tooltip_manager.cc

Issue 10701051: Polish launcher tooltip visibility (2nd try). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/launcher/launcher_tooltip_manager.h ('k') | ash/launcher/launcher_tooltip_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..188ef885aae44b57aefc0337f0c5e93fcf892f46 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"
@@ -76,7 +78,7 @@ LauncherTooltipManager::LauncherTooltipBubble::LauncherTooltipBubble(
aura::RootWindow* root_window =
anchor->GetWidget()->GetNativeView()->GetRootWindow();
set_parent_window(ash::Shell::GetInstance()->GetContainer(
- root_window, ash::internal::kShellWindowId_SettingBubbleContainer));
+ root_window, ash::internal::kShellWindowId_LauncherContainer));
}
label_ = new views::Label;
label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
@@ -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,31 @@ bool LauncherTooltipManager::IsVisible() {
return view_ && view_->GetWidget() && view_->GetWidget()->IsVisible();
}
+void LauncherTooltipManager::WillDeleteShelf() {
+ shelf_layout_manager_ = NULL;
+}
+
+void LauncherTooltipManager::WillChangeVisibilityState(
+ 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();
« no previous file with comments | « ash/launcher/launcher_tooltip_manager.h ('k') | ash/launcher/launcher_tooltip_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698