Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: chrome/browser/ui/views/status_bubble_views.cc

Issue 1233313005: Move elide_url to its own component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/thread_task_runner_handle.h" 15 #include "base/thread_task_runner_handle.h"
16 #include "chrome/browser/themes/theme_properties.h" 16 #include "chrome/browser/themes/theme_properties.h"
17 #include "chrome/browser/ui/elide_url.h"
18 #include "net/base/net_util.h" 17 #include "net/base/net_util.h"
19 #include "third_party/skia/include/core/SkPaint.h" 18 #include "third_party/skia/include/core/SkPaint.h"
20 #include "third_party/skia/include/core/SkRect.h" 19 #include "third_party/skia/include/core/SkRect.h"
21 #include "ui/base/theme_provider.h" 20 #include "ui/base/theme_provider.h"
22 #include "ui/gfx/animation/animation_delegate.h" 21 #include "ui/gfx/animation/animation_delegate.h"
23 #include "ui/gfx/animation/linear_animation.h" 22 #include "ui/gfx/animation/linear_animation.h"
24 #include "ui/gfx/canvas.h" 23 #include "ui/gfx/canvas.h"
25 #include "ui/gfx/font_list.h" 24 #include "ui/gfx/font_list.h"
26 #include "ui/gfx/geometry/point.h" 25 #include "ui/gfx/geometry/point.h"
27 #include "ui/gfx/geometry/rect.h" 26 #include "ui/gfx/geometry/rect.h"
28 #include "ui/gfx/screen.h" 27 #include "ui/gfx/screen.h"
29 #include "ui/gfx/skia_util.h" 28 #include "ui/gfx/skia_util.h"
30 #include "ui/gfx/text_elider.h" 29 #include "ui/gfx/text_elider.h"
31 #include "ui/gfx/text_utils.h" 30 #include "ui/gfx/text_utils.h"
32 #include "ui/native_theme/native_theme.h" 31 #include "ui/native_theme/native_theme.h"
32 #include "ui/secure_display/elide_url.h"
33 #include "ui/views/controls/scrollbar/native_scroll_bar.h" 33 #include "ui/views/controls/scrollbar/native_scroll_bar.h"
34 #include "ui/views/widget/root_view.h" 34 #include "ui/views/widget/root_view.h"
35 #include "ui/views/widget/widget.h" 35 #include "ui/views/widget/widget.h"
36 #include "url/gurl.h" 36 #include "url/gurl.h"
37 37
38 #if defined(USE_ASH) 38 #if defined(USE_ASH)
39 #include "ash/wm/window_state.h" 39 #include "ash/wm/window_state.h"
40 #endif 40 #endif
41 41
42 // The alpha and color of the bubble's shadow. 42 // The alpha and color of the bubble's shadow.
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 int text_width = static_cast<int>(popup_bounds.width() - 695 int text_width = static_cast<int>(popup_bounds.width() -
696 (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1); 696 (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1);
697 url_text_ = ElideUrl(url, gfx::FontList(), text_width, languages); 697 url_text_ =
698 secure_display::ElideUrl(url, gfx::FontList(), text_width, languages);
698 699
699 // An URL is always treated as a left-to-right string. On right-to-left UIs 700 // An URL is always treated as a left-to-right string. On right-to-left UIs
700 // we need to explicitly mark the URL as LTR to make sure it is displayed 701 // we need to explicitly mark the URL as LTR to make sure it is displayed
701 // correctly. 702 // correctly.
702 url_text_ = base::i18n::GetDisplayStringInLTRDirectionality(url_text_); 703 url_text_ = base::i18n::GetDisplayStringInLTRDirectionality(url_text_);
703 704
704 if (IsFrameVisible()) { 705 if (IsFrameVisible()) {
705 view_->SetText(url_text_, true); 706 view_->SetText(url_text_, true);
706 707
707 CancelExpandTimer(); 708 CancelExpandTimer();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 views::Widget* window = frame->GetTopLevelWidget(); 851 views::Widget* window = frame->GetTopLevelWidget();
851 return window && window->IsMaximized(); 852 return window && window->IsMaximized();
852 } 853 }
853 854
854 void StatusBubbleViews::ExpandBubble() { 855 void StatusBubbleViews::ExpandBubble() {
855 // Elide URL to maximum possible size, then check actual length (it may 856 // Elide URL to maximum possible size, then check actual length (it may
856 // still be too long to fit) before expanding bubble. 857 // still be too long to fit) before expanding bubble.
857 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen(); 858 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen();
858 int max_status_bubble_width = GetMaxStatusBubbleWidth(); 859 int max_status_bubble_width = GetMaxStatusBubbleWidth();
859 const gfx::FontList font_list; 860 const gfx::FontList font_list;
860 url_text_ = ElideUrl(url_, font_list, max_status_bubble_width, languages_); 861 url_text_ = secure_display::ElideUrl(url_, font_list, max_status_bubble_width,
862 languages_);
861 int expanded_bubble_width = 863 int expanded_bubble_width =
862 std::max(GetStandardStatusBubbleWidth(), 864 std::max(GetStandardStatusBubbleWidth(),
863 std::min(gfx::GetStringWidth(url_text_, font_list) + 865 std::min(gfx::GetStringWidth(url_text_, font_list) +
864 (kShadowThickness * 2) + kTextPositionX + 866 (kShadowThickness * 2) + kTextPositionX +
865 kTextHorizPadding + 1, 867 kTextHorizPadding + 1,
866 max_status_bubble_width)); 868 max_status_bubble_width));
867 is_expanded_ = true; 869 is_expanded_ = true;
868 expand_view_->StartExpansion(url_text_, popup_bounds.width(), 870 expand_view_->StartExpansion(url_text_, popup_bounds.width(),
869 expanded_bubble_width); 871 expanded_bubble_width);
870 } 872 }
(...skipping 12 matching lines...) Expand all
883 void StatusBubbleViews::SetBubbleWidth(int width) { 885 void StatusBubbleViews::SetBubbleWidth(int width) {
884 size_.set_width(width); 886 size_.set_width(width);
885 SetBounds(original_position_.x(), original_position_.y(), 887 SetBounds(original_position_.x(), original_position_.y(),
886 size_.width(), size_.height()); 888 size_.width(), size_.height());
887 } 889 }
888 890
889 void StatusBubbleViews::CancelExpandTimer() { 891 void StatusBubbleViews::CancelExpandTimer() {
890 if (expand_timer_factory_.HasWeakPtrs()) 892 if (expand_timer_factory_.HasWeakPtrs())
891 expand_timer_factory_.InvalidateWeakPtrs(); 893 expand_timer_factory_.InvalidateWeakPtrs();
892 } 894 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698