1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_RENDERER_CONTEXT_MENU_CONTEXT_MENU_DELEGATE_H_
6 #define COMPONENTS_RENDERER_CONTEXT_MENU_CONTEXT_MENU_DELEGATE_H_
10 class RenderViewContextMenuBase;
13 class RenderFrameHost;
15 struct ContextMenuParams;
18 // A ContextMenuDelegate can build and show renderer context menu.
19 class ContextMenuDelegate {
21 explicit ContextMenuDelegate(content::WebContents* web_contents);
23 ContextMenuDelegate(const ContextMenuDelegate&) = delete;
24 ContextMenuDelegate& operator=(const ContextMenuDelegate&) = delete;
26 virtual ~ContextMenuDelegate();
28 static ContextMenuDelegate* FromWebContents(
29 content::WebContents* web_contents);
31 // Builds and returns a context menu for a context specified by |params|.
33 // The |render_frame_host| represents the frame where the context menu has
34 // been opened (typically this frame is focused, but this is not necessarily
35 // the case - see https://crbug.com/1257907#c14).
37 // The returned value can be used to display the context menu.
38 virtual std::unique_ptr<RenderViewContextMenuBase> BuildMenu(
39 content::RenderFrameHost& render_frame_host,
40 const content::ContextMenuParams& params) = 0;
42 // Displays the context menu.
43 virtual void ShowMenu(std::unique_ptr<RenderViewContextMenuBase> menu) = 0;
46 #endif // COMPONENTS_RENDERER_CONTEXT_MENU_CONTEXT_MENU_DELEGATE_H_