| Index: ui/views/corewm/tooltip_controller.h
|
| diff --git a/ui/views/corewm/tooltip_controller.h b/ui/views/corewm/tooltip_controller.h
|
| index 5a274e319cd5edea134ef540a759884c323edbe0..630df7442d349e268734479a3f954582e7e3681a 100644
|
| --- a/ui/views/corewm/tooltip_controller.h
|
| +++ b/ui/views/corewm/tooltip_controller.h
|
| @@ -11,6 +11,7 @@
|
| #include "base/macros.h"
|
| #include "base/strings/string16.h"
|
| #include "base/timer/timer.h"
|
| +#include "ui/aura/client/cursor_client_observer.h"
|
| #include "ui/aura/window_observer.h"
|
| #include "ui/events/event_handler.h"
|
| #include "ui/gfx/geometry/point.h"
|
| @@ -31,9 +32,11 @@ class TooltipControllerTestHelper;
|
| } // namespace test
|
|
|
| // TooltipController provides tooltip functionality for aura.
|
| -class VIEWS_EXPORT TooltipController : public aura::client::TooltipClient,
|
| - public ui::EventHandler,
|
| - public aura::WindowObserver {
|
| +class VIEWS_EXPORT TooltipController
|
| + : public aura::client::TooltipClient,
|
| + public ui::EventHandler,
|
| + public aura::client::CursorClientObserver,
|
| + public aura::WindowObserver {
|
| public:
|
| explicit TooltipController(std::unique_ptr<Tooltip> tooltip);
|
| ~TooltipController() override;
|
| @@ -50,17 +53,25 @@ class VIEWS_EXPORT TooltipController : public aura::client::TooltipClient,
|
| void OnTouchEvent(ui::TouchEvent* event) override;
|
| void OnCancelMode(ui::CancelModeEvent* event) override;
|
|
|
| + // Overridden from aura::client::CursorClientObserver.
|
| + void OnCursorVisibilityChanged(bool is_visible) override;
|
| +
|
| // Overridden from aura::WindowObserver.
|
| void OnWindowDestroyed(aura::Window* window) override;
|
| + void OnWindowPropertyChanged(aura::Window* window,
|
| + const void* key,
|
| + intptr_t old) override;
|
|
|
| const gfx::Point& mouse_location() const { return curr_mouse_loc_; }
|
|
|
| private:
|
| friend class test::TooltipControllerTestHelper;
|
|
|
| - void TooltipTimerFired();
|
| void TooltipShownTimerFired();
|
|
|
| + // Show the tooltip.
|
| + void ShowTooltip();
|
| +
|
| // Updates the tooltip if required (if there is any change in the tooltip
|
| // text, tooltip id or the aura::Window).
|
| void UpdateIfRequired();
|
| @@ -80,8 +91,11 @@ class VIEWS_EXPORT TooltipController : public aura::client::TooltipClient,
|
| // Calls AddObserver on the new window if it is not NULL.
|
| void SetTooltipWindow(aura::Window* target);
|
|
|
| + void DisableTooltipShowDelay() { tooltip_show_delayed_ = false; }
|
| +
|
| aura::Window* tooltip_window_;
|
| base::string16 tooltip_text_;
|
| + base::string16 tooltip_text_whitespace_trimmed_;
|
| const void* tooltip_id_;
|
|
|
| // These fields are for tracking state when the user presses a mouse button.
|
| @@ -90,7 +104,8 @@ class VIEWS_EXPORT TooltipController : public aura::client::TooltipClient,
|
|
|
| std::unique_ptr<Tooltip> tooltip_;
|
|
|
| - base::RepeatingTimer tooltip_timer_;
|
| + // Timer for requesting delayed updates of the tooltip.
|
| + base::OneShotTimer tooltip_defer_timer_;
|
|
|
| // Timer to timeout the life of an on-screen tooltip. We hide the tooltip when
|
| // this timer fires.
|
| @@ -101,6 +116,11 @@ class VIEWS_EXPORT TooltipController : public aura::client::TooltipClient,
|
|
|
| bool tooltips_enabled_;
|
|
|
| + // An indicator of whether tooltip appears with delay or not.
|
| + // If the flag is true, tooltip shows up with delay;
|
| + // otherwise there is no delay, which is used in unit tests only.
|
| + bool tooltip_show_delayed_;
|
| +
|
| std::map<aura::Window*, int> tooltip_shown_timeout_map_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(TooltipController);
|
|
|