Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: emit context-menu event from extensions #38356

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions shell/browser/api/electron_api_web_contents.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,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);
Expand Down Expand Up @@ -551,8 +554,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,
Expand Down
13 changes: 11 additions & 2 deletions shell/browser/extensions/electron_extensions_api_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
};
Expand Down