context_menu_delegate.h 1.5 KB

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