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

Side by Side Diff: ui/base/ios/cru_context_menu_controller.mm

Issue 1144873002: Add a callback for cancelling the context menu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "ui/base/ios/cru_context_menu_controller.h" 5 #import "ui/base/ios/cru_context_menu_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/ios/ios_util.h" 9 #include "base/ios/ios_util.h"
10 #include "base/ios/weak_nsobject.h" 10 #include "base/ios/weak_nsobject.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 void (^actionHandler)(UIAlertAction*) = ^(UIAlertAction* action) { 261 void (^actionHandler)(UIAlertAction*) = ^(UIAlertAction* action) {
262 [menuHolder performActionAtIndex:itemIndex]; 262 [menuHolder performActionAtIndex:itemIndex];
263 [weakSelf setVisible:NO]; 263 [weakSelf setVisible:NO];
264 }; 264 };
265 [alert addAction:[UIAlertAction actionWithTitle:itemTitle 265 [alert addAction:[UIAlertAction actionWithTitle:itemTitle
266 style:UIAlertActionStyleDefault 266 style:UIAlertActionStyleDefault
267 handler:actionHandler]]; 267 handler:actionHandler]];
268 }]; 268 }];
269 269
270 // Cancel button goes last, to match other browsers. 270 // Cancel button goes last, to match other browsers.
271 void (^cancelHandler)(UIAlertAction*) = ^(UIAlertAction* action) {
272 [weakSelf setVisible:NO];
273 };
271 UIAlertAction* cancel_action = 274 UIAlertAction* cancel_action =
272 [UIAlertAction actionWithTitle:l10n_util::GetNSString(IDS_APP_CANCEL) 275 [UIAlertAction actionWithTitle:l10n_util::GetNSString(IDS_APP_CANCEL)
273 style:UIAlertActionStyleCancel 276 style:UIAlertActionStyleCancel
274 handler:nil]; 277 handler:cancelHandler];
275 [alert addAction:cancel_action]; 278 [alert addAction:cancel_action];
276 279
277 // Present sheet/popover using controller that is added to view hierarchy. 280 // Present sheet/popover using controller that is added to view hierarchy.
278 UIViewController* topController = view.window.rootViewController; 281 UIViewController* topController = view.window.rootViewController;
279 while (topController.presentedViewController) 282 while (topController.presentedViewController)
280 topController = topController.presentedViewController; 283 topController = topController.presentedViewController;
281 [topController presentViewController:alert animated:YES completion:nil]; 284 [topController presentViewController:alert animated:YES completion:nil];
282 self.visible = YES; 285 self.visible = YES;
283 } 286 }
284 287
285 @end 288 @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