| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/corewm/tooltip_controller.h" | 5 #include "ui/views/corewm/tooltip_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 tooltip_shown_timer_.Stop(); | 301 tooltip_shown_timer_.Stop(); |
| 302 tooltip_text_ = tooltip_text; | 302 tooltip_text_ = tooltip_text; |
| 303 base::string16 trimmed_text = | 303 base::string16 trimmed_text = |
| 304 gfx::TruncateString(tooltip_text_, kMaxTooltipLength, gfx::WORD_BREAK); | 304 gfx::TruncateString(tooltip_text_, kMaxTooltipLength, gfx::WORD_BREAK); |
| 305 // If the string consists entirely of whitespace, then don't both showing it | 305 // If the string consists entirely of whitespace, then don't both showing it |
| 306 // (an empty tooltip is useless). | 306 // (an empty tooltip is useless). |
| 307 base::TrimWhitespace(trimmed_text, base::TRIM_ALL, | 307 base::TrimWhitespace(trimmed_text, base::TRIM_ALL, |
| 308 &tooltip_text_whitespace_trimmed_); | 308 &tooltip_text_whitespace_trimmed_); |
| 309 if (tooltip_text_whitespace_trimmed_.empty()) { | 309 if (tooltip_text_whitespace_trimmed_.empty()) { |
| 310 tooltip_->Hide(); | 310 tooltip_->Hide(); |
| 311 tooltip_defer_timer_.Stop(); |
| 311 } else if (tooltip_show_delayed_) { | 312 } else if (tooltip_show_delayed_) { |
| 312 // Initialize the one-shot timer to show the tooltip in a while. | 313 // Initialize the one-shot timer to show the tooltip in a while. |
| 313 // If there is already a request queued then cancel it and post the new | 314 // If there is already a request queued then cancel it and post the new |
| 314 // request. This ensures that tooltip won't show up too early. | 315 // request. This ensures that tooltip won't show up too early. |
| 315 // The delayed appearance of a tooltip is by default. | 316 // The delayed appearance of a tooltip is by default. |
| 316 if (tooltip_defer_timer_.IsRunning()) { | 317 if (tooltip_defer_timer_.IsRunning()) { |
| 317 tooltip_defer_timer_.Reset(); | 318 tooltip_defer_timer_.Reset(); |
| 318 } else { | 319 } else { |
| 319 tooltip_defer_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds( | 320 tooltip_defer_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds( |
| 320 kDelayForTooltipUpdateInMs), | 321 kDelayForTooltipUpdateInMs), |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 return; | 380 return; |
| 380 if (tooltip_window_) | 381 if (tooltip_window_) |
| 381 tooltip_window_->RemoveObserver(this); | 382 tooltip_window_->RemoveObserver(this); |
| 382 tooltip_window_ = target; | 383 tooltip_window_ = target; |
| 383 if (tooltip_window_) | 384 if (tooltip_window_) |
| 384 tooltip_window_->AddObserver(this); | 385 tooltip_window_->AddObserver(this); |
| 385 } | 386 } |
| 386 | 387 |
| 387 } // namespace corewm | 388 } // namespace corewm |
| 388 } // namespace views | 389 } // namespace views |
| OLD | NEW |