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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 } | 685 } |
686 | 686 |
687 // Reset expansion state only when bubble is completely hidden. | 687 // Reset expansion state only when bubble is completely hidden. |
688 if (view_->state() == StatusView::BUBBLE_HIDDEN) { | 688 if (view_->state() == StatusView::BUBBLE_HIDDEN) { |
689 is_expanded_ = false; | 689 is_expanded_ = false; |
690 SetBubbleWidth(GetStandardStatusBubbleWidth()); | 690 SetBubbleWidth(GetStandardStatusBubbleWidth()); |
691 } | 691 } |
692 | 692 |
693 // Set Elided Text corresponding to the GURL object. | 693 // Set Elided Text corresponding to the GURL object. |
694 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen(); | 694 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen(); |
| 695 #if !defined(USE_AURA) |
695 int text_width = static_cast<int>(popup_bounds.width() - | 696 int text_width = static_cast<int>(popup_bounds.width() - |
696 (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1); | 697 (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1); |
697 url_text_ = | 698 url_text_ = |
698 url_formatter::ElideUrl(url, gfx::FontList(), text_width, languages); | 699 url_formatter::ElideUrl(url, gfx::FontList(), text_width, languages); |
| 700 #endif |
699 | 701 |
700 // An URL is always treated as a left-to-right string. On right-to-left UIs | 702 // An URL is always treated as a left-to-right string. On right-to-left UIs |
701 // we need to explicitly mark the URL as LTR to make sure it is displayed | 703 // we need to explicitly mark the URL as LTR to make sure it is displayed |
702 // correctly. | 704 // correctly. |
703 url_text_ = base::i18n::GetDisplayStringInLTRDirectionality(url_text_); | 705 url_text_ = base::i18n::GetDisplayStringInLTRDirectionality(url_text_); |
704 | 706 |
705 if (IsFrameVisible()) { | 707 if (IsFrameVisible()) { |
706 view_->SetText(url_text_, true); | 708 view_->SetText(url_text_, true); |
707 | 709 |
708 CancelExpandTimer(); | 710 CancelExpandTimer(); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 views::Widget* window = frame->GetTopLevelWidget(); | 854 views::Widget* window = frame->GetTopLevelWidget(); |
853 return window && window->IsMaximized(); | 855 return window && window->IsMaximized(); |
854 } | 856 } |
855 | 857 |
856 void StatusBubbleViews::ExpandBubble() { | 858 void StatusBubbleViews::ExpandBubble() { |
857 // Elide URL to maximum possible size, then check actual length (it may | 859 // Elide URL to maximum possible size, then check actual length (it may |
858 // still be too long to fit) before expanding bubble. | 860 // still be too long to fit) before expanding bubble. |
859 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen(); | 861 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen(); |
860 int max_status_bubble_width = GetMaxStatusBubbleWidth(); | 862 int max_status_bubble_width = GetMaxStatusBubbleWidth(); |
861 const gfx::FontList font_list; | 863 const gfx::FontList font_list; |
| 864 #if !defined(USE_AURA) |
862 url_text_ = url_formatter::ElideUrl(url_, font_list, max_status_bubble_width, | 865 url_text_ = url_formatter::ElideUrl(url_, font_list, max_status_bubble_width, |
863 languages_); | 866 languages_); |
| 867 #endif |
864 int expanded_bubble_width = | 868 int expanded_bubble_width = |
865 std::max(GetStandardStatusBubbleWidth(), | 869 std::max(GetStandardStatusBubbleWidth(), |
866 std::min(gfx::GetStringWidth(url_text_, font_list) + | 870 std::min(gfx::GetStringWidth(url_text_, font_list) + |
867 (kShadowThickness * 2) + kTextPositionX + | 871 (kShadowThickness * 2) + kTextPositionX + |
868 kTextHorizPadding + 1, | 872 kTextHorizPadding + 1, |
869 max_status_bubble_width)); | 873 max_status_bubble_width)); |
870 is_expanded_ = true; | 874 is_expanded_ = true; |
871 expand_view_->StartExpansion(url_text_, popup_bounds.width(), | 875 expand_view_->StartExpansion(url_text_, popup_bounds.width(), |
872 expanded_bubble_width); | 876 expanded_bubble_width); |
873 } | 877 } |
(...skipping 12 matching lines...) Expand all Loading... |
886 void StatusBubbleViews::SetBubbleWidth(int width) { | 890 void StatusBubbleViews::SetBubbleWidth(int width) { |
887 size_.set_width(width); | 891 size_.set_width(width); |
888 SetBounds(original_position_.x(), original_position_.y(), | 892 SetBounds(original_position_.x(), original_position_.y(), |
889 size_.width(), size_.height()); | 893 size_.width(), size_.height()); |
890 } | 894 } |
891 | 895 |
892 void StatusBubbleViews::CancelExpandTimer() { | 896 void StatusBubbleViews::CancelExpandTimer() { |
893 if (expand_timer_factory_.HasWeakPtrs()) | 897 if (expand_timer_factory_.HasWeakPtrs()) |
894 expand_timer_factory_.InvalidateWeakPtrs(); | 898 expand_timer_factory_.InvalidateWeakPtrs(); |
895 } | 899 } |
OLD | NEW |