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

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

Issue 8392017: Change string16 to std::string in the gfx::Font() interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix mac unit tests Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 int text_width = static_cast<int>(NSWidth(frame) - 142 int text_width = static_cast<int>(NSWidth(frame) -
143 kBubbleViewTextPositionX - 143 kBubbleViewTextPositionX -
144 kTextPadding); 144 kTextPadding);
145 145
146 // Scale from view to window coordinates before eliding URL string. 146 // Scale from view to window coordinates before eliding URL string.
147 NSSize scaled_width = NSMakeSize(text_width, 0); 147 NSSize scaled_width = NSMakeSize(text_width, 0);
148 scaled_width = [[parent_ contentView] convertSize:scaled_width fromView:nil]; 148 scaled_width = [[parent_ contentView] convertSize:scaled_width fromView:nil];
149 text_width = static_cast<int>(scaled_width.width); 149 text_width = static_cast<int>(scaled_width.width);
150 NSFont* font = [[window_ contentView] font]; 150 NSFont* font = [[window_ contentView] font];
151 gfx::Font font_chr(base::SysNSStringToUTF16([font fontName]), 151 gfx::Font font_chr(base::SysNSStringToUTF8([font fontName]),
152 [font pointSize]); 152 [font pointSize]);
153 153
154 string16 original_url_text = net::FormatUrl(url, languages); 154 string16 original_url_text = net::FormatUrl(url, languages);
155 string16 status = ui::ElideUrl(url, font_chr, text_width, languages); 155 string16 status = ui::ElideUrl(url, font_chr, text_width, languages);
156 156
157 SetText(status, true); 157 SetText(status, true);
158 158
159 // In testing, don't use animation. When ExpandBubble is tested, it is 159 // In testing, don't use animation. When ExpandBubble is tested, it is
160 // called explicitly. 160 // called explicitly.
161 if (immediate_) 161 if (immediate_)
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 602
603 void StatusBubbleMac::ExpandBubble() { 603 void StatusBubbleMac::ExpandBubble() {
604 // Calculate the width available for expanded and standard bubbles. 604 // Calculate the width available for expanded and standard bubbles.
605 NSRect window_frame = CalculateWindowFrame(/*expand=*/true); 605 NSRect window_frame = CalculateWindowFrame(/*expand=*/true);
606 CGFloat max_bubble_width = NSWidth(window_frame); 606 CGFloat max_bubble_width = NSWidth(window_frame);
607 CGFloat standard_bubble_width = 607 CGFloat standard_bubble_width =
608 NSWidth(CalculateWindowFrame(/*expand=*/false)); 608 NSWidth(CalculateWindowFrame(/*expand=*/false));
609 609
610 // Generate the URL string that fits in the expanded bubble. 610 // Generate the URL string that fits in the expanded bubble.
611 NSFont* font = [[window_ contentView] font]; 611 NSFont* font = [[window_ contentView] font];
612 gfx::Font font_chr(base::SysNSStringToUTF16([font fontName]), 612 gfx::Font font_chr(base::SysNSStringToUTF8([font fontName]),
613 [font pointSize]); 613 [font pointSize]);
614 string16 expanded_url = ui::ElideUrl( 614 string16 expanded_url = ui::ElideUrl(
615 url_, font_chr, max_bubble_width, languages_); 615 url_, font_chr, max_bubble_width, languages_);
616 616
617 // Scale width from gfx::Font in view coordinates to window coordinates. 617 // Scale width from gfx::Font in view coordinates to window coordinates.
618 int required_width_for_string = 618 int required_width_for_string =
619 font_chr.GetStringWidth(expanded_url) + 619 font_chr.GetStringWidth(expanded_url) +
620 kTextPadding * 2 + kBubbleViewTextPositionX; 620 kTextPadding * 2 + kBubbleViewTextPositionX;
621 NSSize scaled_width = NSMakeSize(required_width_for_string, 0); 621 NSSize scaled_width = NSMakeSize(required_width_for_string, 0);
622 scaled_width = [[parent_ contentView] convertSize:scaled_width toView:nil]; 622 scaled_width = [[parent_ contentView] convertSize:scaled_width toView:nil];
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 } 729 }
730 730
731 // Round the top corners when the bubble is below the parent window. 731 // Round the top corners when the bubble is below the parent window.
732 if (NSMinY(window_frame) < NSMinY(parent_frame)) { 732 if (NSMinY(window_frame) < NSMinY(parent_frame)) {
733 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner; 733 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner;
734 } 734 }
735 } 735 }
736 736
737 return corner_flags; 737 return corner_flags;
738 } 738 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698