| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/notifications/notification_platform_bridge_mac.h" | 5 #include "chrome/browser/notifications/notification_platform_bridge_mac.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 // Mac OS notifications don't provide a good way to elide the domain (or tell | 141 // Mac OS notifications don't provide a good way to elide the domain (or tell |
| 142 // you the maximum width of the subtitle field). We have experimentally | 142 // you the maximum width of the subtitle field). We have experimentally |
| 143 // determined the maximum number of characters that fit using the widest | 143 // determined the maximum number of characters that fit using the widest |
| 144 // possible character (m). If the domain fits in those character we show it | 144 // possible character (m). If the domain fits in those character we show it |
| 145 // completely. Otherwise we use eTLD + 1. | 145 // completely. Otherwise we use eTLD + 1. |
| 146 | 146 |
| 147 // These numbers have been obtained through experimentation on various | 147 // These numbers have been obtained through experimentation on various |
| 148 // Mac OS platforms. | 148 // Mac OS platforms. |
| 149 | 149 |
| 150 // Corresponds to the string "mmmmmmmmmmmmmm" | 150 constexpr size_t kMaxDomainLenghtAlert = 19; |
| 151 constexpr size_t kMaxDomainLenghtAlert = 14; | 151 constexpr size_t kMaxDomainLenghtBanner = 28; |
| 152 | |
| 153 // Corresponds to the string "mmmmmmmmmmmmmmmmmmmmm" | |
| 154 constexpr size_t kMaxDomainLenghtBanner = 21; | |
| 155 | 152 |
| 156 size_t max_characters = IsPersistentNotification(notification) | 153 size_t max_characters = IsPersistentNotification(notification) |
| 157 ? kMaxDomainLenghtAlert | 154 ? kMaxDomainLenghtAlert |
| 158 : kMaxDomainLenghtBanner; | 155 : kMaxDomainLenghtBanner; |
| 159 | 156 |
| 160 base::string16 origin = url_formatter::FormatOriginForSecurityDisplay( | 157 base::string16 origin = url_formatter::FormatOriginForSecurityDisplay( |
| 161 url::Origin(notification.origin_url()), | 158 url::Origin(notification.origin_url()), |
| 162 url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS); | 159 url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS); |
| 163 | 160 |
| 164 if (origin.size() <= max_characters) | 161 if (origin.size() <= max_characters) |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 base::scoped_nsobject<CrXPCMachPort> xpcPort( | 595 base::scoped_nsobject<CrXPCMachPort> xpcPort( |
| 599 [[CrXPCMachPort alloc] initWithMachSendRight:std::move(exceptionPort)]); | 596 [[CrXPCMachPort alloc] initWithMachSendRight:std::move(exceptionPort)]); |
| 600 [proxy setMachExceptionPort:xpcPort]; | 597 [proxy setMachExceptionPort:xpcPort]; |
| 601 setExceptionPort_ = YES; | 598 setExceptionPort_ = YES; |
| 602 } | 599 } |
| 603 | 600 |
| 604 return proxy; | 601 return proxy; |
| 605 } | 602 } |
| 606 | 603 |
| 607 @end | 604 @end |
| OLD | NEW |