mojo_web_ui_controller.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 UI_WEBUI_MOJO_WEB_UI_CONTROLLER_H_
  5. #define UI_WEBUI_MOJO_WEB_UI_CONTROLLER_H_
  6. #include "content/public/browser/web_ui.h"
  7. #include "content/public/browser/web_ui_controller.h"
  8. namespace ui {
  9. // MojoWebUIController is intended for WebUI pages that use Mojo. It is
  10. // expected that subclasses will:
  11. // . Add all Mojo Bindings Resources via AddResourcePath(), eg:
  12. // source->AddResourcePath("chrome/browser/ui/webui/omnibox/omnibox.mojom",
  13. // IDR_OMNIBOX_MOJO_JS);
  14. // . Overload void BindInterface(mojo::PendingReceiver<InterfaceName>) for all
  15. // Mojo Interfaces it wishes to handle.
  16. // . Use WEB_UI_CONTROLLER_TYPE_DECL macro in .h file and
  17. // WEB_UI_CONTROLLER_TYPE_IMPL macro in .cc file.
  18. // . Register all Mojo Interfaces it wishes to handle in the appropriate
  19. // BinderMap:
  20. // - chrome/browser/chrome_browser_interface_binders.cc for chrome/ WebUIs;
  21. // - content/browser/browser_interface_binders.cc for content/ WebUIs.
  22. class MojoWebUIController : public content::WebUIController {
  23. public:
  24. // By default MojoWebUIControllers do not have normal WebUI bindings. Pass
  25. // |enable_chrome_send| as true if these are needed.
  26. explicit MojoWebUIController(content::WebUI* contents,
  27. bool enable_chrome_send = false);
  28. MojoWebUIController(const MojoWebUIController&) = delete;
  29. MojoWebUIController& operator=(const MojoWebUIController&) = delete;
  30. ~MojoWebUIController() override;
  31. };
  32. } // namespace ui
  33. #endif // UI_WEBUI_MOJO_WEB_UI_CONTROLLER_H_