OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/status_bubble_views.h" | 5 #include "chrome/browser/views/status_bubble_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/linear_animation.h" | 9 #include "app/linear_animation.h" |
10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "app/text_elider.h" | 11 #include "app/text_elider.h" |
12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/browser_theme_provider.h" | 16 #include "chrome/browser/browser_theme_provider.h" |
16 #include "gfx/canvas_skia.h" | 17 #include "gfx/canvas_skia.h" |
17 #include "gfx/point.h" | 18 #include "gfx/point.h" |
18 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
20 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
21 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
22 #include "third_party/skia/include/core/SkPaint.h" | 23 #include "third_party/skia/include/core/SkPaint.h" |
23 #include "third_party/skia/include/core/SkPath.h" | 24 #include "third_party/skia/include/core/SkPath.h" |
24 #include "third_party/skia/include/core/SkRect.h" | 25 #include "third_party/skia/include/core/SkRect.h" |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 int text_width = static_cast<int>(popup_bounds.width() - | 655 int text_width = static_cast<int>(popup_bounds.width() - |
655 (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1); | 656 (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1); |
656 url_text_ = gfx::ElideUrl(url, view_->Label::font(), text_width, | 657 url_text_ = gfx::ElideUrl(url, view_->Label::font(), text_width, |
657 languages); | 658 languages); |
658 | 659 |
659 std::wstring original_url_text = net::FormatUrl(url, languages); | 660 std::wstring original_url_text = net::FormatUrl(url, languages); |
660 | 661 |
661 // An URL is always treated as a left-to-right string. On right-to-left UIs | 662 // An URL is always treated as a left-to-right string. On right-to-left UIs |
662 // we need to explicitly mark the URL as LTR to make sure it is displayed | 663 // we need to explicitly mark the URL as LTR to make sure it is displayed |
663 // correctly. | 664 // correctly. |
664 base::i18n::GetDisplayStringInLTRDirectionality(&url_text_); | 665 url_text_ = UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality( |
| 666 WideToUTF16(url_text_))); |
665 | 667 |
666 if (IsFrameVisible()) { | 668 if (IsFrameVisible()) { |
667 view_->SetText(url_text_, true); | 669 view_->SetText(url_text_, true); |
668 | 670 |
669 CancelExpandTimer(); | 671 CancelExpandTimer(); |
670 | 672 |
671 // If bubble is already in expanded state, shift to adjust to new text | 673 // If bubble is already in expanded state, shift to adjust to new text |
672 // size (shrinking or expanding). Otherwise delay. | 674 // size (shrinking or expanding). Otherwise delay. |
673 if (is_expanded_ && !url.is_empty()) | 675 if (is_expanded_ && !url.is_empty()) |
674 ExpandBubble(); | 676 ExpandBubble(); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 | 837 |
836 void StatusBubbleViews::SetBubbleWidth(int width) { | 838 void StatusBubbleViews::SetBubbleWidth(int width) { |
837 size_.set_width(width); | 839 size_.set_width(width); |
838 SetBounds(position_.x(), position_.y(), size_.width(), size_.height()); | 840 SetBounds(position_.x(), position_.y(), size_.width(), size_.height()); |
839 } | 841 } |
840 | 842 |
841 void StatusBubbleViews::CancelExpandTimer() { | 843 void StatusBubbleViews::CancelExpandTimer() { |
842 if (!expand_timer_factory_.empty()) | 844 if (!expand_timer_factory_.empty()) |
843 expand_timer_factory_.RevokeAll(); | 845 expand_timer_factory_.RevokeAll(); |
844 } | 846 } |
OLD | NEW |