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

Side by Side Diff: ui/message_center/cocoa/notification_controller.mm

Issue 93903011: Remove 'using base::string16;' from base/strings/string16.h and remove temporary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: asdf 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
« no previous file with comments | « ui/base/cocoa/menu_controller.mm ('k') | no next file » | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #import "ui/message_center/cocoa/notification_controller.h" 5 #import "ui/message_center/cocoa/notification_controller.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 220
221 // Gets the rectangle in which notification content should be placed. This 221 // Gets the rectangle in which notification content should be placed. This
222 // rectangle is to the right of the icon and left of the control buttons. 222 // rectangle is to the right of the icon and left of the control buttons.
223 // This depends on the icon_ and closeButton_ being initialized. 223 // This depends on the icon_ and closeButton_ being initialized.
224 - (NSRect)currentContentRect; 224 - (NSRect)currentContentRect;
225 225
226 // Returns the wrapped text that could fit within the content rect with not 226 // Returns the wrapped text that could fit within the content rect with not
227 // more than the given number of lines. The wrapped text would be painted using 227 // more than the given number of lines. The wrapped text would be painted using
228 // the given font. The Ellipsis could be added at the end of the last line if 228 // the given font. The Ellipsis could be added at the end of the last line if
229 // it is too long. 229 // it is too long.
230 - (string16)wrapText:(const base::string16&)text 230 - (base::string16)wrapText:(const base::string16&)text
231 forFont:(NSFont*)font 231 forFont:(NSFont*)font
232 maxNumberOfLines:(size_t)lines; 232 maxNumberOfLines:(size_t)lines;
233 @end 233 @end
234 234
235 //////////////////////////////////////////////////////////////////////////////// 235 ////////////////////////////////////////////////////////////////////////////////
236 236
237 @implementation MCNotificationController 237 @implementation MCNotificationController
238 238
239 - (id)initWithNotification:(const message_center::Notification*)notification 239 - (id)initWithNotification:(const message_center::Notification*)notification
240 messageCenter:(message_center::MessageCenter*)messageCenter { 240 messageCenter:(message_center::MessageCenter*)messageCenter {
241 if ((self = [super initWithNibName:nil bundle:nil])) { 241 if ((self = [super initWithNibName:nil bundle:nil])) {
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 DCHECK(closeButton_); 717 DCHECK(closeButton_);
718 718
719 NSRect iconFrame, contentFrame; 719 NSRect iconFrame, contentFrame;
720 NSDivideRect([[self view] bounds], &iconFrame, &contentFrame, 720 NSDivideRect([[self view] bounds], &iconFrame, &contentFrame,
721 NSWidth([icon_ frame]) + message_center::kIconToTextPadding, 721 NSWidth([icon_ frame]) + message_center::kIconToTextPadding,
722 NSMinXEdge); 722 NSMinXEdge);
723 contentFrame.size.width -= NSWidth([closeButton_ frame]); 723 contentFrame.size.width -= NSWidth([closeButton_ frame]);
724 return contentFrame; 724 return contentFrame;
725 } 725 }
726 726
727 - (string16)wrapText:(const base::string16&)text 727 - (base::string16)wrapText:(const base::string16&)text
728 forFont:(NSFont*)nsfont 728 forFont:(NSFont*)nsfont
729 maxNumberOfLines:(size_t)lines { 729 maxNumberOfLines:(size_t)lines {
730 if (text.empty()) 730 if (text.empty())
731 return text; 731 return text;
732 gfx::FontList font_list((gfx::Font(nsfont))); 732 gfx::FontList font_list((gfx::Font(nsfont)));
733 int width = NSWidth([self currentContentRect]); 733 int width = NSWidth([self currentContentRect]);
734 int height = (lines + 1) * font_list.GetHeight(); 734 int height = (lines + 1) * font_list.GetHeight();
735 735
736 std::vector<base::string16> wrapped; 736 std::vector<base::string16> wrapped;
737 gfx::ElideRectangleText(text, font_list, width, height, 737 gfx::ElideRectangleText(text, font_list, width, height,
738 gfx::WRAP_LONG_WORDS, &wrapped); 738 gfx::WRAP_LONG_WORDS, &wrapped);
(...skipping 10 matching lines...) Expand all
749 if (gfx::GetStringWidth(last, font_list) > width) 749 if (gfx::GetStringWidth(last, font_list) > width)
750 last = gfx::ElideText(last, font_list, width, gfx::ELIDE_AT_END); 750 last = gfx::ElideText(last, font_list, width, gfx::ELIDE_AT_END);
751 wrapped.resize(lines - 1); 751 wrapped.resize(lines - 1);
752 wrapped.push_back(last); 752 wrapped.push_back(last);
753 } 753 }
754 754
755 return lines == 1 ? wrapped[0] : JoinString(wrapped, '\n'); 755 return lines == 1 ? wrapped[0] : JoinString(wrapped, '\n');
756 } 756 }
757 757
758 @end 758 @end
OLDNEW
« no previous file with comments | « ui/base/cocoa/menu_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698