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

Unified Diff: ui/message_center/cocoa/notification_controller.mm

Issue 1292003004: Elide origins displayed on web notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Style nit 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/message_center/DEPS ('k') | ui/message_center/cocoa/notification_controller_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/message_center/cocoa/notification_controller.mm
diff --git a/ui/message_center/cocoa/notification_controller.mm b/ui/message_center/cocoa/notification_controller.mm
index 1b4e96a0ce1ecb1a05f0b1e43271e350a26a667d..2d1207a73b19caa771e3934fbad2383017d888ee 100644
--- a/ui/message_center/cocoa/notification_controller.mm
+++ b/ui/message_center/cocoa/notification_controller.mm
@@ -10,6 +10,7 @@
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#include "components/url_formatter/elide_url.h"
#include "skia/ext/skia_utils_mac.h"
#import "ui/base/cocoa/hover_image_button.h"
#include "ui/base/l10n/l10n_util_mac.h"
@@ -22,7 +23,7 @@
#include "ui/message_center/notification.h"
#include "ui/resources/grit/ui_resources.h"
#include "ui/strings/grit/ui_strings.h"
-
+#include "url/gurl.h"
@interface MCNotificationProgressBar : NSProgressIndicator
@end
@@ -380,11 +381,11 @@
// Set the title and recalculate the frame.
size_t actualTitleLines = 0;
- [title_ setString:base::SysUTF16ToNSString(
- [self wrapText:notification_->title()
- forFont:[title_ font]
- maxNumberOfLines:message_center::kMaxTitleLines
- actualLines:&actualTitleLines])];
+ [title_ setString:base::SysUTF16ToNSString([self
+ wrapText:notification_->title()
+ forFont:[title_ font]
+ maxNumberOfLines:message_center::kMaxTitleLines
+ actualLines:&actualTitleLines])];
[title_ sizeToFit];
NSRect titleFrame = [title_ frame];
titleFrame.origin.y = NSMaxY(rootFrame) - titlePadding - NSHeight(titleFrame);
@@ -396,7 +397,9 @@
messageLineLimit -= (actualTitleLines - 1) * 2;
if (!notification_->image().IsEmpty()) {
messageLineLimit /= 2;
- if (!notification_->context_message().empty())
+
+ if (!notification_->context_message().empty() &&
+ !notification_->UseOriginAsContextMessage())
messageLineLimit -= message_center::kContextMessageLineLimit;
}
if (messageLineLimit < 0)
@@ -428,14 +431,26 @@
}
// Set the context message and recalculate the frame.
- [contextMessage_ setString:base::SysUTF16ToNSString(
- [self wrapText:notification_->context_message()
+ base::string16 message;
+ if (notification->UseOriginAsContextMessage()) {
+ gfx::FontList font_list((gfx::Font([message_ font])));
+ message =
+ url_formatter::ElideHost(notification->origin_url(), font_list,
+ message_center::kContextMessageViewWidth);
+ } else {
+ message = notification->context_message();
+ }
+
+ base::string16 elided =
+ [self wrapText:message
forFont:[contextMessage_ font]
- maxNumberOfLines:message_center::kContextMessageLineLimit])];
+ maxNumberOfLines:message_center::kContextMessageLineLimit];
+ [contextMessage_ setString:base::SysUTF16ToNSString(elided)];
[contextMessage_ sizeToFit];
NSRect contextMessageFrame = [contextMessage_ frame];
- if (notification_->context_message().empty()) {
+ if (notification->context_message().empty() &&
+ !notification->UseOriginAsContextMessage()) {
[contextMessage_ setHidden:YES];
contextMessageFrame.origin.y = messageFrame.origin.y;
contextMessageFrame.size.height = 0;
« no previous file with comments | « ui/message_center/DEPS ('k') | ui/message_center/cocoa/notification_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698