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

Unified Diff: ios/chrome/browser/ui/context_menu/context_menu_controller.mm

Issue 1972013003: Add ContextMenuCoordinator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove old files. Created 4 years, 7 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/context_menu/context_menu_controller.mm
diff --git a/ios/chrome/browser/ui/context_menu/context_menu_controller.mm b/ios/chrome/browser/ui/context_menu/context_menu_controller.mm
index 1ba2a1ea3a6ee5d39d6045ef3fa94817b582b07a..964211736030de2e51c26765840147f080558d00 100644
--- a/ios/chrome/browser/ui/context_menu/context_menu_controller.mm
+++ b/ios/chrome/browser/ui/context_menu/context_menu_controller.mm
@@ -14,50 +14,20 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/strings/grit/ui_strings.h"
-// Abstracts system implementation of popovers and action sheets.
-@protocol ContextMenuControllerImpl<NSObject>
-
-// Whether the context menu is visible.
-@property(nonatomic, readonly, getter=isVisible) BOOL visible;
-
-// Displays a context menu.
-- (void)showWithHolder:(ContextMenuHolder*)menuHolder
- atPoint:(CGPoint)localPoint
- inView:(UIView*)view;
-
-// Dismisses displayed context menu.
-- (void)dismissAnimated:(BOOL)animated
- completionHandler:(ProceduralBlock)completionHandler;
-
-@end
-
-// Backs up ContextMenuController by using UIAlertController.
-@interface AlertController : NSObject<ContextMenuControllerImpl> {
+@interface ContextMenuController () {
Eugene But (OOO till 7-30) 2016/05/12 22:27:48 Thank you for this cleanup. Could you please land
michaeldo 2016/05/12 23:32:42 yes, I will move to a separate CL and remove from
+ // Underlying system alert.
base::WeakNSObject<UIAlertController> _alert;
}
// Redefined to readwrite.
@property(nonatomic, readwrite, getter=isVisible) BOOL visible;
@end
-// Displays a context menu. Implements Bridge pattern.
-@implementation ContextMenuController {
- base::scoped_nsprotocol<id<ContextMenuControllerImpl>> _impl;
-}
-
-- (BOOL)isVisible {
- return [_impl isVisible];
-}
-
-- (instancetype)init {
- self = [super init];
- if (self) {
- _impl.reset([[AlertController alloc] init]);
- }
- return self;
-}
+// Displays a context menu.
+@implementation ContextMenuController
+@synthesize visible = _visible;
- (void)dealloc {
- [_impl dismissAnimated:NO completionHandler:nil];
+ [_alert dismissViewControllerAnimated:NO completion:nil];
[super dealloc];
}
@@ -69,37 +39,7 @@
// don't show the context menu.
if (![view window] && ![view isKindOfClass:[UIWindow class]])
return;
- [_impl showWithHolder:menuHolder atPoint:point inView:view];
-}
-
-- (void)dismissAnimated:(BOOL)animated
- completionHandler:(ProceduralBlock)completionHandler {
- [_impl dismissAnimated:animated completionHandler:completionHandler];
-}
-
-@end
-@implementation AlertController
-@synthesize visible = _visible;
-
-- (CGSize)sizeForTitleThatFitsMenuWithHolder:(ContextMenuHolder*)menuHolder
- atPoint:(CGPoint)point
- inView:(UIView*)view {
- // Presenting and dismissing a dummy UIAlertController flushes a screen.
- // As a workaround return an estimation of the space available depending
- // on the device's type.
- const CGFloat kAvailableWidth = 320;
- const CGFloat kAvailableHeightTablet = 200;
- const CGFloat kAvailableHeightPhone = 100;
- if (ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET) {
- return CGSizeMake(kAvailableWidth, kAvailableHeightTablet);
- }
- return CGSizeMake(kAvailableWidth, kAvailableHeightPhone);
-}
-
-- (void)showWithHolder:(ContextMenuHolder*)menuHolder
- atPoint:(CGPoint)point
- inView:(UIView*)view {
UIAlertController* alert = [UIAlertController
alertControllerWithTitle:menuHolder.menuTitle
message:nil
@@ -109,7 +49,7 @@
CGRectMake(point.x, point.y, 1.0, 1.0);
// Add the actions.
- base::WeakNSObject<AlertController> weakSelf(self);
+ base::WeakNSObject<ContextMenuController> weakSelf(self);
[menuHolder.itemTitles enumerateObjectsUsingBlock:^(
NSString* itemTitle, NSUInteger itemIndex, BOOL*) {
void (^actionHandler)(UIAlertAction*) = ^(UIAlertAction* action) {

Powered by Google App Engine
This is Rietveld 408576698