Add support for multiple smart text selection actions in context menu
This change adds support for multiple smart actions instead of only one
and moves them below the copy/print section and groups them with
extensions.
Some SEPARATOR logic from
https://chromium-review.googlesource.com/c/chromium/src/+/1087724 is
reverted (due to the move from top to extensions) and some extra
separator cleanup is needed after all actions are loaded.
Bug: b/32781610
Change-Id: I7c825e9ef58cc21ed10a49b784e6258a704e2f8b
Reviewed-on: https://chromium-review.googlesource.com/1147544
Reviewed-by: Luis Hector Chavez <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Greg Kerr <[email protected]>
Reviewed-by: David Jacobo <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Commit-Queue: Jorge Gil <[email protected]>
Cr-Commit-Position: refs/heads/master@{#579997}
diff --git a/chrome/browser/extensions/context_menu_matcher.cc b/chrome/browser/extensions/context_menu_matcher.cc
index 5ae5348..fc51177e 100644
--- a/chrome/browser/extensions/context_menu_matcher.cc
+++ b/chrome/browser/extensions/context_menu_matcher.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/extensions/context_menu_matcher.h"
+#include <string>
+
#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
@@ -49,8 +51,8 @@
: browser_context_(browser_context),
menu_model_(menu_model),
delegate_(delegate),
- filter_(filter) {
-}
+ filter_(filter),
+ is_smart_text_selection_enabled_(false) {}
void ContextMenuMatcher::AppendExtensionItems(
const MenuItem::ExtensionKey& extension_key,
@@ -77,9 +79,13 @@
// items in the menu, and the last item is not a separator add a separator.
// Separators are not required when the context menu is a touchable app
// context menu.
+ // Also, don't add separators when Smart Text Selection is enabled. Smart
+ // actions are grouped with extensions and the separator logic is
+ // handled by them.
const bool prepend_separator =
*index == 0 && menu_model_->GetItemCount() &&
- !::features::IsTouchableAppContextMenuEnabled();
+ !::features::IsTouchableAppContextMenuEnabled() &&
+ !is_smart_text_selection_enabled_;
// Extensions (other than platform apps) are only allowed one top-level slot
// (and it can't be a radio or checkbox item because we are going to put the