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 "chrome/browser/ui/views/status_bubble_views.h" | 5 #include "chrome/browser/ui/views/status_bubble_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 SetOpacity(0.0); | 214 SetOpacity(0.0); |
215 text_.clear(); | 215 text_.clear(); |
216 popup_->Hide(); | 216 popup_->Hide(); |
217 stage_ = BUBBLE_HIDDEN; | 217 stage_ = BUBBLE_HIDDEN; |
218 } | 218 } |
219 | 219 |
220 void StatusBubbleViews::StatusView::StartTimer(base::TimeDelta time) { | 220 void StatusBubbleViews::StatusView::StartTimer(base::TimeDelta time) { |
221 if (timer_factory_.HasWeakPtrs()) | 221 if (timer_factory_.HasWeakPtrs()) |
222 timer_factory_.InvalidateWeakPtrs(); | 222 timer_factory_.InvalidateWeakPtrs(); |
223 | 223 |
224 MessageLoop::current()->PostDelayedTask( | 224 base::MessageLoop::current()->PostDelayedTask( |
225 FROM_HERE, | 225 FROM_HERE, |
226 base::Bind(&StatusBubbleViews::StatusView::OnTimer, | 226 base::Bind(&StatusBubbleViews::StatusView::OnTimer, |
227 timer_factory_.GetWeakPtr()), | 227 timer_factory_.GetWeakPtr()), |
228 time); | 228 time); |
229 } | 229 } |
230 | 230 |
231 void StatusBubbleViews::StatusView::OnTimer() { | 231 void StatusBubbleViews::StatusView::OnTimer() { |
232 if (stage_ == BUBBLE_HIDING_TIMER) { | 232 if (stage_ == BUBBLE_HIDING_TIMER) { |
233 stage_ = BUBBLE_HIDING_FADE; | 233 stage_ = BUBBLE_HIDING_FADE; |
234 StartFade(1.0, 0.0, kHideFadeDurationMS); | 234 StartFade(1.0, 0.0, kHideFadeDurationMS); |
235 } else if (stage_ == BUBBLE_SHOWING_TIMER) { | 235 } else if (stage_ == BUBBLE_SHOWING_TIMER) { |
236 stage_ = BUBBLE_SHOWING_FADE; | 236 stage_ = BUBBLE_SHOWING_FADE; |
237 StartFade(0.0, 1.0, kShowFadeDurationMS); | 237 StartFade(0.0, 1.0, kShowFadeDurationMS); |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 if (IsFrameVisible()) { | 674 if (IsFrameVisible()) { |
675 view_->SetText(url_text_, true); | 675 view_->SetText(url_text_, true); |
676 | 676 |
677 CancelExpandTimer(); | 677 CancelExpandTimer(); |
678 | 678 |
679 // If bubble is already in expanded state, shift to adjust to new text | 679 // If bubble is already in expanded state, shift to adjust to new text |
680 // size (shrinking or expanding). Otherwise delay. | 680 // size (shrinking or expanding). Otherwise delay. |
681 if (is_expanded_ && !url.is_empty()) { | 681 if (is_expanded_ && !url.is_empty()) { |
682 ExpandBubble(); | 682 ExpandBubble(); |
683 } else if (net::FormatUrl(url, languages).length() > url_text_.length()) { | 683 } else if (net::FormatUrl(url, languages).length() > url_text_.length()) { |
684 MessageLoop::current()->PostDelayedTask( | 684 base::MessageLoop::current()->PostDelayedTask( |
685 FROM_HERE, | 685 FROM_HERE, |
686 base::Bind(&StatusBubbleViews::ExpandBubble, | 686 base::Bind(&StatusBubbleViews::ExpandBubble, |
687 expand_timer_factory_.GetWeakPtr()), | 687 expand_timer_factory_.GetWeakPtr()), |
688 base::TimeDelta::FromMilliseconds(kExpandHoverDelay)); | 688 base::TimeDelta::FromMilliseconds(kExpandHoverDelay)); |
689 } | 689 } |
690 } | 690 } |
691 } | 691 } |
692 | 692 |
693 void StatusBubbleViews::Hide() { | 693 void StatusBubbleViews::Hide() { |
694 status_text_ = string16(); | 694 status_text_ = string16(); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 void StatusBubbleViews::SetBubbleWidth(int width) { | 845 void StatusBubbleViews::SetBubbleWidth(int width) { |
846 size_.set_width(width); | 846 size_.set_width(width); |
847 SetBounds(original_position_.x(), original_position_.y(), | 847 SetBounds(original_position_.x(), original_position_.y(), |
848 size_.width(), size_.height()); | 848 size_.width(), size_.height()); |
849 } | 849 } |
850 | 850 |
851 void StatusBubbleViews::CancelExpandTimer() { | 851 void StatusBubbleViews::CancelExpandTimer() { |
852 if (expand_timer_factory_.HasWeakPtrs()) | 852 if (expand_timer_factory_.HasWeakPtrs()) |
853 expand_timer_factory_.InvalidateWeakPtrs(); | 853 expand_timer_factory_.InvalidateWeakPtrs(); |
854 } | 854 } |
OLD | NEW |