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

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

Issue 2922573002: [iOS Clean] Ignore compiler warnings for |-performSelector:withObject:|. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_view_controller.h " 5 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_view_controller.h "
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_context.h" 8 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_context.h"
9 9
10 #if !defined(__has_feature) || !__has_feature(objc_arc) 10 #if !defined(__has_feature) || !__has_feature(objc_arc)
11 #error "This file requires ARC support." 11 #error "This file requires ARC support."
12 #endif 12 #endif
13 13
14 namespace { 14 namespace {
15 // Typedef the block parameter for UIAlertAction for readability. 15 // Typedef the block parameter for UIAlertAction for readability.
16 typedef void (^AlertActionHandler)(UIAlertAction*); 16 typedef void (^AlertActionHandler)(UIAlertAction*);
17 // Sends |commands| to |dispatcher| using |context| as the menu context. 17 // Sends |commands| to |dispatcher| using |context| as the menu context.
18 void DispatchContextMenuCommands(const std::vector<SEL>& commands, 18 void DispatchContextMenuCommands(const std::vector<SEL>& commands,
19 id dispatcher, 19 id dispatcher,
20 ContextMenuContext* context) { 20 ContextMenuContext* context) {
21 DCHECK(dispatcher); 21 DCHECK(dispatcher);
22 DCHECK(context); 22 DCHECK(context);
23 #pragma clang diagnostic push
marq (ping after 24h) 2017/06/02 08:28:35 Please add a comment explaining why this is needed
kkhorimoto 2017/06/02 21:17:35 Done.
24 #pragma clang diagnostic ignored "-Warc-performSelector-leaks"
23 for (SEL command : commands) { 25 for (SEL command : commands) {
24 IMP command_imp = [dispatcher methodForSelector:command]; 26 [dispatcher performSelector:command withObject:context];
25 DCHECK(command_imp);
26 command_imp(dispatcher, command, context);
27 } 27 }
28 #pragma clang diagnostic pop
28 } 29 }
29 } 30 }
30 31
31 @interface ContextMenuViewController () 32 @interface ContextMenuViewController ()
32 // The dispatcher passed on initialization. 33 // The dispatcher passed on initialization.
33 @property(nonatomic, readonly, weak) id<ContextMenuCommands> dispatcher; 34 @property(nonatomic, readonly, weak) id<ContextMenuCommands> dispatcher;
34 // The context passed on initialization. 35 // The context passed on initialization.
35 @property(nonatomic, strong) ContextMenuContext* context; 36 @property(nonatomic, strong) ContextMenuContext* context;
36 37
37 // Creates an UIAlertAction for |item| using |style| to manage the action's 38 // Creates an UIAlertAction for |item| using |style| to manage the action's
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 style:(UIAlertActionStyle)style { 86 style:(UIAlertActionStyle)style {
86 DCHECK(item); 87 DCHECK(item);
87 // Create a block that dispatches |item|'s ContextMenuCommands. 88 // Create a block that dispatches |item|'s ContextMenuCommands.
88 AlertActionHandler handler = ^(UIAlertAction* action) { 89 AlertActionHandler handler = ^(UIAlertAction* action) {
89 DispatchContextMenuCommands(item.commands, self.dispatcher, self.context); 90 DispatchContextMenuCommands(item.commands, self.dispatcher, self.context);
90 }; 91 };
91 return [UIAlertAction actionWithTitle:item.title style:style handler:handler]; 92 return [UIAlertAction actionWithTitle:item.title style:style handler:handler];
92 } 93 }
93 94
94 @end 95 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698