Chromium Code Reviews| Index: ios/chrome/browser/ui/alert_coordinator/action_sheet.mm |
| diff --git a/ios/chrome/browser/ui/alert_coordinator/action_sheet.mm b/ios/chrome/browser/ui/alert_coordinator/action_sheet.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..01471fe65d206fbd1e5613d8f472085219fd6254 |
| --- /dev/null |
| +++ b/ios/chrome/browser/ui/alert_coordinator/action_sheet.mm |
| @@ -0,0 +1,54 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "ios/chrome/browser/ui/alert_coordinator/action_sheet.h" |
| + |
| +#import "ios/web/public/web_state/context_menu_params.h" |
| + |
| +@interface ActionSheet () { |
| + // Parameters that define what is shown in the context menu. |
|
lpromero
2016/07/18 12:11:35
This comment should rather be in the header.
More
|
| + web::ContextMenuParams _params; |
| +} |
| + |
| +@end |
| + |
| +@implementation ActionSheet |
| + |
| +- (instancetype)initWithParams:(const web::ContextMenuParams&)params { |
| + self = [super init]; |
| + if (self) { |
| + _params = params; |
| + } |
| + return self; |
| +} |
| + |
| +#pragma mark - Private Methods |
|
lpromero
2016/07/18 12:11:35
These are AlertCoordinatorDelegate methods, not pr
|
| + |
| +- (BOOL)alertCoordinatorShouldStart:(AlertCoordinator*)alertCoordinator { |
| + // Check that the view is still visible on screen, otherwise just return and |
| + // don't show the context menu. |
|
lpromero
2016/07/18 12:11:35
Idem s/context menu/action sheet.
|
| + return [_params.view window] || [_params.view isKindOfClass:[UIWindow class]]; |
| +} |
| + |
| +- (UIAlertController*)alertCoordinatorUIAlertController: |
| + (AlertCoordinator*)alertCoordinator { |
| + DCHECK([_params.view |
| + isDescendantOfView:[alertCoordinator.baseViewController view]]); |
| + UIAlertController* alert = [UIAlertController |
|
marq (ping after 24h)
2016/07/18 13:02:41
I don't like the idea of a coordinator being hande
|
| + alertControllerWithTitle:_params.menu_title |
| + message:alertCoordinator.message |
| + preferredStyle:UIAlertControllerStyleActionSheet]; |
| + alert.popoverPresentationController.sourceView = _params.view; |
| + alert.popoverPresentationController.sourceRect = |
| + CGRectMake(_params.location.x, _params.location.y, 1.0, 1.0); |
|
lpromero
2016/07/18 12:11:35
Is the location passed in params already localized
gambard
2016/07/18 12:40:20
I am looking into it.
|
| + |
| + return alert; |
| +} |
| + |
| +- (BOOL)alertCoordinatorShouldAddCancelButton: |
| + (AlertCoordinator*)alertCoordinator { |
| + return YES; |
| +} |
| + |
| +@end |