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

Side by Side Diff: ios/clean/chrome/browser/ui/context_menu/context_menu_item.mm

Issue 2917973002: [iOS Clean] Update ContextMenuItem to use a single command. (Closed)
Patch Set: rebase Created 3 years, 6 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 unified diff | Download patch
OLDNEW
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 "ios/clean/chrome/browser/ui/context_menu/context_menu_item.h" 5 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_item.h"
6 6
7 #if !defined(__has_feature) || !__has_feature(objc_arc) 7 #if !defined(__has_feature) || !__has_feature(objc_arc)
8 #error "This file requires ARC support." 8 #error "This file requires ARC support."
9 #endif 9 #endif
10 10
11 @interface ContextMenuItem () { 11 @interface ContextMenuItem ()
12 // Backing object for |commands|.
13 std::vector<SEL> _commands;
14 }
15 12
16 // Convenience initializer for use by the factory method. 13 // Convenience initializer for use by the factory method.
17 - (instancetype)initWithTitle:(NSString*)title 14 - (instancetype)initWithTitle:(NSString*)title
18 commands:(const std::vector<SEL>&)commands; 15 command:(SEL)command
16 commandOpensTab:(BOOL)commandOpensTab NS_DESIGNATED_INITIALIZER;
19 17
20 @end 18 @end
21 19
22 @implementation ContextMenuItem 20 @implementation ContextMenuItem
23 21
24 @synthesize title = _title; 22 @synthesize title = _title;
23 @synthesize command = _command;
24 @synthesize commandOpensTab = _commandOpensTab;
25 25
26 - (instancetype)initWithTitle:(NSString*)title 26 - (instancetype)initWithTitle:(NSString*)title
27 commands:(const std::vector<SEL>&)commands { 27 command:(SEL)command
28 commandOpensTab:(BOOL)commandOpensTab {
28 if ((self = [super init])) { 29 if ((self = [super init])) {
29 _title = [title copy]; 30 _title = [title copy];
30 _commands = commands; 31 _command = command;
32 _commandOpensTab = commandOpensTab;
31 } 33 }
32 return self; 34 return self;
33 } 35 }
34 36
35 #pragma mark - Accessors
36
37 - (const std::vector<SEL>&)commands {
38 return _commands;
39 }
40
41 #pragma mark - Public 37 #pragma mark - Public
42 38
43 + (instancetype)itemWithTitle:(NSString*)title 39 + (instancetype)itemWithTitle:(NSString*)title
44 commands:(const std::vector<SEL>&)commands { 40 command:(SEL)command
45 return [[ContextMenuItem alloc] initWithTitle:title commands:commands]; 41 commandOpensTab:(BOOL)commandOpensTab {
42 return [[ContextMenuItem alloc] initWithTitle:title
43 command:command
44 commandOpensTab:commandOpensTab];
46 } 45 }
47 46
48 @end 47 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698