| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chrome/browser/ui/cocoa/browser_window_touch_bar.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_touch_bar.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 content::WebContents* contents = | 317 content::WebContents* contents = |
| 318 browser_->tab_strip_model()->GetActiveWebContents(); | 318 browser_->tab_strip_model()->GetActiveWebContents(); |
| 319 GURL originUrl = contents->GetLastCommittedURL(); | 319 GURL originUrl = contents->GetLastCommittedURL(); |
| 320 | 320 |
| 321 base::string16 displayText = base::ASCIIToUTF16(originUrl.spec()); | 321 base::string16 displayText = base::ASCIIToUTF16(originUrl.spec()); |
| 322 base::scoped_nsobject<NSMutableAttributedString> attributedString( | 322 base::scoped_nsobject<NSMutableAttributedString> attributedString( |
| 323 [[NSMutableAttributedString alloc] | 323 [[NSMutableAttributedString alloc] |
| 324 initWithString:base::SysUTF16ToNSString(displayText)]); | 324 initWithString:base::SysUTF16ToNSString(displayText)]); |
| 325 | 325 |
| 326 if (originUrl.has_path()) { | 326 if (originUrl.has_path()) { |
| 327 size_t pathLength = originUrl.path().length() - 1; | 327 size_t pathIndex = originUrl.GetWithEmptyPath().spec().length(); |
| 328 [attributedString | 328 [attributedString |
| 329 addAttribute:NSForegroundColorAttributeName | 329 addAttribute:NSForegroundColorAttributeName |
| 330 value:OmniboxViewMac::BaseTextColor(true) | 330 value:OmniboxViewMac::BaseTextColor(true) |
| 331 range:NSMakeRange([attributedString length] - pathLength, | 331 range:NSMakeRange(pathIndex, |
| 332 pathLength)]; | 332 [attributedString length] - pathIndex)]; |
| 333 } | 333 } |
| 334 | 334 |
| 335 [touchBarItem | 335 [touchBarItem |
| 336 setView:[NSTextField labelWithAttributedString:attributedString.get()]]; | 336 setView:[NSTextField labelWithAttributedString:attributedString.get()]]; |
| 337 } else if ([identifier hasSuffix:kExitFullscreenTouchId]) { | 337 } else if ([identifier hasSuffix:kExitFullscreenTouchId]) { |
| 338 return nil; | 338 return nil; |
| 339 } | 339 } |
| 340 | 340 |
| 341 return touchBarItem.autorelease(); | 341 return touchBarItem.autorelease(); |
| 342 } | 342 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 ->ExitExclusiveAccessIfNecessary(); | 477 ->ExitExclusiveAccessIfNecessary(); |
| 478 } | 478 } |
| 479 | 479 |
| 480 - (void)executeCommand:(id)sender { | 480 - (void)executeCommand:(id)sender { |
| 481 int command = [sender tag]; | 481 int command = [sender tag]; |
| 482 LogTouchBarUMA(command); | 482 LogTouchBarUMA(command); |
| 483 commandUpdater_->ExecuteCommand(command); | 483 commandUpdater_->ExecuteCommand(command); |
| 484 } | 484 } |
| 485 | 485 |
| 486 @end | 486 @end |
| OLD | NEW |