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

Unified Diff: ios/chrome/browser/ui/alert_coordinator/action_sheet_coordinator.mm

Issue 2119373002: Creates coordinators for displaying alerts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698