Commit 711663d3 authored by Avi Drissman's avatar Avi Drissman Committed by Commit Bot

Make the fullscreen touchbar customizable

Users might not like the URL display on the touchbar in fullscreen.
This CL makes the fullscreen touchbar customizable. Right now, that
means that the user can add or remove the single item in it (the
URL display) but that should help for the case in the bug.

Fixed: 1135102
Change-Id: I99e3ca0d4d9d6575a0ec79ab3329e54613475e7b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2464080
Commit-Queue: Leonard Grey <lgrey@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Reviewed-by: default avatarLeonard Grey <lgrey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816197}
parent 178f90e5
...@@ -2247,6 +2247,10 @@ are declared in tools/grit/grit_rule.gni. ...@@ -2247,6 +2247,10 @@ are declared in tools/grit/grit_rule.gni.
desc="Customization label for the new tab button in the touch bar."> desc="Customization label for the new tab button in the touch bar.">
New Tab New Tab
</message> </message>
<message name="IDS_TOUCH_BAR_URL_CUSTOMIZATION_LABEL"
desc="Customization label for the URL field in the touch bar.">
Page URL
</message>
</if> </if>
<!-- Abandon in-progress downloads confirmation dialog --> <!-- Abandon in-progress downloads confirmation dialog -->
......
6c6e424489528fd834c66f8eeb477cb5d49cd7c2
\ No newline at end of file
...@@ -273,6 +273,9 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge ...@@ -273,6 +273,9 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge
base::scoped_nsobject<NSButton> _starredButton; base::scoped_nsobject<NSButton> _starredButton;
} }
// Creates and returns a touch bar for tab non-fullscreen mode.
- (NSTouchBar*)createTabTouchBar;
// Creates and returns a touch bar for tab fullscreen mode. // Creates and returns a touch bar for tab fullscreen mode.
- (NSTouchBar*)createTabFullscreenTouchBar; - (NSTouchBar*)createTabFullscreenTouchBar;
...@@ -304,37 +307,7 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge ...@@ -304,37 +307,7 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge
return [self createTabFullscreenTouchBar]; return [self createTabFullscreenTouchBar];
} }
base::scoped_nsobject<NSTouchBar> touchBar([[NSTouchBar alloc] init]); return [self createTabTouchBar];
[touchBar
setCustomizationIdentifier:ui::GetTouchBarId(kBrowserWindowTouchBarId)];
[touchBar setDelegate:self];
NSMutableArray<NSString*>* customIdentifiers = [NSMutableArray array];
NSMutableArray<NSString*>* defaultIdentifiers = [NSMutableArray array];
NSArray<NSString*>* touchBarItems = @[
kBackTouchId, kForwardTouchId, kReloadOrStopTouchId, kHomeTouchId,
kSearchTouchId, kStarTouchId, kNewTabTouchId
];
for (NSString* item in touchBarItems) {
NSString* itemIdentifier =
ui::GetTouchBarItemId(kBrowserWindowTouchBarId, item);
[customIdentifiers addObject:itemIdentifier];
// Don't add the home button if it's not shown in the toolbar.
if (item == kHomeTouchId && !_notificationBridge->show_home_button())
continue;
[defaultIdentifiers addObject:itemIdentifier];
}
[customIdentifiers addObject:NSTouchBarItemIdentifierFlexibleSpace];
[touchBar setDefaultItemIdentifiers:defaultIdentifiers];
[touchBar setCustomizationAllowedItemIdentifiers:customIdentifiers];
return touchBar.autorelease();
} }
- (NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar - (NSTouchBarItem*)touchBar:(NSTouchBar*)touchBar
...@@ -435,6 +408,9 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge ...@@ -435,6 +408,9 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge
[touchBarItem [touchBarItem
setView:[NSTextField labelWithAttributedString:attributedString.get()]]; setView:[NSTextField labelWithAttributedString:attributedString.get()]];
[touchBarItem
setCustomizationLabel:l10n_util::GetNSString(
IDS_TOUCH_BAR_URL_CUSTOMIZATION_LABEL)];
} else { } else {
return nil; return nil;
} }
...@@ -442,12 +418,52 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge ...@@ -442,12 +418,52 @@ class API_AVAILABLE(macos(10.12.2)) TouchBarNotificationBridge
return touchBarItem.autorelease(); return touchBarItem.autorelease();
} }
- (NSTouchBar*)createTabTouchBar {
base::scoped_nsobject<NSTouchBar> touchBar([[NSTouchBar alloc] init]);
[touchBar
setCustomizationIdentifier:ui::GetTouchBarId(kBrowserWindowTouchBarId)];
[touchBar setDelegate:self];
NSMutableArray<NSString*>* customIdentifiers = [NSMutableArray array];
NSMutableArray<NSString*>* defaultIdentifiers = [NSMutableArray array];
NSArray<NSString*>* touchBarItems = @[
kBackTouchId, kForwardTouchId, kReloadOrStopTouchId, kHomeTouchId,
kSearchTouchId, kStarTouchId, kNewTabTouchId
];
for (NSString* item in touchBarItems) {
NSString* itemIdentifier =
ui::GetTouchBarItemId(kBrowserWindowTouchBarId, item);
[customIdentifiers addObject:itemIdentifier];
// Don't add the home button if it's not shown in the toolbar.
if (item == kHomeTouchId && !_notificationBridge->show_home_button())
continue;
[defaultIdentifiers addObject:itemIdentifier];
}
[customIdentifiers addObject:NSTouchBarItemIdentifierFlexibleSpace];
[touchBar setDefaultItemIdentifiers:defaultIdentifiers];
[touchBar setCustomizationAllowedItemIdentifiers:customIdentifiers];
return touchBar.autorelease();
}
- (NSTouchBar*)createTabFullscreenTouchBar { - (NSTouchBar*)createTabFullscreenTouchBar {
base::scoped_nsobject<NSTouchBar> touchBar([[NSTouchBar alloc] init]); base::scoped_nsobject<NSTouchBar> touchBar([[NSTouchBar alloc] init]);
[touchBar
setCustomizationIdentifier:ui::GetTouchBarId(kTabFullscreenTouchBarId)];
[touchBar setDelegate:self]; [touchBar setDelegate:self];
[touchBar setDefaultItemIdentifiers:@[ ui::GetTouchBarItemId(
kTabFullscreenTouchBarId, NSArray<NSString*>* touchBarItems = @[ ui::GetTouchBarItemId(
kFullscreenOriginLabelTouchId) ]]; kTabFullscreenTouchBarId, kFullscreenOriginLabelTouchId) ];
[touchBar setDefaultItemIdentifiers:touchBarItems];
[touchBar setCustomizationAllowedItemIdentifiers:touchBarItems];
return touchBar.autorelease(); return touchBar.autorelease();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment