OLD | NEW |
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 Loading... |
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 |
OLD | NEW |