| Index: ios/chrome/browser/ui/tools_menu/tools_popup_controller.mm
|
| diff --git a/ios/chrome/browser/ui/tools_menu/tools_popup_controller.mm b/ios/chrome/browser/ui/tools_menu/tools_popup_controller.mm
|
| index d549374658de8f28ea2bed01ec8348489922d849..af3f14120ca272198cb893f9630e66a1f3da67a9 100644
|
| --- a/ios/chrome/browser/ui/tools_menu/tools_popup_controller.mm
|
| +++ b/ios/chrome/browser/ui/tools_menu/tools_popup_controller.mm
|
| @@ -12,7 +12,7 @@
|
| #include "base/metrics/user_metrics_action.h"
|
| #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
|
| #include "ios/chrome/browser/ui/rtl_geometry.h"
|
| -#import "ios/chrome/browser/ui/tools_menu/tools_menu_context.h"
|
| +#import "ios/chrome/browser/ui/tools_menu/tools_menu_configuration.h"
|
| #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_controller.h"
|
| #import "ios/chrome/browser/ui/uikit_ui_util.h"
|
|
|
| @@ -42,24 +42,24 @@ @interface ToolsPopupController ()<ToolsPopupTableDelegate> {
|
| @implementation ToolsPopupController
|
| @synthesize isCurrentPageBookmarked = _isCurrentPageBookmarked;
|
|
|
| -- (instancetype)initWithContext:(ToolsMenuContext*)context {
|
| - DCHECK(context.displayView);
|
| - self = [super initWithParentView:context.displayView];
|
| +- (instancetype)initWithConfiguration:(ToolsMenuConfiguration*)configuration {
|
| + DCHECK(configuration.displayView);
|
| + self = [super initWithParentView:configuration.displayView];
|
| if (self) {
|
| _toolsMenuViewController.reset([[ToolsMenuViewController alloc] init]);
|
| _toolsTableViewContainer.reset([[_toolsMenuViewController view] retain]);
|
| [_toolsTableViewContainer layer].cornerRadius = 2;
|
| [_toolsTableViewContainer layer].masksToBounds = YES;
|
| - [_toolsMenuViewController initializeMenu:context];
|
| + [_toolsMenuViewController initializeMenuWithConfiguration:configuration];
|
|
|
| UIEdgeInsets popupInsets = TabHistoryPopupMenuInsets();
|
| CGFloat popupWidth = kToolsPopupMenuWidth;
|
|
|
| - CGPoint origin = CGPointMake(CGRectGetMidX(context.sourceRect),
|
| - CGRectGetMidY(context.sourceRect));
|
| + CGPoint origin = CGPointMake(CGRectGetMidX(configuration.sourceRect),
|
| + CGRectGetMidY(configuration.sourceRect));
|
|
|
| - CGRect containerBounds = [context.displayView bounds];
|
| - CGFloat minY = CGRectGetMinY(context.sourceRect) - popupInsets.top;
|
| + CGRect containerBounds = [configuration.displayView bounds];
|
| + CGFloat minY = CGRectGetMinY(configuration.sourceRect) - popupInsets.top;
|
|
|
| // The tools popup appears trailing- aligned, but because
|
| // kToolsPopupMenuTrailingOffset is smaller than the popupInsets's trailing
|
| @@ -72,8 +72,9 @@ - (instancetype)initWithContext:(ToolsMenuContext*)context {
|
| CGPoint destination = CGPointMake(
|
| CGRectGetTrailingEdge(containerBounds) + trailingShift, minY);
|
|
|
| - CGFloat availableHeight = CGRectGetHeight([context.displayView bounds]) -
|
| - minY - popupInsets.bottom;
|
| + CGFloat availableHeight =
|
| + CGRectGetHeight([configuration.displayView bounds]) - minY -
|
| + popupInsets.bottom;
|
| CGFloat optimalHeight =
|
| [_toolsMenuViewController optimalHeight:availableHeight];
|
| [self setOptimalSize:CGSizeMake(popupWidth, optimalHeight)
|
| @@ -97,12 +98,13 @@ - (instancetype)initWithContext:(ToolsMenuContext*)context {
|
| // |origin| is the center of the tools menu icon in the toolbar; use
|
| // that to determine where the tools button should be placed.
|
| CGPoint buttonCenter =
|
| - [context.displayView convertPoint:origin toView:outsideAnimationView];
|
| + [configuration.displayView convertPoint:origin
|
| + toView:outsideAnimationView];
|
| CGRect frame = CGRectMake(buttonCenter.x - buttonWidth / 2.0,
|
| buttonCenter.y - buttonWidth / 2.0, buttonWidth,
|
| buttonWidth);
|
| [toolsButton setFrame:frame];
|
| - [toolsButton setImageEdgeInsets:context.toolsButtonInsets];
|
| + [toolsButton setImageEdgeInsets:configuration.toolsButtonInsets];
|
| [outsideAnimationView addSubview:toolsButton];
|
| }
|
| }
|
| @@ -131,15 +133,10 @@ - (void)setIsCurrentPageBookmarked:(BOOL)value {
|
| [_toolsMenuViewController setIsCurrentPageBookmarked:value];
|
| }
|
|
|
| -// Informs tools popup menu whether the switch to reader mode is possible.
|
| - (void)setCanUseReaderMode:(BOOL)enabled {
|
| [_toolsMenuViewController setCanUseReaderMode:enabled];
|
| }
|
|
|
| -- (void)setCanUseDesktopUserAgent:(BOOL)enabled {
|
| - [_toolsMenuViewController setCanUseDesktopUserAgent:enabled];
|
| -}
|
| -
|
| - (void)setCanShowFindBar:(BOOL)enabled {
|
| [_toolsMenuViewController setCanShowFindBar:enabled];
|
| }
|
| @@ -193,6 +190,9 @@ - (void)commandWasSelected:(int)commandID {
|
| case IDC_REQUEST_DESKTOP_SITE:
|
| base::RecordAction(UserMetricsAction("MobileMenuRequestDesktopSite"));
|
| break;
|
| + case IDC_REQUEST_MOBILE_SITE:
|
| + base::RecordAction(UserMetricsAction("MobileMenuRequestMobileSite"));
|
| + break;
|
| case IDC_READER_MODE:
|
| base::RecordAction(UserMetricsAction("MobileMenuRequestReaderMode"));
|
| break;
|
|
|