| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CONSTRAINED_HTML_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "content/browser/webui/web_ui.h" | 9 #include "content/browser/webui/web_ui.h" |
| 10 #include "content/public/browser/web_ui_controller.h" |
| 10 | 11 |
| 11 class ConstrainedWindow; | 12 class ConstrainedWindow; |
| 12 class HtmlDialogUIDelegate; | 13 class HtmlDialogUIDelegate; |
| 13 class Profile; | 14 class Profile; |
| 14 class RenderViewHost; | 15 class RenderViewHost; |
| 15 class TabContentsWrapper; | 16 class TabContentsWrapper; |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 template<class T> class PropertyAccessor; | 19 template<class T> class PropertyAccessor; |
| 19 } | 20 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 40 protected: | 41 protected: |
| 41 virtual ~ConstrainedHtmlUIDelegate() {} | 42 virtual ~ConstrainedHtmlUIDelegate() {} |
| 42 }; | 43 }; |
| 43 | 44 |
| 44 // ConstrainedHtmlUI is a facility to show HTML WebUI content | 45 // ConstrainedHtmlUI is a facility to show HTML WebUI content |
| 45 // in a tab-modal constrained dialog. It is implemented as an adapter | 46 // in a tab-modal constrained dialog. It is implemented as an adapter |
| 46 // between an HtmlDialogUI object and a ConstrainedWindow object. | 47 // between an HtmlDialogUI object and a ConstrainedWindow object. |
| 47 // | 48 // |
| 48 // Since ConstrainedWindow requires platform-specific delegate | 49 // Since ConstrainedWindow requires platform-specific delegate |
| 49 // implementations, this class is just a factory stub. | 50 // implementations, this class is just a factory stub. |
| 50 class ConstrainedHtmlUI : public WebUI { | 51 class ConstrainedHtmlUI : public WebUI, public content::WebUIController { |
| 51 public: | 52 public: |
| 52 explicit ConstrainedHtmlUI(content::WebContents* contents); | 53 explicit ConstrainedHtmlUI(content::WebContents* contents); |
| 53 virtual ~ConstrainedHtmlUI(); | 54 virtual ~ConstrainedHtmlUI(); |
| 54 | 55 |
| 56 // WebUIController implementation: |
| 55 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; | 57 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
| 56 | 58 |
| 57 // Create a constrained HTML dialog. The actual object that gets created | 59 // Create a constrained HTML dialog. The actual object that gets created |
| 58 // is a ConstrainedHtmlUIDelegate, which later triggers construction of a | 60 // is a ConstrainedHtmlUIDelegate, which later triggers construction of a |
| 59 // ConstrainedHtmlUI object. | 61 // ConstrainedHtmlUI object. |
| 60 static ConstrainedHtmlUIDelegate* CreateConstrainedHtmlDialog( | 62 static ConstrainedHtmlUIDelegate* CreateConstrainedHtmlDialog( |
| 61 Profile* profile, | 63 Profile* profile, |
| 62 HtmlDialogUIDelegate* delegate, | 64 HtmlDialogUIDelegate* delegate, |
| 63 TabContentsWrapper* overshadowed); | 65 TabContentsWrapper* overshadowed); |
| 64 | 66 |
| 65 // Returns a property accessor that can be used to set the | 67 // Returns a property accessor that can be used to set the |
| 66 // ConstrainedHtmlUIDelegate property on a WebContents. | 68 // ConstrainedHtmlUIDelegate property on a WebContents. |
| 67 static base::PropertyAccessor<ConstrainedHtmlUIDelegate*>& | 69 static base::PropertyAccessor<ConstrainedHtmlUIDelegate*>& |
| 68 GetPropertyAccessor(); | 70 GetPropertyAccessor(); |
| 69 | 71 |
| 70 protected: | 72 protected: |
| 71 // Returns the WebContents' PropertyBag's ConstrainedHtmlUIDelegate. | 73 // Returns the WebContents' PropertyBag's ConstrainedHtmlUIDelegate. |
| 72 // Returns NULL if that property is not set. | 74 // Returns NULL if that property is not set. |
| 73 ConstrainedHtmlUIDelegate* GetConstrainedDelegate(); | 75 ConstrainedHtmlUIDelegate* GetConstrainedDelegate(); |
| 74 | 76 |
| 75 private: | 77 private: |
| 76 // JS Message Handler | 78 // JS Message Handler |
| 77 void OnDialogCloseMessage(const base::ListValue* args); | 79 void OnDialogCloseMessage(const base::ListValue* args); |
| 78 | 80 |
| 79 DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlUI); | 81 DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlUI); |
| 80 }; | 82 }; |
| 81 | 83 |
| 82 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ | 84 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ |
| OLD | NEW |