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

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

Issue 2921083003: [Mac] Touch Bar Support for Dialogs (Closed)
Patch Set: nits Created 3 years, 7 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
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 3f617bd4a183aabe00c89c0d031580a1492a025f..07936050f9b1b507ee9ca70cdad370ef357c9cb1 100644
--- a/chrome/browser/ui/cocoa/browser_window_touch_bar.mm
+++ b/chrome/browser/ui/cocoa/browser_window_touch_bar.mm
@@ -6,7 +6,6 @@
#include <memory>
-#include "base/mac/foundation_util.h"
#include "base/mac/mac_util.h"
#import "base/mac/scoped_nsobject.h"
#import "base/mac/sdk_forward_declarations.h"
@@ -33,6 +32,7 @@
#include "components/strings/grit/components_strings.h"
#include "components/toolbar/vector_icons.h"
#include "content/public/browser/web_contents.h"
+#import "ui/base/cocoa/touch_bar_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_mac.h"
#include "ui/gfx/color_palette.h"
@@ -109,12 +109,6 @@ NSButton* CreateTouchBarButton(const gfx::VectorIcon& icon,
return button;
}
-NSString* GetTouchBarId(NSString* touch_bar_id) {
- NSString* chrome_bundle_id =
- base::SysUTF8ToNSString(base::mac::BaseBundleID());
- return [NSString stringWithFormat:@"%@.%@", chrome_bundle_id, touch_bar_id];
-}
-
TouchBarAction TouchBarActionFromCommand(int command) {
switch (command) {
case IDC_BACK:
@@ -196,12 +190,6 @@ class HomePrefNotificationBridge {
@synthesize isPageLoading = isPageLoading_;
@synthesize isStarred = isStarred_;
-+ (NSString*)identifierForTouchBarId:(NSString*)touchBarId
- itemId:(NSString*)itemId {
- return
- [NSString stringWithFormat:@"%@-%@", GetTouchBarId(touchBarId), itemId];
-}
-
- (instancetype)initWithBrowser:(Browser*)browser
browserWindowController:(BrowserWindowController*)bwc {
if ((self = [self init])) {
@@ -233,7 +221,8 @@ class HomePrefNotificationBridge {
base::scoped_nsobject<NSTouchBar> touchBar(
[[NSClassFromString(@"NSTouchBar") alloc] init]);
- [touchBar setCustomizationIdentifier:GetTouchBarId(kBrowserWindowTouchBarId)];
+ [touchBar setCustomizationIdentifier:ui::CreateTouchBarId(
+ kBrowserWindowTouchBarId)];
[touchBar setDelegate:self];
NSMutableArray* customIdentifiers = [NSMutableArray arrayWithCapacity:7];
@@ -246,8 +235,7 @@ class HomePrefNotificationBridge {
for (NSString* item in touchBarItems) {
NSString* itemIdentifier =
- [BrowserWindowTouchBar identifierForTouchBarId:kBrowserWindowTouchBarId
- itemId:item];
+ ui::CreateTouchBarItemId(kBrowserWindowTouchBarId, item);
[customIdentifiers addObject:itemIdentifier];
// Don't add the home button if it's not shown in the toolbar.
@@ -348,15 +336,12 @@ class HomePrefNotificationBridge {
if ([touchBar respondsToSelector:
@selector(setEscapeKeyReplacementItemIdentifier:)]) {
- NSString* exitIdentifier =
- [BrowserWindowTouchBar identifierForTouchBarId:kTabFullscreenTouchBarId
- itemId:kExitFullscreenTouchId];
+ NSString* exitIdentifier = ui::CreateTouchBarItemId(
+ kTabFullscreenTouchBarId, kExitFullscreenTouchId);
[touchBar setEscapeKeyReplacementItemIdentifier:exitIdentifier];
- [touchBar setDefaultItemIdentifiers:@[
- [BrowserWindowTouchBar
- identifierForTouchBarId:kTabFullscreenTouchBarId
- itemId:kFullscreenOriginLabelTouchId]
- ]];
+ [touchBar setDefaultItemIdentifiers:@[ ui::CreateTouchBarItemId(
+ kTabFullscreenTouchBarId,
+ kFullscreenOriginLabelTouchId) ]];
base::scoped_nsobject<NSCustomTouchBarItem> touchBarItem(
[[NSClassFromString(@"NSCustomTouchBarItem") alloc]

Powered by Google App Engine
This is Rietveld 408576698