Commit 0bf08388 authored by Sebastien Lalancette's avatar Sebastien Lalancette Committed by Commit Bot

[iOS] Allow Disabling New Context Menu Delete Bookmark Action

In a previous CL, I've added logic to disable the Edit and Move actions
in the new Context Menus based on the enterprise policy's setting, but
forgot about the new Delete action. Bookmarks' deletion is also
controlled by this policy, so in this CL we'll be disabling that action
as well, based on the policy.

Bug: 1128028
Change-Id: I9f7cf4e8fa9e0889657d73a80ce1036d45d46511
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410308
Commit-Queue: Sebastien Lalancette <seblalancette@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807108}
parent ea551f3d
...@@ -2255,9 +2255,6 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -2255,9 +2255,6 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
UIAction* editAction = [actionFactory actionToEditWithBlock:^{ UIAction* editAction = [actionFactory actionToEditWithBlock:^{
[self editNode:node]; [self editNode:node];
}]; }];
if (!canEditNode) {
editAction.attributes = UIMenuElementAttributesDisabled;
}
[menuElements addObject:editAction]; [menuElements addObject:editAction];
[menuElements [menuElements
...@@ -2267,13 +2264,20 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) { ...@@ -2267,13 +2264,20 @@ std::vector<GURL> GetUrlsToOpen(const std::vector<const BookmarkNode*>& nodes) {
indexPath:indexPath]; indexPath:indexPath];
}]]; }]];
[menuElements addObject:[actionFactory actionToDeleteWithBlock:^{ UIAction* deleteAction = [actionFactory actionToDeleteWithBlock:^{
std::set<const BookmarkNode*> nodes; std::set<const BookmarkNode*> nodes;
nodes.insert(node); nodes.insert(node);
[self handleSelectNodesForDeletion:nodes]; [self handleSelectNodesForDeletion:nodes];
base::RecordAction(base::UserMetricsAction( base::RecordAction(
"MobileBookmarkManagerEntryDeleted")); base::UserMetricsAction("MobileBookmarkManagerEntryDeleted"));
}]]; }];
[menuElements addObject:deleteAction];
// Disable Edit and Delete if the node cannot be edited.
if (!canEditNode) {
editAction.attributes = UIMenuElementAttributesDisabled;
deleteAction.attributes = UIMenuElementAttributesDisabled;
}
return [UIMenu menuWithTitle:@"" children:menuElements]; return [UIMenu menuWithTitle:@"" children:menuElements];
}; };
......
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