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

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

Issue 1171333003: Move net::FormatUrl and friends outside of //net and into //components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase again now that CQ is fixed Created 5 years, 4 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/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/debug/stack_trace.h" 11 #include "base/debug/stack_trace.h"
12 #include "base/mac/mac_util.h" 12 #include "base/mac/mac_util.h"
13 #include "base/mac/scoped_block.h" 13 #include "base/mac/scoped_block.h"
14 #include "base/mac/sdk_forward_declarations.h" 14 #include "base/mac/sdk_forward_declarations.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/sys_string_conversions.h" 17 #include "base/strings/sys_string_conversions.h"
18 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
19 #import "chrome/browser/ui/cocoa/bubble_view.h" 19 #import "chrome/browser/ui/cocoa/bubble_view.h"
20 #include "components/secure_display/elide_url.h" 20 #include "components/url_formatter/elide_url.h"
21 #include "net/base/net_util.h" 21 #include "components/url_formatter/url_formatter.h"
22 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h " 22 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h "
23 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSBezierPath+RoundRect .h" 23 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSBezierPath+RoundRect .h"
24 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSColor+Luminance.h" 24 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSColor+Luminance.h"
25 #include "ui/base/cocoa/window_size_constants.h" 25 #include "ui/base/cocoa/window_size_constants.h"
26 #include "ui/gfx/font_list.h" 26 #include "ui/gfx/font_list.h"
27 #include "ui/gfx/geometry/point.h" 27 #include "ui/gfx/geometry/point.h"
28 #include "ui/gfx/platform_font.h" 28 #include "ui/gfx/platform_font.h"
29 #include "ui/gfx/text_elider.h" 29 #include "ui/gfx/text_elider.h"
30 #include "ui/gfx/text_utils.h" 30 #include "ui/gfx/text_utils.h"
31 31
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 kTextPadding); 228 kTextPadding);
229 229
230 // Scale from view to window coordinates before eliding URL string. 230 // Scale from view to window coordinates before eliding URL string.
231 NSSize scaled_width = NSMakeSize(text_width, 0); 231 NSSize scaled_width = NSMakeSize(text_width, 0);
232 scaled_width = [[parent_ contentView] convertSize:scaled_width fromView:nil]; 232 scaled_width = [[parent_ contentView] convertSize:scaled_width fromView:nil];
233 text_width = static_cast<int>(scaled_width.width); 233 text_width = static_cast<int>(scaled_width.width);
234 NSFont* font = [[window_ contentView] font]; 234 NSFont* font = [[window_ contentView] font];
235 gfx::FontList font_list_chr( 235 gfx::FontList font_list_chr(
236 gfx::Font(gfx::PlatformFont::CreateFromNativeFont(font))); 236 gfx::Font(gfx::PlatformFont::CreateFromNativeFont(font)));
237 237
238 base::string16 original_url_text = net::FormatUrl(url, languages); 238 base::string16 original_url_text = url_formatter::FormatUrl(url, languages);
239 base::string16 status = 239 base::string16 status =
240 secure_display::ElideUrl(url, font_list_chr, text_width, languages); 240 url_formatter::ElideUrl(url, font_list_chr, text_width, languages);
241 241
242 SetText(status, true); 242 SetText(status, true);
243 243
244 // In testing, don't use animation. When ExpandBubble is tested, it is 244 // In testing, don't use animation. When ExpandBubble is tested, it is
245 // called explicitly. 245 // called explicitly.
246 if (immediate_) 246 if (immediate_)
247 return; 247 return;
248 else 248 else
249 CancelExpandTimer(); 249 CancelExpandTimer();
250 250
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 // Calculate the width available for expanded and standard bubbles. 699 // Calculate the width available for expanded and standard bubbles.
700 NSRect window_frame = CalculateWindowFrame(/*expand=*/true); 700 NSRect window_frame = CalculateWindowFrame(/*expand=*/true);
701 CGFloat max_bubble_width = NSWidth(window_frame); 701 CGFloat max_bubble_width = NSWidth(window_frame);
702 CGFloat standard_bubble_width = 702 CGFloat standard_bubble_width =
703 NSWidth(CalculateWindowFrame(/*expand=*/false)); 703 NSWidth(CalculateWindowFrame(/*expand=*/false));
704 704
705 // Generate the URL string that fits in the expanded bubble. 705 // Generate the URL string that fits in the expanded bubble.
706 NSFont* font = [[window_ contentView] font]; 706 NSFont* font = [[window_ contentView] font];
707 gfx::FontList font_list_chr( 707 gfx::FontList font_list_chr(
708 gfx::Font(gfx::PlatformFont::CreateFromNativeFont(font))); 708 gfx::Font(gfx::PlatformFont::CreateFromNativeFont(font)));
709 base::string16 expanded_url = secure_display::ElideUrl( 709 base::string16 expanded_url = url_formatter::ElideUrl(
710 url_, font_list_chr, max_bubble_width, languages_); 710 url_, font_list_chr, max_bubble_width, languages_);
711 711
712 // Scale width from gfx::Font in view coordinates to window coordinates. 712 // Scale width from gfx::Font in view coordinates to window coordinates.
713 int required_width_for_string = 713 int required_width_for_string =
714 gfx::GetStringWidth(expanded_url, font_list_chr) + 714 gfx::GetStringWidth(expanded_url, font_list_chr) +
715 kTextPadding * 2 + kBubbleViewTextPositionX; 715 kTextPadding * 2 + kBubbleViewTextPositionX;
716 NSSize scaled_width = NSMakeSize(required_width_for_string, 0); 716 NSSize scaled_width = NSMakeSize(required_width_for_string, 0);
717 scaled_width = [[parent_ contentView] convertSize:scaled_width toView:nil]; 717 scaled_width = [[parent_ contentView] convertSize:scaled_width toView:nil];
718 required_width_for_string = scaled_width.width; 718 required_width_for_string = scaled_width.width;
719 719
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 } 849 }
850 850
851 // Round the top corners when the bubble is below the parent window. 851 // Round the top corners when the bubble is below the parent window.
852 if (NSMinY(window_frame) < NSMinY(parent_frame)) { 852 if (NSMinY(window_frame) < NSMinY(parent_frame)) {
853 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner; 853 corner_flags |= kRoundedTopLeftCorner | kRoundedTopRightCorner;
854 } 854 }
855 } 855 }
856 856
857 return corner_flags; 857 return corner_flags;
858 } 858 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.mm ('k') | chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698