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/cocoa/status_bubble_mac.h" | 5 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 return; | 163 return; |
164 else | 164 else |
165 CancelExpandTimer(); | 165 CancelExpandTimer(); |
166 | 166 |
167 // If the bubble has been expanded, the user has already hovered over a link | 167 // If the bubble has been expanded, the user has already hovered over a link |
168 // to trigger the expanded state. Don't wait to change the bubble in this | 168 // to trigger the expanded state. Don't wait to change the bubble in this |
169 // case -- immediately expand or contract to fit the URL. | 169 // case -- immediately expand or contract to fit the URL. |
170 if (is_expanded_ && !url.is_empty()) { | 170 if (is_expanded_ && !url.is_empty()) { |
171 ExpandBubble(); | 171 ExpandBubble(); |
172 } else if (original_url_text.length() > status.length()) { | 172 } else if (original_url_text.length() > status.length()) { |
173 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 173 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, |
174 base::Bind(&StatusBubbleMac::ExpandBubble, | 174 base::Bind(&StatusBubbleMac::ExpandBubble, |
175 expand_timer_factory_.GetWeakPtr()), | 175 expand_timer_factory_.GetWeakPtr()), |
176 base::TimeDelta::FromMilliseconds(kExpandHoverDelay)); | 176 base::TimeDelta::FromMilliseconds(kExpandHoverDelay)); |
177 } | 177 } |
178 } | 178 } |
179 | 179 |
180 void StatusBubbleMac::SetText(const string16& text, bool is_url) { | 180 void StatusBubbleMac::SetText(const string16& text, bool is_url) { |
181 // The status bubble allows the status and URL strings to be set | 181 // The status bubble allows the status and URL strings to be set |
182 // independently. Whichever was set non-empty most recently will be the | 182 // independently. Whichever was set non-empty most recently will be the |
183 // value displayed. When both are empty, the status bubble hides. | 183 // value displayed. When both are empty, the status bubble hides. |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 DCHECK(state_ == kBubbleShowingTimer || state_ == kBubbleHidingTimer); | 516 DCHECK(state_ == kBubbleShowingTimer || state_ == kBubbleHidingTimer); |
517 | 517 |
518 if (immediate_) { | 518 if (immediate_) { |
519 TimerFired(); | 519 TimerFired(); |
520 return; | 520 return; |
521 } | 521 } |
522 | 522 |
523 // There can only be one running timer. | 523 // There can only be one running timer. |
524 CancelTimer(); | 524 CancelTimer(); |
525 | 525 |
526 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 526 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, |
527 base::Bind(&StatusBubbleMac::TimerFired, timer_factory_.GetWeakPtr()), | 527 base::Bind(&StatusBubbleMac::TimerFired, timer_factory_.GetWeakPtr()), |
528 base::TimeDelta::FromMilliseconds(delay_ms)); | 528 base::TimeDelta::FromMilliseconds(delay_ms)); |
529 } | 529 } |
530 | 530 |
531 void StatusBubbleMac::CancelTimer() { | 531 void StatusBubbleMac::CancelTimer() { |
532 DCHECK([NSThread isMainThread]); | 532 DCHECK([NSThread isMainThread]); |
533 | 533 |
534 if (timer_factory_.HasWeakPtrs()) | 534 if (timer_factory_.HasWeakPtrs()) |
535 timer_factory_.InvalidateWeakPtrs(); | 535 timer_factory_.InvalidateWeakPtrs(); |
536 } | 536 } |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 } | 740 } |
741 | 741 |
742 // Round the top corners when the bubble is below the parent window. | 742 // Round the top corners when the bubble is below the parent window. |
743 if (NSMinY(window_frame) < NSMinY(parent_frame)) { | 743 if (NSMinY(window_frame) < NSMinY(parent_frame)) { |
744 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner; | 744 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner; |
745 } | 745 } |
746 } | 746 } |
747 | 747 |
748 return corner_flags; | 748 return corner_flags; |
749 } | 749 } |
OLD | NEW |