Commit 0af1b90b authored by Ewann's avatar Ewann Committed by Commit Bot

[iOS] Fixes context menu style

This CL fixes some style issue related to context menu.

Bug: 1093302
Change-Id: I53966504a431b9545c4d79ebaf6bbbdfdda77d88
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2325615
Commit-Queue: Ewann Pellé <ewannpv@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarSebastien Lalancette <seblalancette@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792759}
parent 43d515d3
...@@ -2182,14 +2182,14 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -2182,14 +2182,14 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
if (node->is_url()) { if (node->is_url()) {
actionProvider = ^(NSArray<UIMenuElement*>* suggestedActions) { actionProvider = ^(NSArray<UIMenuElement*>* suggestedActions) {
// Record that this context menu was shown to the user. // Record that this context menu was shown to the user.
RecordMenuShown(MenuScenario::BookmarkEntry); RecordMenuShown(MenuScenario::kBookmarkEntry);
ActionFactory* actionFactory = ActionFactory* actionFactory =
[[ActionFactory alloc] initWithScenario:MenuScenario::BookmarkEntry]; [[ActionFactory alloc] initWithScenario:MenuScenario::kBookmarkEntry];
UIAction* copyAction = [actionFactory actionToCopyURL:node->url()]; UIAction* copyAction = [actionFactory actionToCopyURL:node->url()];
return [UIMenu menuWithTitle:[NSString string] children:@[ copyAction ]]; return [UIMenu menuWithTitle:@"" children:@[ copyAction ]];
}; };
} }
......
...@@ -175,9 +175,9 @@ ...@@ -175,9 +175,9 @@
#pragma mark - HistoryMenuProvider #pragma mark - HistoryMenuProvider
- (UIContextMenuConfiguration*)createConfigurationForItem: - (UIContextMenuConfiguration*)contextMenuConfigurationForItem:
(HistoryEntryItem*)item (HistoryEntryItem*)item
withView:(UIView*)view withView:(UIView*)view
API_AVAILABLE(ios(13.0)) { API_AVAILABLE(ios(13.0)) {
__weak id<HistoryEntryItemDelegate> historyItemDelegate = __weak id<HistoryEntryItemDelegate> historyItemDelegate =
self.historyTableViewController; self.historyTableViewController;
...@@ -185,10 +185,10 @@ ...@@ -185,10 +185,10 @@
UIContextMenuActionProvider actionProvider = UIContextMenuActionProvider actionProvider =
^(NSArray<UIMenuElement*>* suggestedActions) { ^(NSArray<UIMenuElement*>* suggestedActions) {
// Record that this context menu was shown to the user. // Record that this context menu was shown to the user.
RecordMenuShown(MenuScenario::HistoryEntry); RecordMenuShown(MenuScenario::kHistoryEntry);
ActionFactory* actionFactory = ActionFactory* actionFactory = [[ActionFactory alloc]
[[ActionFactory alloc] initWithScenario:MenuScenario::HistoryEntry]; initWithScenario:MenuScenario::kHistoryEntry];
UIAction* copyAction = [actionFactory actionToCopyURL:item.URL]; UIAction* copyAction = [actionFactory actionToCopyURL:item.URL];
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
[historyItemDelegate historyEntryItemDidRequestDelete:item]; [historyItemDelegate historyEntryItemDidRequestDelete:item];
}]; }];
return [UIMenu menuWithTitle:[NSString string] return [UIMenu menuWithTitle:@""
children:@[ copyAction, deleteAction ]]; children:@[ copyAction, deleteAction ]];
}; };
......
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
#import "ios/chrome/browser/ui/history/history_entry_item.h" #import "ios/chrome/browser/ui/history/history_entry_item.h"
// Protocol for instances that will provide menus to history components. // Protocol for instances that will provide menus to History components.
@protocol HistoryMenuProvider @protocol HistoryMenuProvider
// Creates a context menu configuration instance for the given |item|, which is // Creates a context menu configuration instance for the given |item|, which is
// represented on the UI by |view|. // represented on the UI by |view|.
- (UIContextMenuConfiguration*)createConfigurationForItem: - (UIContextMenuConfiguration*)contextMenuConfigurationForItem:
(HistoryEntryItem*)item (HistoryEntryItem*)item
withView:(UIView*)view withView:(UIView*)view
API_AVAILABLE(ios(13.0)); API_AVAILABLE(ios(13.0));
@end @end
......
...@@ -628,7 +628,8 @@ const CGFloat kButtonHorizontalPadding = 30.0; ...@@ -628,7 +628,8 @@ const CGFloat kButtonHorizontalPadding = 30.0;
HistoryEntryItem* entry = base::mac::ObjCCastStrict<HistoryEntryItem>( HistoryEntryItem* entry = base::mac::ObjCCastStrict<HistoryEntryItem>(
[self.tableViewModel itemAtIndexPath:indexPath]); [self.tableViewModel itemAtIndexPath:indexPath]);
UIView* cell = [self.tableView cellForRowAtIndexPath:indexPath]; UIView* cell = [self.tableView cellForRowAtIndexPath:indexPath];
return [self.menuProvider createConfigurationForItem:entry withView:cell]; return [self.menuProvider contextMenuConfigurationForItem:entry
withView:cell];
} }
#pragma mark - UITableViewDataSource #pragma mark - UITableViewDataSource
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#if defined(__IPHONE_13_0) #if defined(__IPHONE_13_0)
namespace { namespace {
MenuScenario kTestMenuScenario = MenuScenario::HistoryEntry; MenuScenario kTestMenuScenario = MenuScenario::kHistoryEntry;
} // namespace } // namespace
// Test fixture for the ActionFactory. // Test fixture for the ActionFactory.
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
// not be renumbered. Please keep in sync with "IOSMenuScenario" in // not be renumbered. Please keep in sync with "IOSMenuScenario" in
// src/tools/metrics/histograms/enums.xml. // src/tools/metrics/histograms/enums.xml.
enum class MenuScenario { enum class MenuScenario {
HistoryEntry = 0, kHistoryEntry = 0,
BookmarkEntry = 1, kBookmarkEntry = 1,
kMaxValue = BookmarkEntry kMaxValue = kBookmarkEntry
}; };
// Records a menu shown histogram metric for the |scenario|. // Records a menu shown histogram metric for the |scenario|.
......
...@@ -27,9 +27,9 @@ void RecordMenuShown(MenuScenario scenario) { ...@@ -27,9 +27,9 @@ void RecordMenuShown(MenuScenario scenario) {
const char* GetActionsHistogramName(MenuScenario scenario) { const char* GetActionsHistogramName(MenuScenario scenario) {
switch (scenario) { switch (scenario) {
case MenuScenario::HistoryEntry: case MenuScenario::kHistoryEntry:
return kHistoryEntryActionsHistogram; return kHistoryEntryActionsHistogram;
case MenuScenario::BookmarkEntry: case MenuScenario::kBookmarkEntry:
return kBookmarkEntryActionsHistogram; return kBookmarkEntryActionsHistogram;
} }
} }
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