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

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

Issue 143463006: Remove net dependency from ui/gfx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add gurl include to elide_url_unittest.cc Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/themes/theme_properties.h" 14 #include "chrome/browser/themes/theme_properties.h"
15 #include "chrome/browser/ui/elide_url.h"
15 #include "net/base/net_util.h" 16 #include "net/base/net_util.h"
16 #include "third_party/skia/include/core/SkPaint.h" 17 #include "third_party/skia/include/core/SkPaint.h"
17 #include "third_party/skia/include/core/SkPath.h" 18 #include "third_party/skia/include/core/SkPath.h"
18 #include "third_party/skia/include/core/SkRect.h" 19 #include "third_party/skia/include/core/SkRect.h"
19 #include "ui/base/theme_provider.h" 20 #include "ui/base/theme_provider.h"
20 #include "ui/gfx/animation/animation_delegate.h" 21 #include "ui/gfx/animation/animation_delegate.h"
21 #include "ui/gfx/animation/linear_animation.h" 22 #include "ui/gfx/animation/linear_animation.h"
22 #include "ui/gfx/canvas.h" 23 #include "ui/gfx/canvas.h"
23 #include "ui/gfx/font_list.h" 24 #include "ui/gfx/font_list.h"
24 #include "ui/gfx/point.h" 25 #include "ui/gfx/point.h"
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 // Reset expansion state only when bubble is completely hidden. 716 // Reset expansion state only when bubble is completely hidden.
716 if (view_->state() == StatusView::BUBBLE_HIDDEN) { 717 if (view_->state() == StatusView::BUBBLE_HIDDEN) {
717 is_expanded_ = false; 718 is_expanded_ = false;
718 SetBubbleWidth(GetStandardStatusBubbleWidth()); 719 SetBubbleWidth(GetStandardStatusBubbleWidth());
719 } 720 }
720 721
721 // Set Elided Text corresponding to the GURL object. 722 // Set Elided Text corresponding to the GURL object.
722 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen(); 723 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen();
723 int text_width = static_cast<int>(popup_bounds.width() - 724 int text_width = static_cast<int>(popup_bounds.width() -
724 (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1); 725 (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1);
725 url_text_ = gfx::ElideUrl(url, gfx::FontList(), text_width, languages); 726 url_text_ = ElideUrl(url, gfx::FontList(), text_width, languages);
726 727
727 // An URL is always treated as a left-to-right string. On right-to-left UIs 728 // An URL is always treated as a left-to-right string. On right-to-left UIs
728 // we need to explicitly mark the URL as LTR to make sure it is displayed 729 // we need to explicitly mark the URL as LTR to make sure it is displayed
729 // correctly. 730 // correctly.
730 url_text_ = base::i18n::GetDisplayStringInLTRDirectionality(url_text_); 731 url_text_ = base::i18n::GetDisplayStringInLTRDirectionality(url_text_);
731 732
732 if (IsFrameVisible()) { 733 if (IsFrameVisible()) {
733 view_->SetText(url_text_, true); 734 view_->SetText(url_text_, true);
734 735
735 CancelExpandTimer(); 736 CancelExpandTimer();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 views::Widget* window = frame->GetTopLevelWidget(); 880 views::Widget* window = frame->GetTopLevelWidget();
880 return window && window->IsMaximized(); 881 return window && window->IsMaximized();
881 } 882 }
882 883
883 void StatusBubbleViews::ExpandBubble() { 884 void StatusBubbleViews::ExpandBubble() {
884 // Elide URL to maximum possible size, then check actual length (it may 885 // Elide URL to maximum possible size, then check actual length (it may
885 // still be too long to fit) before expanding bubble. 886 // still be too long to fit) before expanding bubble.
886 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen(); 887 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen();
887 int max_status_bubble_width = GetMaxStatusBubbleWidth(); 888 int max_status_bubble_width = GetMaxStatusBubbleWidth();
888 const gfx::FontList font_list; 889 const gfx::FontList font_list;
889 url_text_ = gfx::ElideUrl(url_, font_list, 890 url_text_ = ElideUrl(url_, font_list, max_status_bubble_width, languages_);
890 max_status_bubble_width, languages_);
891 int expanded_bubble_width = 891 int expanded_bubble_width =
892 std::max(GetStandardStatusBubbleWidth(), 892 std::max(GetStandardStatusBubbleWidth(),
893 std::min(gfx::GetStringWidth(url_text_, font_list) + 893 std::min(gfx::GetStringWidth(url_text_, font_list) +
894 (kShadowThickness * 2) + kTextPositionX + 894 (kShadowThickness * 2) + kTextPositionX +
895 kTextHorizPadding + 1, 895 kTextHorizPadding + 1,
896 max_status_bubble_width)); 896 max_status_bubble_width));
897 is_expanded_ = true; 897 is_expanded_ = true;
898 expand_view_->StartExpansion(url_text_, popup_bounds.width(), 898 expand_view_->StartExpansion(url_text_, popup_bounds.width(),
899 expanded_bubble_width); 899 expanded_bubble_width);
900 } 900 }
(...skipping 12 matching lines...) Expand all
913 void StatusBubbleViews::SetBubbleWidth(int width) { 913 void StatusBubbleViews::SetBubbleWidth(int width) {
914 size_.set_width(width); 914 size_.set_width(width);
915 SetBounds(original_position_.x(), original_position_.y(), 915 SetBounds(original_position_.x(), original_position_.y(),
916 size_.width(), size_.height()); 916 size_.width(), size_.height());
917 } 917 }
918 918
919 void StatusBubbleViews::CancelExpandTimer() { 919 void StatusBubbleViews::CancelExpandTimer() {
920 if (expand_timer_factory_.HasWeakPtrs()) 920 if (expand_timer_factory_.HasWeakPtrs())
921 expand_timer_factory_.InvalidateWeakPtrs(); 921 expand_timer_factory_.InvalidateWeakPtrs();
922 } 922 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698