Commit 9448b41a authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

Create the items for the tools menu

This CL creates the items to be used by the tools menu.
It also creates the actions associated with the items.

Bug: 804773
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: Id34c8fb33daceaa34276aa4c42cf39ce0d3a5eb1
Reviewed-on: https://chromium-review.googlesource.com/970583Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544655}
parent 441a3358
...@@ -1571,6 +1571,9 @@ Your data was encrypted with your sync passphrase on <ph name="TIME">$2<ex>Sept ...@@ -1571,6 +1571,9 @@ Your data was encrypted with your sync passphrase on <ph name="TIME">$2<ex>Sept
<message name="IDS_IOS_TOOLS_MENU_HELP_URL" translateable="false"> <message name="IDS_IOS_TOOLS_MENU_HELP_URL" translateable="false">
https://support.google.com/chrome/?p=chrome_help&amp;hl=[GRITLANGCODE] https://support.google.com/chrome/?p=chrome_help&amp;hl=[GRITLANGCODE]
</message> </message>
<message name="IDS_IOS_TOOLS_MENU_HISTORY" desc="The Tools menu item for opening the navigation history menu">
History
</message>
<message name="IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_TAB" desc="The iOS menu item for opening a new incognito tab [Length: 15em] [iOS only]" meaning="Tools menu entry to create a new Incognito tab."> <message name="IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_TAB" desc="The iOS menu item for opening a new incognito tab [Length: 15em] [iOS only]" meaning="Tools menu entry to create a new Incognito tab.">
New Incognito Tab New Incognito Tab
</message> </message>
...@@ -1583,6 +1586,9 @@ Your data was encrypted with your sync passphrase on <ph name="TIME">$2<ex>Sept ...@@ -1583,6 +1586,9 @@ Your data was encrypted with your sync passphrase on <ph name="TIME">$2<ex>Sept
<message name="IDS_IOS_TOOLS_MENU_RECENT_TABS" desc="The iOS menu item for opening the panel showing the recently closed tabs and the tabs from other devices. [Length: 15em]" meaning="[In Title case] [iOS only]"> <message name="IDS_IOS_TOOLS_MENU_RECENT_TABS" desc="The iOS menu item for opening the panel showing the recently closed tabs and the tabs from other devices. [Length: 15em]" meaning="[In Title case] [iOS only]">
Recent Tabs Recent Tabs
</message> </message>
<message name="IDS_IOS_TOOLS_MENU_RELOAD" desc="The title of the button in the menu allowing the user to reload the page.">
Reload This Page
</message>
<message name="IDS_IOS_TOOLS_MENU_REQUEST_DESKTOP_SITE" desc="The iOS menu item for requesting the desktop site [Length: 15em] [iOS only]"> <message name="IDS_IOS_TOOLS_MENU_REQUEST_DESKTOP_SITE" desc="The iOS menu item for requesting the desktop site [Length: 15em] [iOS only]">
Request Desktop Site Request Desktop Site
</message> </message>
...@@ -1595,6 +1601,9 @@ Your data was encrypted with your sync passphrase on <ph name="TIME">$2<ex>Sept ...@@ -1595,6 +1601,9 @@ Your data was encrypted with your sync passphrase on <ph name="TIME">$2<ex>Sept
<message name="IDS_IOS_TOOLS_MENU_SHARE" desc="The iOS menu item for sharing the current URL [Length: 15em] [iOS only]"> <message name="IDS_IOS_TOOLS_MENU_SHARE" desc="The iOS menu item for sharing the current URL [Length: 15em] [iOS only]">
Share... Share...
</message> </message>
<message name="IDS_IOS_TOOLS_MENU_SITE_INFORMATION" desc="The iOS menu item for getting the site informations.">
Site Information
</message>
<message name="IDS_IOS_TRANSLATE_SETTING" desc="Title for the view and option in Settings for Translate. [Length: 25em] [iOS only]"> <message name="IDS_IOS_TRANSLATE_SETTING" desc="Title for the view and option in Settings for Translate. [Length: 25em] [iOS only]">
Google Translate Google Translate
</message> </message>
......
...@@ -13,10 +13,12 @@ source_set("popup_menu") { ...@@ -13,10 +13,12 @@ source_set("popup_menu") {
deps = [ deps = [
":popup_menu_ui", ":popup_menu_ui",
"//base", "//base",
"//ios/chrome/app/strings",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators", "//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/browser/ui/popup_menu/cells", "//ios/chrome/browser/ui/popup_menu/cells",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
"//ui/base",
] ]
libs = [ "UIKit.framework" ] libs = [ "UIKit.framework" ]
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
source_set("cells") { source_set("cells") {
configs += [ "//build/config/compiler:enable_arc" ] configs += [ "//build/config/compiler:enable_arc" ]
sources = [ sources = [
"popup_menu_item.h",
"popup_menu_navigation_item.h", "popup_menu_navigation_item.h",
"popup_menu_navigation_item.mm", "popup_menu_navigation_item.mm",
"popup_menu_tools_item.h", "popup_menu_tools_item.h",
......
// Copyright 2018 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.
#ifndef IOS_CHROME_BROWSER_UI_POPUP_MENU_CELLS_POPUP_MENU_ITEM_H_
#define IOS_CHROME_BROWSER_UI_POPUP_MENU_CELLS_POPUP_MENU_ITEM_H_
#import <Foundation/Foundation.h>
// Identifier for the action associated with a popup menu item.
typedef NS_ENUM(NSInteger, PopupMenuAction) {
PopupMenuActionReload,
PopupMenuActionStop,
PopupMenuActionOpenNewTab,
PopupMenuActionOpenNewIncognitoTab,
PopupMenuActionReadLater,
PopupMenuActionRequestDesktop,
PopupMenuActionRequestMobile,
PopupMenuActionSiteInformation,
PopupMenuActionReportIssue,
PopupMenuActionHelp,
PopupMenuActionBookmarks,
PopupMenuActionReadingList,
PopupMenuActionRecentTabs,
PopupMenuActionHistory,
PopupMenuActionSettings,
};
// Protocol defining a popup item.
@protocol PopupMenuItem
// Action identifier for the popup item.
@property(nonatomic, assign) PopupMenuAction actionIdentifier;
@end
#endif // IOS_CHROME_BROWSER_UI_POPUP_MENU_CELLS_POPUP_MENU_ITEM_H_
...@@ -5,10 +5,11 @@ ...@@ -5,10 +5,11 @@
#ifndef IOS_CHROME_BROWSER_UI_POPUP_MENU_CELLS_POPUP_MENU_NAVIGATION_ITEM_H_ #ifndef IOS_CHROME_BROWSER_UI_POPUP_MENU_CELLS_POPUP_MENU_NAVIGATION_ITEM_H_
#define IOS_CHROME_BROWSER_UI_POPUP_MENU_CELLS_POPUP_MENU_NAVIGATION_ITEM_H_ #define IOS_CHROME_BROWSER_UI_POPUP_MENU_CELLS_POPUP_MENU_NAVIGATION_ITEM_H_
#import "ios/chrome/browser/ui/popup_menu/cells/popup_menu_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_item.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_item.h"
// Item used to display an item for a navigation menu. // Item used to display an item for a navigation menu.
@interface PopupMenuNavigationItem : TableViewItem @interface PopupMenuNavigationItem : TableViewItem<PopupMenuItem>
@end @end
// Associated cell for a PopupMenuNavigationItem. // Associated cell for a PopupMenuNavigationItem.
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
@implementation PopupMenuNavigationItem @implementation PopupMenuNavigationItem
@synthesize actionIdentifier = _actionIdentifier;
- (instancetype)initWithType:(NSInteger)type { - (instancetype)initWithType:(NSInteger)type {
self = [super initWithType:type]; self = [super initWithType:type];
if (self) { if (self) {
......
...@@ -5,19 +5,25 @@ ...@@ -5,19 +5,25 @@
#ifndef IOS_CHROME_BROWSER_UI_POPUP_MENU_CELLS_POPUP_MENU_TOOLS_ITEM_H_ #ifndef IOS_CHROME_BROWSER_UI_POPUP_MENU_CELLS_POPUP_MENU_TOOLS_ITEM_H_
#define IOS_CHROME_BROWSER_UI_POPUP_MENU_CELLS_POPUP_MENU_TOOLS_ITEM_H_ #define IOS_CHROME_BROWSER_UI_POPUP_MENU_CELLS_POPUP_MENU_TOOLS_ITEM_H_
#import "ios/chrome/browser/ui/popup_menu/cells/popup_menu_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_item.h" #import "ios/chrome/browser/ui/table_view/cells/table_view_item.h"
// Item for a tools menu item. // Item for a tools menu item.
@interface PopupMenuToolsItem : TableViewItem @interface PopupMenuToolsItem : TableViewItem<PopupMenuItem>
// The title of the item. // The title of the item.
@property(nonatomic, copy) NSString* title; @property(nonatomic, copy) NSString* title;
// Image to be displayed on the item.
@property(nonatomic, strong) UIImage* image;
@end @end
// Associated cell for the PopupMenuToolsItem. // Associated cell for the PopupMenuToolsItem.
@interface PopupMenuToolsCell : UITableViewCell @interface PopupMenuToolsCell : UITableViewCell
// Image view to display the image.
@property(nonatomic, strong, readonly) UIImageView* imageView;
// Sets the title of the cell. // Sets the title of the cell.
- (void)setTitleText:(NSString*)title; - (void)setTitleText:(NSString*)title;
......
...@@ -10,8 +10,14 @@ ...@@ -10,8 +10,14 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
namespace {
const CGFloat kImageLength = 30;
}
@implementation PopupMenuToolsItem @implementation PopupMenuToolsItem
@synthesize actionIdentifier = _actionIdentifier;
@synthesize image = _image;
@synthesize title = _title; @synthesize title = _title;
- (instancetype)initWithType:(NSInteger)type { - (instancetype)initWithType:(NSInteger)type {
...@@ -26,6 +32,7 @@ ...@@ -26,6 +32,7 @@
withStyler:(ChromeTableViewStyler*)styler { withStyler:(ChromeTableViewStyler*)styler {
[super configureCell:cell withStyler:styler]; [super configureCell:cell withStyler:styler];
[cell setTitleText:self.title]; [cell setTitleText:self.title];
cell.imageView.image = self.image;
} }
@end @end
...@@ -36,11 +43,14 @@ ...@@ -36,11 +43,14 @@
// Title label for the cell. // Title label for the cell.
@property(nonatomic, strong) UILabel* title; @property(nonatomic, strong) UILabel* title;
// Image view for the cell, redefined as readwrite.
@property(nonatomic, strong, readwrite) UIImageView* imageView;
@end @end
@implementation PopupMenuToolsCell @implementation PopupMenuToolsCell
@synthesize imageView = _imageView;
@synthesize title = _title; @synthesize title = _title;
- (instancetype)initWithStyle:(UITableViewCellStyle)style - (instancetype)initWithStyle:(UITableViewCellStyle)style
...@@ -49,8 +59,26 @@ ...@@ -49,8 +59,26 @@
if (self) { if (self) {
_title = [[UILabel alloc] init]; _title = [[UILabel alloc] init];
_title.translatesAutoresizingMaskIntoConstraints = NO; _title.translatesAutoresizingMaskIntoConstraints = NO;
_imageView = [[UIImageView alloc] init];
_imageView.translatesAutoresizingMaskIntoConstraints = NO;
[NSLayoutConstraint activateConstraints:@[
[_imageView.widthAnchor constraintEqualToConstant:kImageLength],
[_imageView.heightAnchor
constraintGreaterThanOrEqualToConstant:kImageLength],
]];
[self.contentView addSubview:_title]; [self.contentView addSubview:_title];
AddSameConstraints(self.contentView, _title); [self.contentView addSubview:_imageView];
AddSameConstraintsToSides(
self.contentView, _title,
LayoutSides::kTop | LayoutSides::kBottom | LayoutSides::kTrailing);
AddSameConstraintsToSides(
self.contentView, _imageView,
LayoutSides::kTop | LayoutSides::kBottom | LayoutSides::kLeading);
[_imageView.trailingAnchor constraintEqualToAnchor:_title.leadingAnchor]
.active = YES;
} }
return self; return self;
} }
......
...@@ -63,6 +63,8 @@ ...@@ -63,6 +63,8 @@
- (void)showToolsMenuPopup { - (void)showToolsMenuPopup {
PopupMenuTableViewController* tableViewController = PopupMenuTableViewController* tableViewController =
[[PopupMenuTableViewController alloc] init]; [[PopupMenuTableViewController alloc] init];
tableViewController.dispatcher =
static_cast<id<ApplicationCommands, BrowserCommands>>(self.dispatcher);
PopupMenuMediator* mediator = PopupMenuMediator* mediator =
[[PopupMenuMediator alloc] initWithType:PopupMenuTypeToolsMenu]; [[PopupMenuMediator alloc] initWithType:PopupMenuTypeToolsMenu];
......
...@@ -4,17 +4,32 @@ ...@@ -4,17 +4,32 @@
#import "ios/chrome/browser/ui/popup_menu/popup_menu_mediator.h" #import "ios/chrome/browser/ui/popup_menu/popup_menu_mediator.h"
#import "ios/chrome/browser/ui/popup_menu/cells/popup_menu_item.h"
#import "ios/chrome/browser/ui/popup_menu/cells/popup_menu_tools_item.h" #import "ios/chrome/browser/ui/popup_menu/cells/popup_menu_tools_item.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_table_view_controller.h" #import "ios/chrome/browser/ui/popup_menu/popup_menu_table_view_controller.h"
#include "ios/chrome/grit/ios_strings.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
namespace {
TableViewItem<PopupMenuItem>* CreateTableViewItem(int titleID,
PopupMenuAction action) {
PopupMenuToolsItem* item =
[[PopupMenuToolsItem alloc] initWithType:kItemTypeEnumZero];
item.title = l10n_util::GetNSString(titleID);
item.actionIdentifier = action;
return item;
}
}
@interface PopupMenuMediator () @interface PopupMenuMediator ()
// Items to be displayed in the popup menu. // Items to be displayed in the popup menu.
@property(nonatomic, strong) NSArray<NSArray<TableViewItem*>*>* items; @property(nonatomic, strong)
NSArray<NSArray<TableViewItem<PopupMenuItem>*>*>* items;
// Type of this mediator. // Type of this mediator.
@property(nonatomic, assign) PopupMenuType type; @property(nonatomic, assign) PopupMenuType type;
...@@ -60,23 +75,85 @@ ...@@ -60,23 +75,85 @@
// Creates the menu items for the tools menu. // Creates the menu items for the tools menu.
- (void)createToolsMenuItem { - (void)createToolsMenuItem {
NSMutableArray* section1 = [NSMutableArray array]; // Reload page action.
for (int i = 0; i < 3; i++) { TableViewItem* reload =
PopupMenuToolsItem* item = CreateTableViewItem(IDS_IOS_TOOLS_MENU_RELOAD, PopupMenuActionReload);
[[PopupMenuToolsItem alloc] initWithType:kItemTypeEnumZero];
item.title = [@"Item number:" stringByAppendingFormat:@"%i", i];
[section1 addObject:item];
}
NSMutableArray* section2 = [NSMutableArray array]; NSArray* tabActions =
for (int i = 0; i < 5; i++) { [@[ reload ] arrayByAddingObjectsFromArray:[self itemsForNewTab]];
PopupMenuToolsItem* item =
[[PopupMenuToolsItem alloc] initWithType:kItemTypeEnumZero]; NSArray* browserActions = [self actionItems];
item.title = [@"Item 2 number:" stringByAppendingFormat:@"%i", i];
[section2 addObject:item]; NSArray* collectionActions = [self collectionItems];
}
self.items = @[ tabActions, browserActions, collectionActions ];
}
- (NSArray<TableViewItem*>*)itemsForNewTab {
// Open New Tab.
TableViewItem* openNewTabItem = CreateTableViewItem(
IDS_IOS_TOOLS_MENU_NEW_TAB, PopupMenuActionOpenNewTab);
// Open New Incogntio Tab.
TableViewItem* openNewIncognitoTabItem = CreateTableViewItem(
IDS_IOS_TOOLS_MENU_NEW_INCOGNITO_TAB, PopupMenuActionOpenNewIncognitoTab);
return @[ openNewTabItem, openNewIncognitoTabItem ];
}
- (NSArray<TableViewItem*>*)actionItems {
// Read Later.
TableViewItem* readLater = CreateTableViewItem(
IDS_IOS_CONTENT_CONTEXT_ADDTOREADINGLIST, PopupMenuActionReadLater);
// Request Desktop Site.
TableViewItem* requestDesktopSite = CreateTableViewItem(
IDS_IOS_TOOLS_MENU_REQUEST_DESKTOP_SITE, PopupMenuActionRequestDesktop);
// Request Mobile Site.
TableViewItem* requestMobileSite = CreateTableViewItem(
IDS_IOS_TOOLS_MENU_REQUEST_MOBILE_SITE, PopupMenuActionRequestMobile);
// Site Information.
TableViewItem* siteInformation = CreateTableViewItem(
IDS_IOS_TOOLS_MENU_SITE_INFORMATION, PopupMenuActionSiteInformation);
// Report an Issue.
TableViewItem* reportIssue = CreateTableViewItem(
IDS_IOS_OPTIONS_REPORT_AN_ISSUE, PopupMenuActionReportIssue);
// Help.
TableViewItem* help =
CreateTableViewItem(IDS_IOS_TOOLS_MENU_HELP_MOBILE, PopupMenuActionHelp);
return @[
readLater, requestDesktopSite, requestMobileSite, siteInformation,
reportIssue, help
];
}
- (NSArray<TableViewItem*>*)collectionItems {
// Bookmarks.
TableViewItem* bookmarks = CreateTableViewItem(IDS_IOS_TOOLS_MENU_BOOKMARKS,
PopupMenuActionBookmarks);
// Reading List.
TableViewItem* readingList = CreateTableViewItem(
IDS_IOS_TOOLS_MENU_READING_LIST, PopupMenuActionReadingList);
// Recent Tabs.
TableViewItem* recentTabs = CreateTableViewItem(
IDS_IOS_TOOLS_MENU_RECENT_TABS, PopupMenuActionRecentTabs);
// History.
TableViewItem* history =
CreateTableViewItem(IDS_IOS_TOOLS_MENU_HISTORY, PopupMenuActionHistory);
// Settings.
TableViewItem* settings =
CreateTableViewItem(IDS_IOS_TOOLS_MENU_SETTINGS, PopupMenuActionSettings);
self.items = @[ section1, section2 ]; return @[ bookmarks, readingList, recentTabs, history, settings ];
} }
@end @end
...@@ -7,12 +7,24 @@ ...@@ -7,12 +7,24 @@
#import "ios/chrome/browser/ui/table_view/chrome_table_view_controller.h" #import "ios/chrome/browser/ui/table_view/chrome_table_view_controller.h"
@protocol ApplicationCommands;
@protocol BrowserCommands;
@protocol PopupMenuItem;
// TableViewController for the popup menu. // TableViewController for the popup menu.
@interface PopupMenuTableViewController : ChromeTableViewController @interface PopupMenuTableViewController : ChromeTableViewController
// The model of this controller.
@property(nonatomic, readonly, strong)
TableViewModel<TableViewItem<PopupMenuItem>*>* tableViewModel;
// Dispatcher.
@property(nonatomic, weak) id<ApplicationCommands, BrowserCommands> dispatcher;
// Sets the |items| to be displayed by this Table View. Removes all the // Sets the |items| to be displayed by this Table View. Removes all the
// currently presented items. // currently presented items.
- (void)setPopupMenuItems:(NSArray<NSArray<TableViewItem*>*>*)items; - (void)setPopupMenuItems:
(NSArray<NSArray<TableViewItem<PopupMenuItem>*>*>*)items;
@end @end
......
...@@ -4,15 +4,27 @@ ...@@ -4,15 +4,27 @@
#import "ios/chrome/browser/ui/popup_menu/popup_menu_table_view_controller.h" #import "ios/chrome/browser/ui/popup_menu/popup_menu_table_view_controller.h"
#include "base/metrics/user_metrics.h"
#include "base/metrics/user_metrics_action.h"
#import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#import "ios/chrome/browser/ui/popup_menu/cells/popup_menu_item.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
using base::UserMetricsAction;
@interface PopupMenuTableViewController () @interface PopupMenuTableViewController ()
@end @end
@implementation PopupMenuTableViewController @implementation PopupMenuTableViewController
@dynamic tableViewModel;
@synthesize dispatcher = _dispatcher;
#pragma mark - UIViewController #pragma mark - UIViewController
- (void)viewDidLoad { - (void)viewDidLoad {
...@@ -22,12 +34,13 @@ ...@@ -22,12 +34,13 @@
self.tableView.sectionFooterHeight = 0; self.tableView.sectionFooterHeight = 0;
} }
- (void)setPopupMenuItems:(NSArray<NSArray<TableViewItem*>*>*)items { - (void)setPopupMenuItems:
(NSArray<NSArray<TableViewItem<PopupMenuItem>*>*>*)items {
[super loadModel]; [super loadModel];
for (NSUInteger section = 0; section < items.count; section++) { for (NSUInteger section = 0; section < items.count; section++) {
NSInteger sectionIdentifier = kSectionIdentifierEnumZero + section; NSInteger sectionIdentifier = kSectionIdentifierEnumZero + section;
[self.tableViewModel addSectionWithIdentifier:sectionIdentifier]; [self.tableViewModel addSectionWithIdentifier:sectionIdentifier];
for (TableViewItem* item in items[section]) { for (TableViewItem<PopupMenuItem>* item in items[section]) {
[self.tableViewModel addItem:item [self.tableViewModel addItem:item
toSectionWithIdentifier:sectionIdentifier]; toSectionWithIdentifier:sectionIdentifier];
} }
...@@ -35,4 +48,90 @@ ...@@ -35,4 +48,90 @@
[self.tableView reloadData]; [self.tableView reloadData];
} }
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView*)tableView
didSelectRowAtIndexPath:(NSIndexPath*)indexPath {
TableViewItem<PopupMenuItem>* item =
[self.tableViewModel itemAtIndexPath:indexPath];
UIView* cell = [self.tableView cellForRowAtIndexPath:indexPath];
CGPoint center = [cell convertPoint:cell.center toView:nil];
[self executeActionForIdentifier:item.actionIdentifier origin:center];
}
#pragma mark - Private
// Executes the action associated with |identifier|, using |origin| as the point
// of origin of the action if one is needed.
- (void)executeActionForIdentifier:(PopupMenuAction)identifier
origin:(CGPoint)origin {
switch (identifier) {
case PopupMenuActionReload:
base::RecordAction(UserMetricsAction("MobileMenuReload"));
[self.dispatcher reload];
break;
case PopupMenuActionStop:
base::RecordAction(UserMetricsAction("MobileMenuStop"));
[self.dispatcher stopLoading];
break;
case PopupMenuActionOpenNewTab:
base::RecordAction(UserMetricsAction("MobileMenuNewTab"));
[self.dispatcher
openNewTab:[[OpenNewTabCommand alloc] initWithIncognito:NO
originPoint:origin]];
break;
case PopupMenuActionOpenNewIncognitoTab:
base::RecordAction(UserMetricsAction("MobileMenuNewIncognitoTab"));
[self.dispatcher
openNewTab:[[OpenNewTabCommand alloc] initWithIncognito:YES
originPoint:origin]];
break;
case PopupMenuActionReadLater:
// TODO(crbug.com/822703): Add metric and action.
break;
case PopupMenuActionRequestDesktop:
base::RecordAction(UserMetricsAction("MobileMenuRequestDesktopSite"));
[self.dispatcher requestDesktopSite];
break;
case PopupMenuActionRequestMobile:
base::RecordAction(UserMetricsAction("MobileMenuRequestMobileSite"));
[self.dispatcher requestMobileSite];
break;
case PopupMenuActionSiteInformation:
// TODO(crbug.com/822703): Add metric and action.
break;
case PopupMenuActionReportIssue:
base::RecordAction(UserMetricsAction("MobileMenuReportAnIssue"));
// TODO(crbug.com/822703): Add action.
break;
case PopupMenuActionHelp:
base::RecordAction(UserMetricsAction("MobileMenuHelp"));
[self.dispatcher showHelpPage];
break;
case PopupMenuActionBookmarks:
base::RecordAction(UserMetricsAction("MobileMenuAllBookmarks"));
[self.dispatcher showBookmarksManager];
break;
case PopupMenuActionReadingList:
base::RecordAction(UserMetricsAction("MobileMenuReadingList"));
[self.dispatcher showReadingList];
break;
case PopupMenuActionRecentTabs:
base::RecordAction(UserMetricsAction("MobileMenuRecentTabs"));
[self.dispatcher showRecentTabs];
break;
case PopupMenuActionHistory:
base::RecordAction(UserMetricsAction("MobileMenuHistory"));
[self.dispatcher showHistory];
break;
case PopupMenuActionSettings:
base::RecordAction(UserMetricsAction("MobileMenuSettings"));
// TODO(crbug.com/822703): Add action.
break;
}
// Close the tools menu.
[self.dispatcher dismissPopupMenu];
}
@end @end
...@@ -78,8 +78,8 @@ const CGFloat kContentMargin = 8; ...@@ -78,8 +78,8 @@ const CGFloat kContentMargin = 8;
- (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer - (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer
shouldReceiveTouch:(UITouch*)touch { shouldReceiveTouch:(UITouch*)touch {
// Do no get the touches on the container view. // Only get the touch on the scrim.
return touch.view != self.contentContainer; return touch.view == self.view;
} }
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment