| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/mac/scoped_nsobject.h" | 5 #import "base/mac/scoped_nsobject.h" |
| 6 #import "base/mac/sdk_forward_declarations.h" | 6 #import "base/mac/sdk_forward_declarations.h" |
| 7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
| 8 #import "ui/base/cocoa/touch_bar_forward_declarations.h" | 8 #import "ui/base/cocoa/touch_bar_forward_declarations.h" |
| 9 #include "ui/base/models/dialog_model.h" | 9 #include "ui/base/models/dialog_model.h" |
| 10 #import "ui/views/cocoa/bridged_content_view.h" | 10 #import "ui/views/cocoa/bridged_content_view.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 if ([identifier isEqualToString:kTouchBarDialogButtonsGroupId]) { | 55 if ([identifier isEqualToString:kTouchBarDialogButtonsGroupId]) { |
| 56 NSMutableArray* items = [NSMutableArray arrayWithCapacity:2]; | 56 NSMutableArray* items = [NSMutableArray arrayWithCapacity:2]; |
| 57 for (NSTouchBarItemIdentifier i in @[ kTouchBarCancelId, kTouchBarOKId ]) { | 57 for (NSTouchBarItemIdentifier i in @[ kTouchBarCancelId, kTouchBarOKId ]) { |
| 58 NSTouchBarItem* item = [self touchBar:touchBar makeItemForIdentifier:i]; | 58 NSTouchBarItem* item = [self touchBar:touchBar makeItemForIdentifier:i]; |
| 59 if (item) | 59 if (item) |
| 60 [items addObject:item]; | 60 [items addObject:item]; |
| 61 } | 61 } |
| 62 if ([items count] == 0) | 62 if ([items count] == 0) |
| 63 return nil; | 63 return nil; |
| 64 return [NSGroupTouchBarItem groupItemWithIdentifier:identifier items:items]; | 64 return [NSClassFromString(@"NSGroupTouchBarItem") |
| 65 groupItemWithIdentifier:identifier |
| 66 items:items]; |
| 65 } | 67 } |
| 66 | 68 |
| 67 ui::DialogButton type = ui::DIALOG_BUTTON_NONE; | 69 ui::DialogButton type = ui::DIALOG_BUTTON_NONE; |
| 68 if ([identifier isEqualToString:kTouchBarOKId]) | 70 if ([identifier isEqualToString:kTouchBarOKId]) |
| 69 type = ui::DIALOG_BUTTON_OK; | 71 type = ui::DIALOG_BUTTON_OK; |
| 70 else if ([identifier isEqualToString:kTouchBarCancelId]) | 72 else if ([identifier isEqualToString:kTouchBarCancelId]) |
| 71 type = ui::DIALOG_BUTTON_CANCEL; | 73 type = ui::DIALOG_BUTTON_CANCEL; |
| 72 else | 74 else |
| 73 return nil; | 75 return nil; |
| 74 | 76 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 118 |
| 117 // Use a group rather than individual items so they can be centered together. | 119 // Use a group rather than individual items so they can be centered together. |
| 118 [bar setDefaultItemIdentifiers:@[ kTouchBarDialogButtonsGroupId ]]; | 120 [bar setDefaultItemIdentifiers:@[ kTouchBarDialogButtonsGroupId ]]; |
| 119 | 121 |
| 120 // Setting the group as principal will center it in the TouchBar. | 122 // Setting the group as principal will center it in the TouchBar. |
| 121 [bar setPrincipalItemIdentifier:kTouchBarDialogButtonsGroupId]; | 123 [bar setPrincipalItemIdentifier:kTouchBarDialogButtonsGroupId]; |
| 122 return bar.autorelease(); | 124 return bar.autorelease(); |
| 123 } | 125 } |
| 124 | 126 |
| 125 @end | 127 @end |
| OLD | NEW |