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

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

Issue 2156913002: Creates alertCoordinatorDelegate for alerts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@alertCoordinator
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.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

Powered by Google App Engine
This is Rietveld 408576698