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 "ash/tooltips/tooltip_controller.h" | 5 #include "ash/tooltips/tooltip_controller.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 // want to update the tooltip because the timer has fired. | 443 // want to update the tooltip because the timer has fired. |
444 // If we come here from UpdateTooltip(), we have already checked for tooltip | 444 // If we come here from UpdateTooltip(), we have already checked for tooltip |
445 // visibility and this check below will have no effect. | 445 // visibility and this check below will have no effect. |
446 if (tooltip_text_ != tooltip_text || !GetTooltip()->IsVisible()) { | 446 if (tooltip_text_ != tooltip_text || !GetTooltip()->IsVisible()) { |
447 tooltip_shown_timer_.Stop(); | 447 tooltip_shown_timer_.Stop(); |
448 tooltip_text_ = tooltip_text; | 448 tooltip_text_ = tooltip_text; |
449 if (tooltip_text_.empty()) { | 449 if (tooltip_text_.empty()) { |
450 GetTooltip()->Hide(); | 450 GetTooltip()->Hide(); |
451 } else { | 451 } else { |
452 string16 tooltip_text(tooltip_text_); | 452 string16 tooltip_text(tooltip_text_); |
453 gfx::Point widget_loc = curr_mouse_loc_; | 453 gfx::Point widget_loc = curr_mouse_loc_.Add( |
454 widget_loc = widget_loc.Add( | 454 tooltip_window_->GetBoundsInScreen().OffsetFromOrigin()); |
455 tooltip_window_->GetBoundsInScreen().origin()); | |
456 GetTooltip()->SetText(tooltip_text, widget_loc); | 455 GetTooltip()->SetText(tooltip_text, widget_loc); |
457 GetTooltip()->Show(); | 456 GetTooltip()->Show(); |
458 tooltip_shown_timer_.Start(FROM_HERE, | 457 tooltip_shown_timer_.Start(FROM_HERE, |
459 base::TimeDelta::FromMilliseconds(kTooltipShownTimeoutMs), | 458 base::TimeDelta::FromMilliseconds(kTooltipShownTimeoutMs), |
460 this, &TooltipController::TooltipShownTimerFired); | 459 this, &TooltipController::TooltipShownTimerFired); |
461 } | 460 } |
462 } | 461 } |
463 } | 462 } |
464 | 463 |
465 bool TooltipController::IsTooltipVisible() { | 464 bool TooltipController::IsTooltipVisible() { |
466 return GetTooltip()->IsVisible(); | 465 return GetTooltip()->IsVisible(); |
467 } | 466 } |
468 | 467 |
469 bool TooltipController::IsDragDropInProgress() { | 468 bool TooltipController::IsDragDropInProgress() { |
470 return drag_drop_client_->IsDragDropInProgress(); | 469 return drag_drop_client_->IsDragDropInProgress(); |
471 } | 470 } |
472 | 471 |
473 TooltipController::Tooltip* TooltipController::GetTooltip() { | 472 TooltipController::Tooltip* TooltipController::GetTooltip() { |
474 if (!tooltip_.get()) | 473 if (!tooltip_.get()) |
475 tooltip_.reset(new Tooltip); | 474 tooltip_.reset(new Tooltip); |
476 return tooltip_.get(); | 475 return tooltip_.get(); |
477 } | 476 } |
478 | 477 |
479 } // namespace internal | 478 } // namespace internal |
480 } // namespace ash | 479 } // namespace ash |
OLD | NEW |