| 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 a8400112461baf35401c8cbdb27d6f96eb260726..88495e0a1b04bac442fe3c3aa179e2e237c412a8 100644
|
| --- a/chrome/browser/ui/cocoa/browser_window_touch_bar.mm
|
| +++ b/chrome/browser/ui/cocoa/browser_window_touch_bar.mm
|
| @@ -54,15 +54,21 @@ enum TouchBarAction {
|
|
|
| // The touch bar's identifier.
|
| const NSTouchBarCustomizationIdentifier kBrowserWindowTouchBarId =
|
| - @"BrowserWindowTouchBarId";
|
| + @"com.google.chrome.browser-window";
|
|
|
| // Touch bar items identifiers.
|
| -const NSTouchBarItemIdentifier kBackForwardTouchId = @"BackForwardTouchId";
|
| -const NSTouchBarItemIdentifier kReloadOrStopTouchId = @"ReloadOrStopTouchId";
|
| -const NSTouchBarItemIdentifier kHomeTouchId = @"HomeTouchId";
|
| -const NSTouchBarItemIdentifier kSearchTouchId = @"SearchTouchId";
|
| -const NSTouchBarItemIdentifier kStarTouchId = @"StarTouchId";
|
| -const NSTouchBarItemIdentifier kNewTabTouchId = @"NewTabTouchId";
|
| +const NSTouchBarItemIdentifier kBackForwardTouchId =
|
| + @"com.google.chrome.browser-window-BACK-FWD";
|
| +const NSTouchBarItemIdentifier kReloadOrStopTouchId =
|
| + @"com.google.chrome.browser-window-RELOAD-STOP";
|
| +const NSTouchBarItemIdentifier kHomeTouchId =
|
| + @"com.google.chrome.browser-window-HOME";
|
| +const NSTouchBarItemIdentifier kSearchTouchId =
|
| + @"com.google.chrome.browser-window--SEARCH";
|
| +const NSTouchBarItemIdentifier kStarTouchId =
|
| + @"com.google.chrome.browser-window-BOOKMARK";
|
| +const NSTouchBarItemIdentifier kNewTabTouchId =
|
| + @"com.google.chrome.browser-window-NEW-TAB";
|
|
|
| // The button indexes in the back and forward segment control.
|
| const int kBackSegmentIndex = 0;
|
| @@ -75,9 +81,8 @@ const SkColor kTouchBarStarActiveColor = gfx::kGoogleBlue500;
|
| // The size of the touch bar icons.
|
| const int kTouchBarIconSize = 16;
|
|
|
| -// The width of the search button in the touch bar.
|
| -const int kSearchBtnWidthWithHomeBtn = 205;
|
| -const int kSearchBtnWidthWithoutHomeBtn = 280;
|
| +// The min width of the search button in the touch bar.
|
| +const int kSearchBtnMinWidth = 205;
|
|
|
| // Creates an NSImage from the given VectorIcon.
|
| NSImage* CreateNSImageFromIcon(const gfx::VectorIcon& icon,
|
| @@ -206,6 +211,10 @@ class HomePrefNotificationBridge {
|
| base::scoped_nsobject<NSTouchBar> touchBar(
|
| [[NSClassFromString(@"NSTouchBar") alloc] init]);
|
| NSArray* touchBarItemIdentifiers;
|
| + NSArray* customTouchBarItemIdentifiers = @[
|
| + kBackForwardTouchId, kReloadOrStopTouchId, kHomeTouchId, kSearchTouchId,
|
| + kStarTouchId, kNewTabTouchId, NSTouchBarItemIdentifierFlexibleSpace
|
| + ];
|
| if (showHomeButton_.GetValue()) {
|
| touchBarItemIdentifiers = @[
|
| kBackForwardTouchId, kReloadOrStopTouchId, kHomeTouchId, kSearchTouchId,
|
| @@ -220,7 +229,8 @@ class HomePrefNotificationBridge {
|
|
|
| [touchBar setCustomizationIdentifier:kBrowserWindowTouchBarId];
|
| [touchBar setDefaultItemIdentifiers:touchBarItemIdentifiers];
|
| - [touchBar setCustomizationAllowedItemIdentifiers:touchBarItemIdentifiers];
|
| + [touchBar
|
| + setCustomizationAllowedItemIdentifiers:customTouchBarItemIdentifiers];
|
| [touchBar setDelegate:self];
|
|
|
| return touchBar.autorelease();
|
| @@ -235,6 +245,9 @@ class HomePrefNotificationBridge {
|
| @"NSCustomTouchBarItem") alloc] initWithIdentifier:identifier]);
|
| if ([identifier isEqualTo:kBackForwardTouchId]) {
|
| [touchBarItem setView:[self backOrForwardTouchBarView]];
|
| + [touchBarItem setCustomizationLabel:
|
| + l10n_util::GetNSString(
|
| + IDS_TOUCH_BAR_BACK_FORWARD_CUSTOMIZATION_LABEL)];
|
| } else if ([identifier isEqualTo:kReloadOrStopTouchId]) {
|
| const gfx::VectorIcon& icon =
|
| isPageLoading_ ? kNavigateStopIcon : kNavigateReloadIcon;
|
| @@ -242,13 +255,22 @@ class HomePrefNotificationBridge {
|
| int tooltipId = isPageLoading_ ? IDS_TOOLTIP_STOP : IDS_TOOLTIP_RELOAD;
|
| [touchBarItem
|
| setView:CreateTouchBarButton(icon, self, commandId, tooltipId)];
|
| + [touchBarItem setCustomizationLabel:
|
| + l10n_util::GetNSString(
|
| + IDS_TOUCH_BAR_STOP_RELOAD_CUSTOMIZATION_LABEL)];
|
| } else if ([identifier isEqualTo:kHomeTouchId]) {
|
| [touchBarItem setView:CreateTouchBarButton(kNavigateHomeIcon, self,
|
| IDC_HOME, IDS_TOOLTIP_HOME)];
|
| + [touchBarItem
|
| + setCustomizationLabel:l10n_util::GetNSString(
|
| + IDS_TOUCH_BAR_HOME_CUSTOMIZATION_LABEL)];
|
| } else if ([identifier isEqualTo:kNewTabTouchId]) {
|
| [touchBarItem
|
| setView:CreateTouchBarButton(kNewTabMacTouchbarIcon, self, IDC_NEW_TAB,
|
| IDS_TOOLTIP_NEW_TAB)];
|
| + [touchBarItem
|
| + setCustomizationLabel:l10n_util::GetNSString(
|
| + IDS_TOUCH_BAR_NEW_TAB_CUSTOMIZATION_LABEL)];
|
| } else if ([identifier isEqualTo:kStarTouchId]) {
|
| const gfx::VectorIcon& icon =
|
| isStarred_ ? toolbar::kStarActiveIcon : toolbar::kStarIcon;
|
| @@ -257,8 +279,13 @@ class HomePrefNotificationBridge {
|
| int tooltipId = isStarred_ ? IDS_TOOLTIP_STARRED : IDS_TOOLTIP_STAR;
|
| [touchBarItem setView:CreateTouchBarButton(icon, self, IDC_BOOKMARK_PAGE,
|
| tooltipId, iconColor)];
|
| + [touchBarItem
|
| + setCustomizationLabel:l10n_util::GetNSString(
|
| + IDS_TOUCH_BAR_BOOKMARK_CUSTOMIZATION_LABEL)];
|
| } else if ([identifier isEqualTo:kSearchTouchId]) {
|
| [touchBarItem setView:[self searchTouchBarView]];
|
| + [touchBarItem setCustomizationLabel:l10n_util::GetNSString(
|
| + IDS_TOUCH_BAR_GOOGLE_SEARCH)];
|
| }
|
|
|
| return touchBarItem.autorelease();
|
| @@ -329,9 +356,12 @@ class HomePrefNotificationBridge {
|
| action:@selector(executeCommand:)];
|
| searchButton.imageHugsTitle = YES;
|
| searchButton.tag = IDC_FOCUS_LOCATION;
|
| - int width = showHomeButton_.GetValue() ? kSearchBtnWidthWithHomeBtn
|
| - : kSearchBtnWidthWithoutHomeBtn;
|
| - [searchButton.widthAnchor constraintEqualToConstant:width].active = YES;
|
| + [searchButton.widthAnchor
|
| + constraintGreaterThanOrEqualToConstant:kSearchBtnMinWidth]
|
| + .active = YES;
|
| + [searchButton
|
| + setContentHuggingPriority:1.0
|
| + forOrientation:NSLayoutConstraintOrientationHorizontal];
|
| return searchButton;
|
| }
|
|
|
|
|