| 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 ATHENA_VIRTUAL_KEYBOARD_VK_WEBUI_CONTROLLER_H_ | 5 #ifndef UI_KEYBOARD_WEBUI_VK_WEBUI_CONTROLLER_H_ |
| 6 #define ATHENA_VIRTUAL_KEYBOARD_VK_WEBUI_CONTROLLER_H_ | 6 #define UI_KEYBOARD_WEBUI_VK_WEBUI_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/memory/weak_ptr.h" |
| 10 #include "content/public/browser/web_ui_controller.h" | 11 #include "content/public/browser/web_ui_controller.h" |
| 11 #include "content/public/browser/web_ui_controller_factory.h" | 12 #include "content/public/browser/web_ui_controller_factory.h" |
| 13 #include "mojo/public/cpp/system/core.h" |
| 14 #include "ui/keyboard/keyboard_export.h" |
| 12 | 15 |
| 13 namespace athena { | 16 namespace content { |
| 17 class WebUIDataSource; |
| 18 } |
| 19 |
| 20 namespace keyboard { |
| 21 |
| 22 class VKMojoHandler; |
| 14 | 23 |
| 15 class VKWebUIController : public content::WebUIController { | 24 class VKWebUIController : public content::WebUIController { |
| 16 public: | 25 public: |
| 17 explicit VKWebUIController(content::WebUI* web_ui); | 26 explicit VKWebUIController(content::WebUI* web_ui); |
| 18 virtual ~VKWebUIController(); | 27 virtual ~VKWebUIController(); |
| 19 | 28 |
| 20 private: | 29 private: |
| 30 void CreateAndStoreUIHandler(mojo::ScopedMessagePipeHandle handle_to_api); |
| 31 |
| 32 // content::WebUIController: |
| 33 virtual void RenderViewCreated(content::RenderViewHost* host) OVERRIDE; |
| 34 |
| 35 scoped_ptr<VKMojoHandler> ui_handler_; |
| 36 base::WeakPtrFactory<VKWebUIController> weak_factory_; |
| 37 |
| 21 DISALLOW_COPY_AND_ASSIGN(VKWebUIController); | 38 DISALLOW_COPY_AND_ASSIGN(VKWebUIController); |
| 22 }; | 39 }; |
| 23 | 40 |
| 24 class VKWebUIControllerFactory : public content::WebUIControllerFactory { | 41 class KEYBOARD_EXPORT VKWebUIControllerFactory |
| 42 : public content::WebUIControllerFactory { |
| 25 public: | 43 public: |
| 26 // WebUIControllerFactory: | 44 // WebUIControllerFactory: |
| 27 virtual content::WebUI::TypeID GetWebUIType( | 45 virtual content::WebUI::TypeID GetWebUIType( |
| 28 content::BrowserContext* browser_context, | 46 content::BrowserContext* browser_context, |
| 29 const GURL& url) const OVERRIDE; | 47 const GURL& url) const OVERRIDE; |
| 30 virtual bool UseWebUIForURL(content::BrowserContext* browser_context, | 48 virtual bool UseWebUIForURL(content::BrowserContext* browser_context, |
| 31 const GURL& url) const OVERRIDE; | 49 const GURL& url) const OVERRIDE; |
| 32 virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context, | 50 virtual bool UseWebUIBindingsForURL(content::BrowserContext* browser_context, |
| 33 const GURL& url) const OVERRIDE; | 51 const GURL& url) const OVERRIDE; |
| 34 virtual content::WebUIController* CreateWebUIControllerForURL( | 52 virtual content::WebUIController* CreateWebUIControllerForURL( |
| 35 content::WebUI* web_ui, | 53 content::WebUI* web_ui, |
| 36 const GURL& url) const OVERRIDE; | 54 const GURL& url) const OVERRIDE; |
| 37 | 55 |
| 38 static VKWebUIControllerFactory* GetInstance(); | 56 static VKWebUIControllerFactory* GetInstance(); |
| 39 | 57 |
| 40 protected: | 58 protected: |
| 41 VKWebUIControllerFactory(); | 59 VKWebUIControllerFactory(); |
| 42 virtual ~VKWebUIControllerFactory(); | 60 virtual ~VKWebUIControllerFactory(); |
| 43 | 61 |
| 44 private: | 62 private: |
| 45 friend struct DefaultSingletonTraits<VKWebUIControllerFactory>; | 63 friend struct DefaultSingletonTraits<VKWebUIControllerFactory>; |
| 46 | 64 |
| 47 DISALLOW_COPY_AND_ASSIGN(VKWebUIControllerFactory); | 65 DISALLOW_COPY_AND_ASSIGN(VKWebUIControllerFactory); |
| 48 }; | 66 }; |
| 49 | 67 |
| 50 } // namespace athena | 68 } // namespace keyboard |
| 51 | 69 |
| 52 #endif // ATHENA_VIRTUAL_KEYBOARD_VK_WEBUI_CONTROLLER_H_ | 70 #endif // UI_KEYBOARD_WEBUI_VK_WEBUI_CONTROLLER_H_ |
| OLD | NEW |