Chromium Code Reviews| Index: ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.mm |
| diff --git a/ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.mm b/ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..443727449236b40e4560bd12549de6fb85d48f61 |
| --- /dev/null |
| +++ b/ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.mm |
| @@ -0,0 +1,57 @@ |
| +// 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_coordinator.h" |
| + |
| +#import "base/ios/weak_nsobject.h" |
| +#import "base/mac/scoped_nsobject.h" |
| +#import "ios/chrome/browser/ui/alert_coordinator/alert_controller_coordinator+subclassing.h" |
| +#import "ios/web/public/web_state/context_menu_params.h" |
| +#include "ui/base/l10n/l10n_util.h" |
| +#include "ui/strings/grit/ui_strings.h" |
| + |
| +@interface ActionSheetCoordinator () { |
| + // Parameters that define what is shown in the context menu. |
| + web::ContextMenuParams _params; |
|
lpromero
2016/07/06 09:03:59
// weak?
gambard
2016/07/07 08:57:42
It is not pointer. Should it be weak?
|
| +} |
| + |
| +@end |
| + |
| +@implementation ActionSheetCoordinator |
| + |
| +- (instancetype)initWithViewController:(UIViewController*)viewController |
| + params:(const web::ContextMenuParams&)params { |
| + self = [super initWithBaseViewController:viewController]; |
| + if (self) { |
| + _params = params; |
| + } |
| + return self; |
| +} |
| + |
| +#pragma mark - Private Methods |
| + |
| +- (BOOL)shouldStart { |
| + // Check that the view is still visible on screen, otherwise just return and |
| + // don't show the context menu. |
| + return [_params.view window] || [_params.view isKindOfClass:[UIWindow class]]; |
| +} |
| + |
| +- (UIAlertController*)createAlertController { |
| + DCHECK([_params.view isDescendantOfView:[self.baseViewController view]]); |
| + UIAlertController* alert = [UIAlertController |
| + alertControllerWithTitle:_params.menu_title |
| + message:self.message |
| + preferredStyle:UIAlertControllerStyleActionSheet]; |
| + alert.popoverPresentationController.sourceView = _params.view; |
| + alert.popoverPresentationController.sourceRect = |
| + CGRectMake(_params.location.x, _params.location.y, 1.0, 1.0); |
| + |
| + return alert; |
|
lpromero
2016/07/06 09:03:58
If renamed newAlertController, you need to return
gambard
2016/07/07 08:57:42
Acknowledged.
|
| +} |
| + |
| +- (BOOL)shouldCreateCancelButtonAtCreation { |
| + return YES; |
| +} |
| + |
| +@end |