| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_WEB_DIALOG_UI_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "content/public/browser/web_ui_controller.h" | 10 #include "content/public/browser/web_ui_controller.h" |
| 11 | 11 |
| 12 class ConstrainedWindow; | 12 class ConstrainedWindow; |
| 13 class HtmlDialogTabContentsDelegate; | |
| 14 class HtmlDialogUIDelegate; | |
| 15 class Profile; | 13 class Profile; |
| 16 class TabContentsWrapper; | 14 class TabContentsWrapper; |
| 15 class WebDialogDelegate; |
| 16 class WebDialogWebContentsDelegate; |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 template<class T> class PropertyAccessor; | 19 template<class T> class PropertyAccessor; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 class RenderViewHost; | 23 class RenderViewHost; |
| 24 } | 24 } |
| 25 | 25 |
| 26 class ConstrainedHtmlUIDelegate { | 26 class ConstrainedWebDialogDelegate { |
| 27 public: | 27 public: |
| 28 virtual const HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() const = 0; | 28 virtual const WebDialogDelegate* GetWebDialogDelegate() const = 0; |
| 29 virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() = 0; | 29 virtual WebDialogDelegate* GetWebDialogDelegate() = 0; |
| 30 | 30 |
| 31 // Called when the dialog is being closed in response to a "DialogClose" | 31 // Called when the dialog is being closed in response to a "DialogClose" |
| 32 // message from WebUI. | 32 // message from WebUI. |
| 33 virtual void OnDialogCloseFromWebUI() = 0; | 33 virtual void OnDialogCloseFromWebUI() = 0; |
| 34 | 34 |
| 35 // If called, on dialog closure, the dialog will release its WebContents | 35 // If called, on dialog closure, the dialog will release its WebContents |
| 36 // instead of destroying it. After which point, the caller will own the | 36 // instead of destroying it. After which point, the caller will own the |
| 37 // released WebContents. | 37 // released WebContents. |
| 38 virtual void ReleaseTabContentsOnDialogClose() = 0; | 38 virtual void ReleaseTabContentsOnDialogClose() = 0; |
| 39 | 39 |
| 40 // Returns the ConstrainedWindow. | 40 // Returns the ConstrainedWindow. |
| 41 virtual ConstrainedWindow* window() = 0; | 41 virtual ConstrainedWindow* window() = 0; |
| 42 | 42 |
| 43 // Returns the TabContentsWrapper owned by the constrained window. | 43 // Returns the TabContentsWrapper owned by the constrained window. |
| 44 virtual TabContentsWrapper* tab() = 0; | 44 virtual TabContentsWrapper* tab() = 0; |
| 45 | 45 |
| 46 protected: | 46 protected: |
| 47 virtual ~ConstrainedHtmlUIDelegate() {} | 47 virtual ~ConstrainedWebDialogDelegate() {} |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 // ConstrainedHtmlUI is a facility to show HTML WebUI content | 50 // ConstrainedWebDialogUI is a facility to show HTML WebUI content |
| 51 // in a tab-modal constrained dialog. It is implemented as an adapter | 51 // in a tab-modal constrained dialog. It is implemented as an adapter |
| 52 // between an HtmlDialogUI object and a ConstrainedWindow object. | 52 // between an WebDialogUI object and a ConstrainedWindow object. |
| 53 // | 53 // |
| 54 // Since ConstrainedWindow requires platform-specific delegate | 54 // Since ConstrainedWindow requires platform-specific delegate |
| 55 // implementations, this class is just a factory stub. | 55 // implementations, this class is just a factory stub. |
| 56 // TODO(thestig) Refactor the platform-independent code out of the | 56 // TODO(thestig) Refactor the platform-independent code out of the |
| 57 // platform-specific implementations. | 57 // platform-specific implementations. |
| 58 class ConstrainedHtmlUI : public content::WebUIController { | 58 class ConstrainedWebDialogUI : public content::WebUIController { |
| 59 public: | 59 public: |
| 60 explicit ConstrainedHtmlUI(content::WebUI* web_ui); | 60 explicit ConstrainedWebDialogUI(content::WebUI* web_ui); |
| 61 virtual ~ConstrainedHtmlUI(); | 61 virtual ~ConstrainedWebDialogUI(); |
| 62 | 62 |
| 63 // WebUIController implementation: | 63 // WebUIController implementation: |
| 64 virtual void RenderViewCreated( | 64 virtual void RenderViewCreated( |
| 65 content::RenderViewHost* render_view_host) OVERRIDE; | 65 content::RenderViewHost* render_view_host) OVERRIDE; |
| 66 | 66 |
| 67 // Create a constrained HTML dialog. The actual object that gets created | 67 // Create a constrained HTML dialog. The actual object that gets created |
| 68 // is a ConstrainedHtmlUIDelegate, which later triggers construction of a | 68 // is a ConstrainedWebDialogDelegate, which later triggers construction of a |
| 69 // ConstrainedHtmlUI object. | 69 // ConstrainedWebDialogUI object. |
| 70 // |profile| is used to construct the constrained HTML dialog's WebContents. | 70 // |profile| is used to construct the constrained HTML dialog's WebContents. |
| 71 // |delegate| controls the behavior of the dialog. | 71 // |delegate| controls the behavior of the dialog. |
| 72 // |tab_delegate| is optional, pass one in to use a custom | 72 // |tab_delegate| is optional, pass one in to use a custom |
| 73 // HtmlDialogTabContentsDelegate with the dialog, or NULL to | 73 // WebDialogWebContentsDelegate with the dialog, or NULL to |
| 74 // use the default one. The dialog takes ownership of | 74 // use the default one. The dialog takes ownership of |
| 75 // |tab_delegate|. | 75 // |tab_delegate|. |
| 76 // |overshadowed| is the tab being overshadowed by the dialog. | 76 // |overshadowed| is the tab being overshadowed by the dialog. |
| 77 static ConstrainedHtmlUIDelegate* CreateConstrainedHtmlDialog( | 77 static ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( |
| 78 Profile* profile, | 78 Profile* profile, |
| 79 HtmlDialogUIDelegate* delegate, | 79 WebDialogDelegate* delegate, |
| 80 HtmlDialogTabContentsDelegate* tab_delegate, | 80 WebDialogWebContentsDelegate* tab_delegate, |
| 81 TabContentsWrapper* overshadowed); | 81 TabContentsWrapper* overshadowed); |
| 82 | 82 |
| 83 // Returns a property accessor that can be used to set the | 83 // Returns a property accessor that can be used to set the |
| 84 // ConstrainedHtmlUIDelegate property on a WebContents. | 84 // ConstrainedWebDialogDelegate property on a WebContents. |
| 85 static base::PropertyAccessor<ConstrainedHtmlUIDelegate*>& | 85 static base::PropertyAccessor<ConstrainedWebDialogDelegate*>& |
| 86 GetPropertyAccessor(); | 86 GetPropertyAccessor(); |
| 87 | 87 |
| 88 protected: | 88 protected: |
| 89 // Returns the WebContents' PropertyBag's ConstrainedHtmlUIDelegate. | 89 // Returns the WebContents' PropertyBag's ConstrainedWebDialogDelegate. |
| 90 // Returns NULL if that property is not set. | 90 // Returns NULL if that property is not set. |
| 91 ConstrainedHtmlUIDelegate* GetConstrainedDelegate(); | 91 ConstrainedWebDialogDelegate* GetConstrainedDelegate(); |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 // JS Message Handler | 94 // JS Message Handler |
| 95 void OnDialogCloseMessage(const base::ListValue* args); | 95 void OnDialogCloseMessage(const base::ListValue* args); |
| 96 | 96 |
| 97 DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlUI); | 97 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogUI); |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ | 100 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_UI_H_ |
| OLD | NEW |