summaryrefslogtreecommitdiffstats
path: root/ash/tooltips/tooltip_controller.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ash/tooltips/tooltip_controller.cc')
-rw-r--r--ash/tooltips/tooltip_controller.cc25
1 files changed, 23 insertions, 2 deletions
diff --git a/ash/tooltips/tooltip_controller.cc b/ash/tooltips/tooltip_controller.cc
index f6cd200..08d2bb4 100644
--- a/ash/tooltips/tooltip_controller.cc
+++ b/ash/tooltips/tooltip_controller.cc
@@ -203,7 +203,8 @@ class TooltipController::Tooltip {
TooltipController::TooltipController()
: aura::EventFilter(NULL),
tooltip_window_(NULL),
- tooltip_(new Tooltip) {
+ tooltip_(new Tooltip),
+ tooltips_enabled_(true) {
tooltip_timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(kTooltipTimeoutMs),
this, &TooltipController::TooltipTimerFired);
@@ -220,6 +221,13 @@ void TooltipController::UpdateTooltip(aura::Window* target) {
UpdateIfRequired();
}
+void TooltipController::SetTooltipsEnabled(bool enable) {
+ if (tooltips_enabled_ == enable)
+ return;
+ tooltips_enabled_ = enable;
+ UpdateTooltip(tooltip_window_);
+}
+
bool TooltipController::PreHandleKeyEvent(aura::Window* target,
aura::KeyEvent* event) {
return false;
@@ -288,11 +296,20 @@ void TooltipController::TooltipTimerFired() {
}
void TooltipController::UpdateIfRequired() {
+ if (!tooltips_enabled_) {
+ tooltip_->Hide();
+ return;
+ }
string16 tooltip_text;
if (tooltip_window_)
tooltip_text = *aura::client::GetTooltipText(tooltip_window_);
- if (tooltip_text_ != tooltip_text) {
+ // We add the !tooltip_->IsVisible() below because when we come here from
+ // TooltipTimerFired(), the tooltip_text may not have changed but we still
+ // want to update the tooltip because the timer has fired.
+ // If we come here from UpdateTooltip(), we have already checked for tooltip
+ // visibility and this check below will have no effect.
+ if (tooltip_text_ != tooltip_text || !tooltip_->IsVisible()) {
tooltip_text_ = tooltip_text;
if (tooltip_text_.empty()) {
tooltip_->Hide();
@@ -306,5 +323,9 @@ void TooltipController::UpdateIfRequired() {
}
}
+bool TooltipController::IsTooltipVisible() {
+ return tooltip_->IsVisible();
+}
+
} // namespace internal
} // namespace ash