| 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" |
| 11 #include "base/memory/weak_ptr.h" |
| 11 #include "content/public/browser/web_ui_controller.h" | 12 #include "content/public/browser/web_ui_controller.h" |
| 12 #include "mojo/public/cpp/system/core.h" | 13 #include "mojo/public/cpp/system/core.h" |
| 13 | 14 |
| 14 class MojoWebUIHandler; | 15 class MojoWebUIHandler; |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 class WebUIDataSource; | 18 class WebUIDataSource; |
| 18 } | 19 } |
| 19 | 20 |
| 20 // MojoWebUIController is intended for web ui pages that use mojo. It is | 21 // MojoWebUIController is intended for web ui pages that use mojo. It is |
| (...skipping 14 matching lines...) Expand all Loading... |
| 35 | 36 |
| 36 protected: | 37 protected: |
| 37 // Invoke to register mapping between binding file and resource id (IDR_...). | 38 // Invoke to register mapping between binding file and resource id (IDR_...). |
| 38 void AddMojoResourcePath(const std::string& path, int resource_id); | 39 void AddMojoResourcePath(const std::string& path, int resource_id); |
| 39 | 40 |
| 40 // Invoked to create the specific bindings implementation. | 41 // Invoked to create the specific bindings implementation. |
| 41 virtual scoped_ptr<MojoWebUIHandler> CreateUIHandler( | 42 virtual scoped_ptr<MojoWebUIHandler> CreateUIHandler( |
| 42 mojo::ScopedMessagePipeHandle handle_to_page) = 0; | 43 mojo::ScopedMessagePipeHandle handle_to_page) = 0; |
| 43 | 44 |
| 44 private: | 45 private: |
| 46 // Invoked in response to a connection from the renderer. |
| 47 void CreateAndStoreUIHandler(mojo::ScopedMessagePipeHandle handle); |
| 48 |
| 45 // Bindings files are registered here. | 49 // Bindings files are registered here. |
| 46 content::WebUIDataSource* mojo_data_source_; | 50 content::WebUIDataSource* mojo_data_source_; |
| 47 | 51 |
| 48 scoped_ptr<MojoWebUIHandler> ui_handler_; | 52 scoped_ptr<MojoWebUIHandler> ui_handler_; |
| 49 | 53 |
| 54 base::WeakPtrFactory<MojoWebUIController> weak_factory_; |
| 55 |
| 50 DISALLOW_COPY_AND_ASSIGN(MojoWebUIController); | 56 DISALLOW_COPY_AND_ASSIGN(MojoWebUIController); |
| 51 }; | 57 }; |
| 52 | 58 |
| 53 #endif // CHROME_BROWSER_UI_WEBUI_MOJO_WEB_UI_CONTROLLER_H_ | 59 #endif // CHROME_BROWSER_UI_WEBUI_MOJO_WEB_UI_CONTROLLER_H_ |
| OLD | NEW |