summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-15 22:07:33 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-15 22:07:33 +0000
commit862deef098a8f161cb9926363bd4786f83fdbdc9 (patch)
treeb4d0169e8d30fd064a3316f2e4e3bf3dd1e8d05e /ui
parent2f22bbc93302fb84904e029bec7bab83f92b071a (diff)
downloadchromium_src-862deef098a8f161cb9926363bd4786f83fdbdc9.zip
chromium_src-862deef098a8f161cb9926363bd4786f83fdbdc9.tar.gz
chromium_src-862deef098a8f161cb9926363bd4786f83fdbdc9.tar.bz2
Move TooltipClient to client namespace and add convenience setters/getters for it and the tooltip text.
BUG=none TEST=existing automation TBR=sky Review URL: http://codereview.chromium.org/8974001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114704 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura/aura.gyp1
-rw-r--r--ui/aura/client/aura_constants.h2
-rw-r--r--ui/aura/client/tooltip_client.cc31
-rw-r--r--ui/aura/client/tooltip_client.h8
-rw-r--r--ui/aura_shell/aura_shell.gyp4
-rw-r--r--ui/aura_shell/shell.cc20
-rw-r--r--ui/aura_shell/shell.h8
-rw-r--r--ui/aura_shell/tooltip_controller.cc (renamed from ui/aura_shell/shell_tooltip_manager.cc)39
-rw-r--r--ui/aura_shell/tooltip_controller.h (renamed from ui/aura_shell/shell_tooltip_manager.h)26
-rw-r--r--ui/views/widget/tooltip_manager_aura.cc23
10 files changed, 95 insertions, 67 deletions
diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp
index 53ebeac..f8c9036 100644
--- a/ui/aura/aura.gyp
+++ b/ui/aura/aura.gyp
@@ -35,6 +35,7 @@
'client/drag_drop_client.h',
'client/stacking_client.cc',
'client/stacking_client.h',
+ 'client/tooltip_client.cc',
'client/tooltip_client.h',
'client/drag_drop_delegate.cc',
'client/drag_drop_delegate.h',
diff --git a/ui/aura/client/aura_constants.h b/ui/aura/client/aura_constants.h
index a964c13..bd42ed6 100644
--- a/ui/aura/client/aura_constants.h
+++ b/ui/aura/client/aura_constants.h
@@ -47,7 +47,7 @@ AURA_EXPORT extern const char kRootWindowDragDropClientKey[];
AURA_EXPORT extern const char kRootWindowStackingClient[];
// A property key to store the tooltip client for the root window. The type of
-// the value is |aura::TooltipClient*|.
+// the value is |aura::client::TooltipClient*|.
AURA_EXPORT extern const char kRootWindowTooltipClientKey[];
// A property key for a value from aura::ShadowType describing the drop shadow
diff --git a/ui/aura/client/tooltip_client.cc b/ui/aura/client/tooltip_client.cc
new file mode 100644
index 0000000..273eff16
--- /dev/null
+++ b/ui/aura/client/tooltip_client.cc
@@ -0,0 +1,31 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/aura/client/tooltip_client.h"
+
+#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/root_window.h"
+
+namespace aura {
+namespace client {
+
+void SetTooltipClient(TooltipClient* client) {
+ RootWindow::GetInstance()->SetProperty(kRootWindowTooltipClientKey, client);
+}
+
+TooltipClient* GetTooltipClient() {
+ return reinterpret_cast<TooltipClient*>(
+ RootWindow::GetInstance()->GetProperty(kRootWindowTooltipClientKey));
+}
+
+void SetTooltipText(Window* window, string16* tooltip_text) {
+ window->SetProperty(kTooltipTextKey, tooltip_text);
+}
+
+string16* GetTooltipText(Window* window) {
+ return reinterpret_cast<string16*>(window->GetProperty(kTooltipTextKey));
+}
+
+} // namespace client
+} // namespace aura
diff --git a/ui/aura/client/tooltip_client.h b/ui/aura/client/tooltip_client.h
index 1a137c9..ca1afb3 100644
--- a/ui/aura/client/tooltip_client.h
+++ b/ui/aura/client/tooltip_client.h
@@ -11,8 +11,8 @@
#include "ui/gfx/font.h"
namespace aura {
-
class Window;
+namespace client {
class AURA_EXPORT TooltipClient {
public:
@@ -20,6 +20,12 @@ class AURA_EXPORT TooltipClient {
virtual void UpdateTooltip(Window* target) = 0;
};
+AURA_EXPORT void SetTooltipClient(TooltipClient* client);
+AURA_EXPORT TooltipClient* GetTooltipClient();
+AURA_EXPORT void SetTooltipText(Window* window, string16* tooltip_text);
+AURA_EXPORT string16* GetTooltipText(Window* window);
+
+} // namespace client
} // namespace aura
#endif // UI_AURA_CLIENT_TOOLTIP_CLIENT_H_
diff --git a/ui/aura_shell/aura_shell.gyp b/ui/aura_shell/aura_shell.gyp
index 88268c4..f4d5ad6 100644
--- a/ui/aura_shell/aura_shell.gyp
+++ b/ui/aura_shell/aura_shell.gyp
@@ -94,8 +94,6 @@
'shell_accelerator_filter.h',
'shell_delegate.h',
'shell_factory.h',
- 'shell_tooltip_manager.cc',
- 'shell_tooltip_manager.h',
'shell_window_ids.h',
'show_state_controller.h',
'show_state_controller.cc',
@@ -105,6 +103,8 @@
'status_area_layout_manager.h',
'status_area_view.cc',
'status_area_view.h',
+ 'tooltip_controller.cc',
+ 'tooltip_controller.h',
'toplevel_frame_view.cc',
'toplevel_frame_view.h',
'toplevel_layout_manager.cc',
diff --git a/ui/aura_shell/shell.cc b/ui/aura_shell/shell.cc
index c4b8892..646cc49 100644
--- a/ui/aura_shell/shell.cc
+++ b/ui/aura_shell/shell.cc
@@ -31,10 +31,10 @@
#include "ui/aura_shell/shell_accelerator_filter.h"
#include "ui/aura_shell/shell_delegate.h"
#include "ui/aura_shell/shell_factory.h"
-#include "ui/aura_shell/shell_tooltip_manager.h"
#include "ui/aura_shell/shell_window_ids.h"
#include "ui/aura_shell/stacking_controller.h"
#include "ui/aura_shell/status_area_layout_manager.h"
+#include "ui/aura_shell/tooltip_controller.h"
#include "ui/aura_shell/toplevel_layout_manager.h"
#include "ui/aura_shell/toplevel_window_event_filter.h"
#include "ui/aura_shell/workspace_controller.h"
@@ -129,12 +129,9 @@ Shell::Shell(ShellDelegate* delegate)
Shell::~Shell() {
RemoveRootWindowEventFilter(accelerator_filter_.get());
- // ShellTooltipManager needs a valid shell instance. We delete it before
+ // TooltipController needs a valid shell instance. We delete it before
// deleting the shell |instance_|.
- RemoveRootWindowEventFilter(tooltip_manager_.get());
- aura::RootWindow::GetInstance()->SetProperty(
- aura::kRootWindowTooltipClientKey,
- NULL);
+ RemoveRootWindowEventFilter(tooltip_controller_.get());
// Make sure we delete WorkspaceController before launcher is
// deleted as it has a reference to launcher model.
@@ -150,7 +147,7 @@ Shell::~Shell() {
delete child;
}
- tooltip_manager_.reset();
+ tooltip_controller_.reset();
// Drag drop controller needs a valid shell instance. We destroy it first.
drag_drop_controller_.reset();
@@ -209,12 +206,9 @@ void Shell::Init() {
accelerator_filter_.reset(new internal::ShellAcceleratorFilter);
AddRootWindowEventFilter(accelerator_filter_.get());
- // Initialize ShellTooltipManager
- tooltip_manager_.reset(new ShellTooltipManager);
- aura::RootWindow::GetInstance()->SetProperty(
- aura::kRootWindowTooltipClientKey,
- static_cast<aura::TooltipClient*>(tooltip_manager_.get()));
- AddRootWindowEventFilter(tooltip_manager_.get());
+ // Initialize TooltipController.
+ tooltip_controller_.reset(new internal::TooltipController);
+ AddRootWindowEventFilter(tooltip_controller_.get());
// Initialize drag drop controller.
drag_drop_controller_.reset(new internal::DragDropController);
diff --git a/ui/aura_shell/shell.h b/ui/aura_shell/shell.h
index 6193667..66c88eb 100644
--- a/ui/aura_shell/shell.h
+++ b/ui/aura_shell/shell.h
@@ -30,7 +30,6 @@ namespace aura_shell {
class Launcher;
class ShellAcceleratorController;
class ShellDelegate;
-class ShellTooltipManager;
namespace internal {
class ActivationController;
@@ -39,6 +38,7 @@ class DragDropController;
class ShadowController;
class ShellAcceleratorFilter;
class StackingController;
+class TooltipController;
class WorkspaceController;
}
@@ -78,8 +78,8 @@ class AURA_SHELL_EXPORT Shell {
return accelerator_controller_.get();
}
- ShellTooltipManager* tooltip_manager() {
- return tooltip_manager_.get();
+ internal::TooltipController* tooltip_controller() {
+ return tooltip_controller_.get();
}
ShellDelegate* delegate() { return delegate_.get(); }
@@ -123,11 +123,11 @@ class AURA_SHELL_EXPORT Shell {
scoped_ptr<internal::DragDropController> drag_drop_controller_;
scoped_ptr<internal::WorkspaceController> workspace_controller_;
scoped_ptr<internal::ShadowController> shadow_controller_;
+ scoped_ptr<internal::TooltipController> tooltip_controller_;
// An event filter that pre-handles global accelerators.
scoped_ptr<internal::ShellAcceleratorFilter> accelerator_filter_;
- scoped_ptr<ShellTooltipManager> tooltip_manager_;
DISALLOW_COPY_AND_ASSIGN(Shell);
};
diff --git a/ui/aura_shell/shell_tooltip_manager.cc b/ui/aura_shell/tooltip_controller.cc
index 1062b27..8b40db3 100644
--- a/ui/aura_shell/shell_tooltip_manager.cc
+++ b/ui/aura_shell/tooltip_controller.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/aura_shell/shell_tooltip_manager.h"
+#include "ui/aura_shell/tooltip_controller.h"
#include <vector>
@@ -123,9 +123,10 @@ views::Widget* CreateTooltip() {
} // namespace
namespace aura_shell {
+namespace internal {
// Displays a widget with tooltip using a views::Label.
-class ShellTooltipManager::Tooltip {
+class TooltipController::Tooltip {
public:
Tooltip() {
label_.set_background(
@@ -197,35 +198,35 @@ class ShellTooltipManager::Tooltip {
};
////////////////////////////////////////////////////////////////////////////////
-// ShellTooltipManager public:
+// TooltipController public:
-ShellTooltipManager::ShellTooltipManager()
+TooltipController::TooltipController()
: aura::EventFilter(NULL),
tooltip_window_(NULL),
tooltip_(new Tooltip) {
tooltip_timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(kTooltipTimeoutMs),
- this, &ShellTooltipManager::TooltipTimerFired);
+ this, &TooltipController::TooltipTimerFired);
}
-ShellTooltipManager::~ShellTooltipManager() {
+TooltipController::~TooltipController() {
if (tooltip_window_)
tooltip_window_->RemoveObserver(this);
}
-void ShellTooltipManager::UpdateTooltip(aura::Window* target) {
+void TooltipController::UpdateTooltip(aura::Window* target) {
// If tooltip is visible, we may want to hide it. If it is not, we are ok.
if (tooltip_window_ == target && tooltip_->IsVisible())
UpdateIfRequired();
}
-bool ShellTooltipManager::PreHandleKeyEvent(aura::Window* target,
- aura::KeyEvent* event) {
+bool TooltipController::PreHandleKeyEvent(aura::Window* target,
+ aura::KeyEvent* event) {
return false;
}
-bool ShellTooltipManager::PreHandleMouseEvent(aura::Window* target,
- aura::MouseEvent* event) {
+bool TooltipController::PreHandleMouseEvent(aura::Window* target,
+ aura::MouseEvent* event) {
switch (event->type()) {
case ui::ET_MOUSE_MOVED:
if (tooltip_window_ != target) {
@@ -255,30 +256,27 @@ bool ShellTooltipManager::PreHandleMouseEvent(aura::Window* target,
return false;
}
-ui::TouchStatus ShellTooltipManager::PreHandleTouchEvent(
+ui::TouchStatus TooltipController::PreHandleTouchEvent(
aura::Window* target,
aura::TouchEvent* event) {
return ui::TOUCH_STATUS_UNKNOWN;
}
-void ShellTooltipManager::OnWindowDestroyed(aura::Window* window) {
+void TooltipController::OnWindowDestroyed(aura::Window* window) {
if (tooltip_window_ == window) {
tooltip_window_->RemoveObserver(this);
tooltip_window_ = NULL;
}
}
-void ShellTooltipManager::TooltipTimerFired() {
+void TooltipController::TooltipTimerFired() {
UpdateIfRequired();
}
-void ShellTooltipManager::UpdateIfRequired() {
+void TooltipController::UpdateIfRequired() {
string16 tooltip_text;
- if (tooltip_window_) {
- void* property = tooltip_window_->GetProperty(aura::kTooltipTextKey);
- if (property)
- tooltip_text = *static_cast<string16*>(property);
- }
+ if (tooltip_window_)
+ tooltip_text = *aura::client::GetTooltipText(tooltip_window_);
if (tooltip_text_ != tooltip_text) {
tooltip_text_ = tooltip_text;
@@ -294,4 +292,5 @@ void ShellTooltipManager::UpdateIfRequired() {
}
}
+} // namespace internal
} // namespace aura_shell
diff --git a/ui/aura_shell/shell_tooltip_manager.h b/ui/aura_shell/tooltip_controller.h
index a9b301b..c84f48d 100644
--- a/ui/aura_shell/shell_tooltip_manager.h
+++ b/ui/aura_shell/tooltip_controller.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_AURA_SHELL_SHELL_TOOLTIP_MANAGER_H_
-#define UI_AURA_SHELL_SHELL_TOOLTIP_MANAGER_H_
+#ifndef UI_AURA_SHELL_TOOLTIP_CONTROLLER_H_
+#define UI_AURA_SHELL_TOOLTIP_CONTROLLER_H_
#pragma once
#include "base/memory/scoped_ptr.h"
@@ -23,16 +23,17 @@ class Window;
}
namespace aura_shell {
+namespace internal {
-// ShellTooltipManager provides tooltip functionality for aura shell.
-class AURA_SHELL_EXPORT ShellTooltipManager : public aura::TooltipClient,
- public aura::EventFilter,
- public aura::WindowObserver {
+// TooltipController provides tooltip functionality for aura shell.
+class AURA_SHELL_EXPORT TooltipController : public aura::client::TooltipClient,
+ public aura::EventFilter,
+ public aura::WindowObserver {
public:
- ShellTooltipManager();
- virtual ~ShellTooltipManager();
+ TooltipController();
+ virtual ~TooltipController();
- // Overridden from aura::TooltipClient.
+ // Overridden from aura::client::TooltipClient.
void UpdateTooltip(aura::Window* target);
// Overridden from aura::EventFilter.
@@ -59,13 +60,14 @@ class AURA_SHELL_EXPORT ShellTooltipManager : public aura::TooltipClient,
string16 tooltip_text_;
scoped_ptr<Tooltip> tooltip_;
- base::RepeatingTimer<ShellTooltipManager> tooltip_timer_;
+ base::RepeatingTimer<TooltipController> tooltip_timer_;
gfx::Point curr_mouse_loc_;
- DISALLOW_COPY_AND_ASSIGN(ShellTooltipManager);
+ DISALLOW_COPY_AND_ASSIGN(TooltipController);
};
+} // namespace internal
} // namespace aura_shell
-#endif // UI_AURA_SHELL_SHELL_TOOLTIP_MANAGER_H_
+#endif // UI_AURA_SHELL_TOOLTIP_CONTROLLER_H_
diff --git a/ui/views/widget/tooltip_manager_aura.cc b/ui/views/widget/tooltip_manager_aura.cc
index cf873e5..b1246fe 100644
--- a/ui/views/widget/tooltip_manager_aura.cc
+++ b/ui/views/widget/tooltip_manager_aura.cc
@@ -40,22 +40,19 @@ int TooltipManager::GetMaxWidth(int x, int y) {
TooltipManagerAura::TooltipManagerAura(NativeWidgetAura* native_widget_aura)
: native_widget_aura_(native_widget_aura) {
- native_widget_aura_->GetNativeView()->SetProperty(aura::kTooltipTextKey,
- &tooltip_text_);
+ aura::client::SetTooltipText(native_widget_aura_->GetNativeView(),
+ &tooltip_text_);
}
TooltipManagerAura::~TooltipManagerAura() {
- native_widget_aura_->GetNativeView()->SetProperty(aura::kTooltipTextKey,
- NULL);
+ aura::client::SetTooltipText(native_widget_aura_->GetNativeView(), NULL);
}
////////////////////////////////////////////////////////////////////////////////
// TooltipManagerAura, TooltipManager implementation:
void TooltipManagerAura::UpdateTooltip() {
- void* property = aura::RootWindow::GetInstance()->GetProperty(
- aura::kRootWindowTooltipClientKey);
- if (property) {
+ if (aura::client::GetTooltipClient()) {
gfx::Point view_point =
aura::RootWindow::GetInstance()->last_mouse_location();
aura::Window::ConvertPointToWindow(aura::RootWindow::GetInstance(),
@@ -68,15 +65,13 @@ void TooltipManagerAura::UpdateTooltip() {
} else {
tooltip_text_.clear();
}
- aura::TooltipClient* tc = static_cast<aura::TooltipClient*>(property);
- tc->UpdateTooltip(native_widget_aura_->GetNativeView());
+ aura::client::GetTooltipClient()->UpdateTooltip(
+ native_widget_aura_->GetNativeView());
}
}
void TooltipManagerAura::TooltipTextChanged(View* view) {
- void* property = aura::RootWindow::GetInstance()->GetProperty(
- aura::kRootWindowTooltipClientKey);
- if (property) {
+ if (aura::client::GetTooltipClient()) {
gfx::Point view_point =
aura::RootWindow::GetInstance()->last_mouse_location();
aura::Window::ConvertPointToWindow(aura::RootWindow::GetInstance(),
@@ -91,8 +86,8 @@ void TooltipManagerAura::TooltipTextChanged(View* view) {
} else {
tooltip_text_.clear();
}
- aura::TooltipClient* tc = static_cast<aura::TooltipClient*>(property);
- tc->UpdateTooltip(native_widget_aura_->GetNativeView());
+ aura::client::GetTooltipClient()->UpdateTooltip(
+ native_widget_aura_->GetNativeView());
}
}