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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 views::TooltipManager::TrimTooltipText(&trimmed_text); | 294 views::TooltipManager::TrimTooltipText(&trimmed_text); |
295 // If the string consists entirely of whitespace, then don't both showing it | 295 // If the string consists entirely of whitespace, then don't both showing it |
296 // (an empty tooltip is useless). | 296 // (an empty tooltip is useless). |
297 base::string16 whitespace_removed_text; | 297 base::string16 whitespace_removed_text; |
298 TrimWhitespace(trimmed_text, TRIM_ALL, &whitespace_removed_text); | 298 TrimWhitespace(trimmed_text, TRIM_ALL, &whitespace_removed_text); |
299 if (whitespace_removed_text.empty()) { | 299 if (whitespace_removed_text.empty()) { |
300 tooltip_->Hide(); | 300 tooltip_->Hide(); |
301 } else { | 301 } else { |
302 gfx::Point widget_loc = curr_mouse_loc_ + | 302 gfx::Point widget_loc = curr_mouse_loc_ + |
303 tooltip_window_->GetBoundsInScreen().OffsetFromOrigin(); | 303 tooltip_window_->GetBoundsInScreen().OffsetFromOrigin(); |
304 tooltip_->SetText(tooltip_window_, trimmed_text, widget_loc); | 304 tooltip_->SetText(tooltip_window_, whitespace_removed_text, widget_loc); |
305 tooltip_->Show(); | 305 tooltip_->Show(); |
306 int timeout = GetTooltipShownTimeout(); | 306 int timeout = GetTooltipShownTimeout(); |
307 if (timeout > 0) { | 307 if (timeout > 0) { |
308 tooltip_shown_timer_.Start(FROM_HERE, | 308 tooltip_shown_timer_.Start(FROM_HERE, |
309 base::TimeDelta::FromMilliseconds(timeout), | 309 base::TimeDelta::FromMilliseconds(timeout), |
310 this, &TooltipController::TooltipShownTimerFired); | 310 this, &TooltipController::TooltipShownTimerFired); |
311 } | 311 } |
312 } | 312 } |
313 } | 313 } |
314 } | 314 } |
(...skipping 25 matching lines...) Expand all Loading... |
340 int TooltipController::GetTooltipShownTimeout() { | 340 int TooltipController::GetTooltipShownTimeout() { |
341 std::map<aura::Window*, int>::const_iterator it = | 341 std::map<aura::Window*, int>::const_iterator it = |
342 tooltip_shown_timeout_map_.find(tooltip_window_); | 342 tooltip_shown_timeout_map_.find(tooltip_window_); |
343 if (it == tooltip_shown_timeout_map_.end()) | 343 if (it == tooltip_shown_timeout_map_.end()) |
344 return kDefaultTooltipShownTimeoutMs; | 344 return kDefaultTooltipShownTimeoutMs; |
345 return it->second; | 345 return it->second; |
346 } | 346 } |
347 | 347 |
348 } // namespace corewm | 348 } // namespace corewm |
349 } // namespace views | 349 } // namespace views |
OLD | NEW |