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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_MOJO_WEB_UI_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_MOJO_WEB_UI_CONTROLLER_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "content/public/browser/web_ui_controller.h"
12 #include "mojo/public/cpp/system/core.h"
14 class MojoWebUIHandler
;
17 class WebUIDataSource
;
20 // MojoWebUIController is intended for web ui pages that use mojo. It is
21 // expected that subclasses will do two things:
22 // . In the constructor invoke AddMojoResourcePath() to register the bindings
24 // AddMojoResourcePath("chrome/browser/ui/webui/omnibox/omnibox.mojom",
25 // IDR_OMNIBOX_MOJO_JS);
26 // . Override CreateUIHandler() to create the implementation of the bindings.
27 class MojoWebUIController
: public content::WebUIController
{
29 explicit MojoWebUIController(content::WebUI
* contents
);
30 virtual ~MojoWebUIController();
32 // WebUIController overrides:
33 virtual void RenderViewCreated(
34 content::RenderViewHost
* render_view_host
) OVERRIDE
;
37 // Invoke to register mapping between binding file and resource id (IDR_...).
38 void AddMojoResourcePath(const std::string
& path
, int resource_id
);
40 // Invoked to create the specific bindings implementation.
41 virtual scoped_ptr
<MojoWebUIHandler
> CreateUIHandler(
42 mojo::ScopedMessagePipeHandle handle_to_page
) = 0;
45 // Bindings files are registered here.
46 content::WebUIDataSource
* mojo_data_source_
;
48 scoped_ptr
<MojoWebUIHandler
> ui_handler_
;
50 DISALLOW_COPY_AND_ASSIGN(MojoWebUIController
);
53 #endif // CHROME_BROWSER_UI_WEBUI_MOJO_WEB_UI_CONTROLLER_H_