| Index: chrome/browser/ui/cocoa/browser_window_touch_bar.mm
|
| diff --git a/chrome/browser/ui/cocoa/browser_window_touch_bar.mm b/chrome/browser/ui/cocoa/browser_window_touch_bar.mm
|
| index 7d13ad7bb345bf5dd1db2d53bba8d88e93249d5a..ddda4d0657c1f7bc30610acd959d5c7757172cc9 100644
|
| --- a/chrome/browser/ui/cocoa/browser_window_touch_bar.mm
|
| +++ b/chrome/browser/ui/cocoa/browser_window_touch_bar.mm
|
| @@ -32,6 +32,7 @@
|
| #include "components/search_engines/util.h"
|
| #include "components/strings/grit/components_strings.h"
|
| #include "components/toolbar/vector_icons.h"
|
| +#include "components/url_formatter/url_formatter.h"
|
| #include "content/public/browser/web_contents.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/base/l10n/l10n_util_mac.h"
|
| @@ -316,15 +317,23 @@ class HomePrefNotificationBridge {
|
| } else if ([identifier hasSuffix:kFullscreenOriginLabelTouchId]) {
|
| content::WebContents* contents =
|
| browser_->tab_strip_model()->GetActiveWebContents();
|
| - GURL originUrl = contents->GetLastCommittedURL();
|
|
|
| - base::string16 displayText = base::ASCIIToUTF16(originUrl.spec());
|
| + if (!contents)
|
| + return nil;
|
| +
|
| + // Strip the trailing slash.
|
| + url::Parsed parsed;
|
| + base::string16 displayText = url_formatter::FormatUrl(
|
| + contents->GetLastCommittedURL(),
|
| + url_formatter::kFormatUrlOmitTrailingSlashOnBareHostname,
|
| + net::UnescapeRule::SPACES, &parsed, nullptr, nullptr);
|
| +
|
| base::scoped_nsobject<NSMutableAttributedString> attributedString(
|
| [[NSMutableAttributedString alloc]
|
| initWithString:base::SysUTF16ToNSString(displayText)]);
|
|
|
| - if (originUrl.has_path()) {
|
| - size_t pathIndex = originUrl.GetWithEmptyPath().spec().length();
|
| + if (parsed.path.is_nonempty()) {
|
| + size_t pathIndex = parsed.path.begin;
|
| [attributedString
|
| addAttribute:NSForegroundColorAttributeName
|
| value:OmniboxViewMac::BaseTextColor(true)
|
|
|