[cr148] is_paste_and_match_style_enabled plumbed into context menu
This argument only gets passed along for our purposes. Chromium changes: https://chromium.googlesource.com/chromium/src/+/54777b8f87dcd034f40ffa2bae1ffe0e5b59d321 commit 54777b8f87dcd034f40ffa2bae1ffe0e5b59d321 Author: Tom Anderson <thomasanderson@chromium.org> Date: Thu Mar 12 20:04:07 2026 -0700 [Clipboard] Async GetAllAvailableFormats replaces sync IsFormatAvailable This change replaces the synchronous IsFormatAvailable method in ui::Clipboard with an asynchronous GetAllAvailableFormats method. The new method takes a callback and returns a set of all available formats. All platform implementations (Android, Windows, Mac, Ozone, iOS, and the non-backed implementation) have been updated. Callers across the codebase have been refactored to use the new asynchronous API, often utilizing a pseudo-synchronous pattern where acceptable or updating to full async. Synchronous convenience functions were added to clipboard_test_util to facilitate the update of the extensive test suite. IsFormatAvailable is most commonly used to enable the "Paste" menu item in context menus. The strategy is to obtain this state before the menu is created, since the menu delegate interface for determining if a command is enabled should remain synchronous. Behavior is preserved by this change except for a change in Textfield (and it's subclass OmniboxViewViews): when pasting, the clipboard is assumed to contain content. The consequence of this is event propagation of Ctrl-V keypresses will stop on the Textfield when it may otherwise have been propagated to parent views. This is deemed an acceptable tradeoff for the async migration since this behavior is unlikely to ever get hit. Bug: 40398800 Change-Id: Ibc005d100d9cfd21cb9f06c758ce0a98282fdb97 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7631097 Reviewed-by: Olivier Robin <olivierrobin@chromium.org> Reviewed-by: Mikel Astiz <mastiz@chromium.org> Reviewed-by: Colin Blundell <blundell@chromium.org> Commit-Queue: Thomas Anderson <thomasanderson@chromium.org> Reviewed-by: Avi Drissman <avi@chromium.org> Reviewed-by: Mitsuru Oshima <oshima@chromium.org> Reviewed-by: Mike Wasserman <msw@chromium.org> Cr-Commit-Position: refs/heads/main@{#1598848}
This commit is contained in:
@@ -97,7 +97,7 @@ class BraveRenderViewContextMenuTest : public testing::Test {
|
||||
ResetBrowser();
|
||||
auto menu = std::make_unique<BraveRenderViewContextMenuMock>(
|
||||
*web_contents->GetPrimaryMainFrame(), params,
|
||||
/*is_paste_enabled=*/false);
|
||||
/*is_paste_enabled=*/false, /*is_paste_and_match_style_enabled=*/false);
|
||||
|
||||
Browser::CreateParams create_params(
|
||||
is_pwa_browser ? Browser::Type::TYPE_APP : Browser::Type::TYPE_NORMAL,
|
||||
|
||||
@@ -8,8 +8,12 @@
|
||||
BraveRenderViewContextMenuViews::BraveRenderViewContextMenuViews(
|
||||
content::RenderFrameHost& render_frame_host,
|
||||
const content::ContextMenuParams& params,
|
||||
bool is_paste_enabled)
|
||||
: RenderViewContextMenuViews(render_frame_host, params, is_paste_enabled) {}
|
||||
bool is_paste_enabled,
|
||||
bool is_paste_and_match_style_enabled)
|
||||
: RenderViewContextMenuViews(render_frame_host,
|
||||
params,
|
||||
is_paste_enabled,
|
||||
is_paste_and_match_style_enabled) {}
|
||||
|
||||
BraveRenderViewContextMenuViews::~BraveRenderViewContextMenuViews() = default;
|
||||
|
||||
@@ -17,9 +21,11 @@ BraveRenderViewContextMenuViews::~BraveRenderViewContextMenuViews() = default;
|
||||
RenderViewContextMenuViews* BraveRenderViewContextMenuViews::Create(
|
||||
content::RenderFrameHost& render_frame_host,
|
||||
const content::ContextMenuParams& params,
|
||||
bool is_paste_enabled) {
|
||||
bool is_paste_enabled,
|
||||
bool is_paste_and_match_style_enabled) {
|
||||
return new BraveRenderViewContextMenuViews(render_frame_host, params,
|
||||
is_paste_enabled);
|
||||
is_paste_enabled,
|
||||
is_paste_and_match_style_enabled);
|
||||
}
|
||||
|
||||
void BraveRenderViewContextMenuViews::Show() {
|
||||
|
||||
@@ -22,7 +22,8 @@ class BraveRenderViewContextMenuViews : public RenderViewContextMenuViews {
|
||||
// NOLINTNEXTLINE(runtime/references)
|
||||
content::RenderFrameHost& render_frame_host,
|
||||
const content::ContextMenuParams& params,
|
||||
bool is_paste_enabled);
|
||||
bool is_paste_enabled,
|
||||
bool is_paste_and_match_style_enabled);
|
||||
|
||||
void Show() override;
|
||||
|
||||
@@ -31,7 +32,8 @@ class BraveRenderViewContextMenuViews : public RenderViewContextMenuViews {
|
||||
// NOLINTNEXTLINE(runtime/references)
|
||||
BraveRenderViewContextMenuViews(content::RenderFrameHost& render_frame_host,
|
||||
const content::ContextMenuParams& params,
|
||||
bool is_paste_enabled);
|
||||
bool is_paste_enabled,
|
||||
bool is_paste_and_match_style_enabled);
|
||||
};
|
||||
|
||||
#endif // BRAVE_BROWSER_UI_VIEWS_RENDERER_CONTEXT_MENU_BRAVE_RENDER_VIEW_CONTEXT_MENU_VIEWS_H_
|
||||
|
||||
@@ -323,10 +323,12 @@ email_aliases::EmailAliasesController* GetEmailAliasesController(
|
||||
RenderViewContextMenu::RenderViewContextMenu(
|
||||
content::RenderFrameHost& render_frame_host,
|
||||
const content::ContextMenuParams& params,
|
||||
bool is_paste_enabled)
|
||||
bool is_paste_enabled,
|
||||
bool is_paste_and_match_style_enabled)
|
||||
: RenderViewContextMenu_Chromium(render_frame_host,
|
||||
params,
|
||||
is_paste_enabled)
|
||||
is_paste_enabled,
|
||||
is_paste_and_match_style_enabled)
|
||||
#if BUILDFLAG(ENABLE_AI_CHAT)
|
||||
,
|
||||
ai_chat_submenu_model_(this),
|
||||
|
||||
@@ -58,7 +58,8 @@ class RenderViewContextMenu : public RenderViewContextMenu_Chromium
|
||||
// NOLINTNEXTLINE(runtime/references)
|
||||
RenderViewContextMenu(content::RenderFrameHost& render_frame_host,
|
||||
const content::ContextMenuParams& params,
|
||||
bool is_paste_enabled);
|
||||
bool is_paste_enabled,
|
||||
bool is_paste_and_match_style_enabled);
|
||||
~RenderViewContextMenu() override;
|
||||
// RenderViewContextMenuBase:
|
||||
bool IsCommandIdEnabled(int command_id) const override;
|
||||
|
||||
Reference in New Issue
Block a user