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

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: also drop url deps Created 6 years, 11 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
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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 // Reset expansion state only when bubble is completely hidden. 655 // Reset expansion state only when bubble is completely hidden.
655 if (view_->state() == StatusView::BUBBLE_HIDDEN) { 656 if (view_->state() == StatusView::BUBBLE_HIDDEN) {
656 is_expanded_ = false; 657 is_expanded_ = false;
657 SetBubbleWidth(GetStandardStatusBubbleWidth()); 658 SetBubbleWidth(GetStandardStatusBubbleWidth());
658 } 659 }
659 660
660 // Set Elided Text corresponding to the GURL object. 661 // Set Elided Text corresponding to the GURL object.
661 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen(); 662 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen();
662 int text_width = static_cast<int>(popup_bounds.width() - 663 int text_width = static_cast<int>(popup_bounds.width() -
663 (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1); 664 (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1);
664 url_text_ = gfx::ElideUrl(url, gfx::FontList(), text_width, languages); 665 url_text_ = ElideUrl(url, gfx::FontList(), text_width, languages);
665 666
666 // An URL is always treated as a left-to-right string. On right-to-left UIs 667 // An URL is always treated as a left-to-right string. On right-to-left UIs
667 // we need to explicitly mark the URL as LTR to make sure it is displayed 668 // we need to explicitly mark the URL as LTR to make sure it is displayed
668 // correctly. 669 // correctly.
669 url_text_ = base::i18n::GetDisplayStringInLTRDirectionality(url_text_); 670 url_text_ = base::i18n::GetDisplayStringInLTRDirectionality(url_text_);
670 671
671 if (IsFrameVisible()) { 672 if (IsFrameVisible()) {
672 view_->SetText(url_text_, true); 673 view_->SetText(url_text_, true);
673 674
674 CancelExpandTimer(); 675 CancelExpandTimer();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 views::Widget* window = frame->GetTopLevelWidget(); 813 views::Widget* window = frame->GetTopLevelWidget();
813 return !window || !window->IsMinimized(); 814 return !window || !window->IsMinimized();
814 } 815 }
815 816
816 void StatusBubbleViews::ExpandBubble() { 817 void StatusBubbleViews::ExpandBubble() {
817 // Elide URL to maximum possible size, then check actual length (it may 818 // Elide URL to maximum possible size, then check actual length (it may
818 // still be too long to fit) before expanding bubble. 819 // still be too long to fit) before expanding bubble.
819 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen(); 820 gfx::Rect popup_bounds = popup_->GetWindowBoundsInScreen();
820 int max_status_bubble_width = GetMaxStatusBubbleWidth(); 821 int max_status_bubble_width = GetMaxStatusBubbleWidth();
821 const gfx::FontList font_list; 822 const gfx::FontList font_list;
822 url_text_ = gfx::ElideUrl(url_, font_list, 823 url_text_ = ElideUrl(url_, font_list, max_status_bubble_width, languages_);
823 max_status_bubble_width, languages_);
824 int expanded_bubble_width = 824 int expanded_bubble_width =
825 std::max(GetStandardStatusBubbleWidth(), 825 std::max(GetStandardStatusBubbleWidth(),
826 std::min(gfx::GetStringWidth(url_text_, font_list) + 826 std::min(gfx::GetStringWidth(url_text_, font_list) +
827 (kShadowThickness * 2) + kTextPositionX + 827 (kShadowThickness * 2) + kTextPositionX +
828 kTextHorizPadding + 1, 828 kTextHorizPadding + 1,
829 max_status_bubble_width)); 829 max_status_bubble_width));
830 is_expanded_ = true; 830 is_expanded_ = true;
831 expand_view_->StartExpansion(url_text_, popup_bounds.width(), 831 expand_view_->StartExpansion(url_text_, popup_bounds.width(),
832 expanded_bubble_width); 832 expanded_bubble_width);
833 } 833 }
(...skipping 12 matching lines...) Expand all
846 void StatusBubbleViews::SetBubbleWidth(int width) { 846 void StatusBubbleViews::SetBubbleWidth(int width) {
847 size_.set_width(width); 847 size_.set_width(width);
848 SetBounds(original_position_.x(), original_position_.y(), 848 SetBounds(original_position_.x(), original_position_.y(),
849 size_.width(), size_.height()); 849 size_.width(), size_.height());
850 } 850 }
851 851
852 void StatusBubbleViews::CancelExpandTimer() { 852 void StatusBubbleViews::CancelExpandTimer() {
853 if (expand_timer_factory_.HasWeakPtrs()) 853 if (expand_timer_factory_.HasWeakPtrs())
854 expand_timer_factory_.InvalidateWeakPtrs(); 854 expand_timer_factory_.InvalidateWeakPtrs();
855 } 855 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698