OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_WEBUI_MOJO_WEB_UI_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_MOJO_WEB_UI_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_MOJO_WEB_UI_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_MOJO_WEB_UI_CONTROLLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // files, eg: | 47 // files, eg: |
48 // AddMojoResourcePath("chrome/browser/ui/webui/omnibox/omnibox.mojom", | 48 // AddMojoResourcePath("chrome/browser/ui/webui/omnibox/omnibox.mojom", |
49 // IDR_OMNIBOX_MOJO_JS); | 49 // IDR_OMNIBOX_MOJO_JS); |
50 // . Override BindUIHandler() to create and bind the implementation of the | 50 // . Override BindUIHandler() to create and bind the implementation of the |
51 // bindings. | 51 // bindings. |
52 template <typename Interface> | 52 template <typename Interface> |
53 class MojoWebUIController : public MojoWebUIControllerBase { | 53 class MojoWebUIController : public MojoWebUIControllerBase { |
54 public: | 54 public: |
55 explicit MojoWebUIController(content::WebUI* contents) | 55 explicit MojoWebUIController(content::WebUI* contents) |
56 : MojoWebUIControllerBase(contents), weak_factory_(this) {} | 56 : MojoWebUIControllerBase(contents), weak_factory_(this) {} |
57 virtual ~MojoWebUIController() {} | 57 ~MojoWebUIController() override {} |
58 virtual void RenderViewCreated( | 58 void RenderViewCreated(content::RenderViewHost* render_view_host) override { |
59 content::RenderViewHost* render_view_host) override { | |
60 MojoWebUIControllerBase::RenderViewCreated(render_view_host); | 59 MojoWebUIControllerBase::RenderViewCreated(render_view_host); |
61 render_view_host->GetMainFrame()->GetServiceRegistry()-> | 60 render_view_host->GetMainFrame()->GetServiceRegistry()-> |
62 AddService<Interface>( | 61 AddService<Interface>( |
63 base::Bind(&MojoWebUIController::BindUIHandler, | 62 base::Bind(&MojoWebUIController::BindUIHandler, |
64 weak_factory_.GetWeakPtr())); | 63 weak_factory_.GetWeakPtr())); |
65 } | 64 } |
66 | 65 |
67 protected: | 66 protected: |
68 // Invoked to create the specific bindings implementation. | 67 // Invoked to create the specific bindings implementation. |
69 virtual void BindUIHandler(mojo::InterfaceRequest<Interface> request) = 0; | 68 virtual void BindUIHandler(mojo::InterfaceRequest<Interface> request) = 0; |
70 | 69 |
71 private: | 70 private: |
72 base::WeakPtrFactory<MojoWebUIController> weak_factory_; | 71 base::WeakPtrFactory<MojoWebUIController> weak_factory_; |
73 | 72 |
74 DISALLOW_COPY_AND_ASSIGN(MojoWebUIController); | 73 DISALLOW_COPY_AND_ASSIGN(MojoWebUIController); |
75 }; | 74 }; |
76 | 75 |
77 #endif // CHROME_BROWSER_UI_WEBUI_MOJO_WEB_UI_CONTROLLER_H_ | 76 #endif // CHROME_BROWSER_UI_WEBUI_MOJO_WEB_UI_CONTROLLER_H_ |
OLD | NEW |