[iOS]: Add the title for the context menu
This CL uses the function GetContextMenuElementsToAdd to add the
appropriate title to experience kit calendar's context menu.
Bug: 1336264
Change-Id: Ia7f544a09e0355eb5f7eb97390abe64f04ff5967
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3726121
Reviewed-by: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: David Jean <djean@chromium.org>
Commit-Queue: Elmehdi Rahmaoui <erahmaoui@google.com>
Cr-Commit-Position: refs/heads/main@{#1019115}
diff --git a/ios/chrome/browser/ui/context_menu/context_menu_configuration_provider.mm b/ios/chrome/browser/ui/context_menu/context_menu_configuration_provider.mm
index d19459a..031a341 100644
--- a/ios/chrome/browser/ui/context_menu/context_menu_configuration_provider.mm
+++ b/ios/chrome/browser/ui/context_menu/context_menu_configuration_provider.mm
@@ -320,17 +320,26 @@
}
}
+ NSString* menuTitle;
+
// Insert any provided menu items. Do after Link and/or Image to allow
// inserting at beginning or adding to end.
- ios::provider::AddContextMenuElements(
- menuElements, self.browser->GetBrowserState(), webState, params,
- self.baseViewController);
+ ElementsToAddToContextMenu* result =
+ ios::provider::GetContextMenuElementsToAdd(
+ self.browser->GetBrowserState(), webState, params,
+ self.baseViewController);
+
+ // Check if result and result.elements are not nil, in that case copy the
+ // title in menuTitle and add the elements of result.elements in menuElements.
+ if (result && result.elements) {
+ [menuElements addObjectsFromArray:result.elements];
+ menuTitle = result.title;
+ }
if (menuElements.count == 0) {
return nil;
}
- NSString* menuTitle = nil;
if (isLink || isImage) {
menuTitle = GetContextMenuTitle(params);