feat: emit context-menu event from extensions (#38356)

feat: emit context-menu event from extensions

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot]
2023-05-18 16:58:40 -04:00
committed by GitHub
parent 7910ace135
commit ab0a13eed6
2 changed files with 14 additions and 4 deletions

View File

@@ -330,6 +330,9 @@ class WebContents : public ExclusiveAccessContext,
const base::FilePath& file_path);
v8::Local<v8::Promise> GetProcessMemoryInfo(v8::Isolate* isolate);
bool HandleContextMenu(content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params) override;
// Properties.
int32_t ID() const { return id_; }
v8::Local<v8::Value> Session(v8::Isolate* isolate);
@@ -555,8 +558,6 @@ class WebContents : public ExclusiveAccessContext,
void RendererResponsive(
content::WebContents* source,
content::RenderWidgetHost* render_widget_host) override;
bool HandleContextMenu(content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params) override;
void FindReply(content::WebContents* web_contents,
int request_id,
int number_of_matches,

View File

@@ -65,10 +65,19 @@ class ElectronMimeHandlerViewGuestDelegate
// MimeHandlerViewGuestDelegate.
bool HandleContextMenu(content::RenderFrameHost& render_frame_host,
const content::ContextMenuParams& params) override {
// TODO(nornagon): surface this event to JS
LOG(INFO) << "HCM";
auto* web_contents =
content::WebContents::FromRenderFrameHost(&render_frame_host);
if (!web_contents)
return true;
electron::api::WebContents* api_web_contents =
electron::api::WebContents::From(
web_contents->GetOutermostWebContents());
if (api_web_contents)
api_web_contents->HandleContextMenu(render_frame_host, params);
return true;
}
void RecordLoadMetric(bool in_main_frame,
const std::string& mime_type) override {}
};