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

Side by Side Diff: chrome/browser/ui/cocoa/status_bubble_mac.mm

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 | « build/android/pylib/gtest/filter/ui_unittests_disabled ('k') | chrome/browser/ui/elide_url.h » ('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/cocoa/status_bubble_mac.h" 5 #include "chrome/browser/ui/cocoa/status_bubble_mac.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/mac/mac_util.h" 11 #include "base/mac/mac_util.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #import "chrome/browser/ui/cocoa/bubble_view.h" 16 #import "chrome/browser/ui/cocoa/bubble_view.h"
17 #include "chrome/browser/ui/elide_url.h"
17 #include "net/base/net_util.h" 18 #include "net/base/net_util.h"
18 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h " 19 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h "
19 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSBezierPath+RoundRect .h" 20 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSBezierPath+RoundRect .h"
20 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSColor+Luminance.h" 21 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSColor+Luminance.h"
21 #include "ui/base/cocoa/window_size_constants.h" 22 #include "ui/base/cocoa/window_size_constants.h"
22 #include "ui/gfx/font_list.h" 23 #include "ui/gfx/font_list.h"
23 #include "ui/gfx/point.h" 24 #include "ui/gfx/point.h"
24 #include "ui/gfx/text_elider.h" 25 #include "ui/gfx/text_elider.h"
25 #include "ui/gfx/text_utils.h" 26 #include "ui/gfx/text_utils.h"
26 27
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // Scale from view to window coordinates before eliding URL string. 150 // Scale from view to window coordinates before eliding URL string.
150 NSSize scaled_width = NSMakeSize(text_width, 0); 151 NSSize scaled_width = NSMakeSize(text_width, 0);
151 scaled_width = [[parent_ contentView] convertSize:scaled_width fromView:nil]; 152 scaled_width = [[parent_ contentView] convertSize:scaled_width fromView:nil];
152 text_width = static_cast<int>(scaled_width.width); 153 text_width = static_cast<int>(scaled_width.width);
153 NSFont* font = [[window_ contentView] font]; 154 NSFont* font = [[window_ contentView] font];
154 gfx::FontList font_list_chr( 155 gfx::FontList font_list_chr(
155 gfx::Font(base::SysNSStringToUTF8([font fontName]), [font pointSize])); 156 gfx::Font(base::SysNSStringToUTF8([font fontName]), [font pointSize]));
156 157
157 base::string16 original_url_text = net::FormatUrl(url, languages); 158 base::string16 original_url_text = net::FormatUrl(url, languages);
158 base::string16 status = 159 base::string16 status =
159 gfx::ElideUrl(url, font_list_chr, text_width, languages); 160 ElideUrl(url, font_list_chr, text_width, languages);
160 161
161 SetText(status, true); 162 SetText(status, true);
162 163
163 // In testing, don't use animation. When ExpandBubble is tested, it is 164 // In testing, don't use animation. When ExpandBubble is tested, it is
164 // called explicitly. 165 // called explicitly.
165 if (immediate_) 166 if (immediate_)
166 return; 167 return;
167 else 168 else
168 CancelExpandTimer(); 169 CancelExpandTimer();
169 170
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 // Calculate the width available for expanded and standard bubbles. 619 // Calculate the width available for expanded and standard bubbles.
619 NSRect window_frame = CalculateWindowFrame(/*expand=*/true); 620 NSRect window_frame = CalculateWindowFrame(/*expand=*/true);
620 CGFloat max_bubble_width = NSWidth(window_frame); 621 CGFloat max_bubble_width = NSWidth(window_frame);
621 CGFloat standard_bubble_width = 622 CGFloat standard_bubble_width =
622 NSWidth(CalculateWindowFrame(/*expand=*/false)); 623 NSWidth(CalculateWindowFrame(/*expand=*/false));
623 624
624 // Generate the URL string that fits in the expanded bubble. 625 // Generate the URL string that fits in the expanded bubble.
625 NSFont* font = [[window_ contentView] font]; 626 NSFont* font = [[window_ contentView] font];
626 gfx::FontList font_list_chr( 627 gfx::FontList font_list_chr(
627 gfx::Font(base::SysNSStringToUTF8([font fontName]), [font pointSize])); 628 gfx::Font(base::SysNSStringToUTF8([font fontName]), [font pointSize]));
628 base::string16 expanded_url = gfx::ElideUrl( 629 base::string16 expanded_url = ElideUrl(
629 url_, font_list_chr, max_bubble_width, languages_); 630 url_, font_list_chr, max_bubble_width, languages_);
630 631
631 // Scale width from gfx::Font in view coordinates to window coordinates. 632 // Scale width from gfx::Font in view coordinates to window coordinates.
632 int required_width_for_string = 633 int required_width_for_string =
633 gfx::GetStringWidth(expanded_url, font_list_chr) + 634 gfx::GetStringWidth(expanded_url, font_list_chr) +
634 kTextPadding * 2 + kBubbleViewTextPositionX; 635 kTextPadding * 2 + kBubbleViewTextPositionX;
635 NSSize scaled_width = NSMakeSize(required_width_for_string, 0); 636 NSSize scaled_width = NSMakeSize(required_width_for_string, 0);
636 scaled_width = [[parent_ contentView] convertSize:scaled_width toView:nil]; 637 scaled_width = [[parent_ contentView] convertSize:scaled_width toView:nil];
637 required_width_for_string = scaled_width.width; 638 required_width_for_string = scaled_width.width;
638 639
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 } 744 }
744 745
745 // Round the top corners when the bubble is below the parent window. 746 // Round the top corners when the bubble is below the parent window.
746 if (NSMinY(window_frame) < NSMinY(parent_frame)) { 747 if (NSMinY(window_frame) < NSMinY(parent_frame)) {
747 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner; 748 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner;
748 } 749 }
749 } 750 }
750 751
751 return corner_flags; 752 return corner_flags;
752 } 753 }
OLDNEW
« no previous file with comments | « build/android/pylib/gtest/filter/ui_unittests_disabled ('k') | chrome/browser/ui/elide_url.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698