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

Unified Diff: chrome/browser/ui/cocoa/browser_window_touch_bar.mm

Issue 2933583002: [Mac] Fullscreen Touch Bar URL Adjustments (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698