| 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 "chrome/browser/ui/webui/chrome_web_ui.h" | 9 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
| 10 #include "content/common/property_bag.h" | 10 #include "content/common/property_bag.h" |
| 11 | 11 |
| 12 class ConstrainedWindow; | 12 class ConstrainedWindow; |
| 13 class HtmlDialogUIDelegate; | 13 class HtmlDialogUIDelegate; |
| 14 class Profile; | 14 class Profile; |
| 15 class RenderViewHost; | 15 class RenderViewHost; |
| 16 class TabContents; | 16 class TabContents; |
| 17 class TabContentsWrapper; | 17 class TabContentsWrapper; |
| 18 | 18 |
| 19 class ConstrainedHtmlUIDelegate { | 19 class ConstrainedHtmlUIDelegate { |
| 20 public: | 20 public: |
| 21 virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() = 0; | 21 virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() = 0; |
| 22 | 22 |
| 23 // Called when the dialog is being closed in response to a "DialogClose" | 23 // Called when the dialog is being closed in response to a "DialogClose" |
| 24 // message from WebUI. | 24 // message from WebUI. |
| 25 virtual void OnDialogCloseFromWebUI() = 0; | 25 virtual void OnDialogCloseFromWebUI() = 0; |
| 26 |
| 27 // If called, on dialog closure, the dialog will release its TabContents |
| 28 // instead of destroying it. After which point, the caller will own the |
| 29 // released TabContents. |
| 30 virtual void ReleaseTabContentsOnDialogClose() = 0; |
| 31 |
| 32 // Returns the ConstrainedWindow. |
| 33 virtual ConstrainedWindow* window() = 0; |
| 34 |
| 35 // Returns the TabContentsWrapper owned by the constrained window. |
| 36 virtual TabContentsWrapper* tab() = 0; |
| 37 |
| 38 protected: |
| 39 virtual ~ConstrainedHtmlUIDelegate() {} |
| 26 }; | 40 }; |
| 27 | 41 |
| 28 // ConstrainedHtmlUI is a facility to show HTML WebUI content | 42 // ConstrainedHtmlUI is a facility to show HTML WebUI content |
| 29 // in a tab-modal constrained dialog. It is implemented as an adapter | 43 // in a tab-modal constrained dialog. It is implemented as an adapter |
| 30 // between an HtmlDialogUI object and a ConstrainedWindow object. | 44 // between an HtmlDialogUI object and a ConstrainedWindow object. |
| 31 // | 45 // |
| 32 // Since ConstrainedWindow requires platform-specific delegate | 46 // Since ConstrainedWindow requires platform-specific delegate |
| 33 // implementations, this class is just a factory stub. | 47 // implementations, this class is just a factory stub. |
| 34 class ConstrainedHtmlUI : public ChromeWebUI { | 48 class ConstrainedHtmlUI : public ChromeWebUI { |
| 35 public: | 49 public: |
| 36 explicit ConstrainedHtmlUI(TabContents* contents); | 50 explicit ConstrainedHtmlUI(TabContents* contents); |
| 37 virtual ~ConstrainedHtmlUI(); | 51 virtual ~ConstrainedHtmlUI(); |
| 38 | 52 |
| 39 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; | 53 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
| 40 | 54 |
| 41 // Create a constrained HTML dialog. The actual object that gets created | 55 // Create a constrained HTML dialog. The actual object that gets created |
| 42 // is a ConstrainedHtmlUIDelegate, which later triggers construction of a | 56 // is a ConstrainedHtmlUIDelegate, which later triggers construction of a |
| 43 // ConstrainedHtmlUI object. | 57 // ConstrainedHtmlUI object. |
| 44 static ConstrainedWindow* CreateConstrainedHtmlDialog( | 58 static ConstrainedHtmlUIDelegate* CreateConstrainedHtmlDialog( |
| 45 Profile* profile, | 59 Profile* profile, |
| 46 HtmlDialogUIDelegate* delegate, | 60 HtmlDialogUIDelegate* delegate, |
| 47 TabContentsWrapper* overshadowed); | 61 TabContentsWrapper* overshadowed); |
| 48 | 62 |
| 49 // Returns a property accessor that can be used to set the | 63 // Returns a property accessor that can be used to set the |
| 50 // ConstrainedHtmlUIDelegate property on a TabContents. | 64 // ConstrainedHtmlUIDelegate property on a TabContents. |
| 51 static PropertyAccessor<ConstrainedHtmlUIDelegate*>& | 65 static PropertyAccessor<ConstrainedHtmlUIDelegate*>& |
| 52 GetPropertyAccessor(); | 66 GetPropertyAccessor(); |
| 53 | 67 |
| 54 private: | 68 private: |
| 55 // Returns the TabContents' PropertyBag's ConstrainedHtmlUIDelegate. | 69 // Returns the TabContents' PropertyBag's ConstrainedHtmlUIDelegate. |
| 56 // Returns NULL if that property is not set. | 70 // Returns NULL if that property is not set. |
| 57 ConstrainedHtmlUIDelegate* GetConstrainedDelegate(); | 71 ConstrainedHtmlUIDelegate* GetConstrainedDelegate(); |
| 58 | 72 |
| 59 // JS Message Handler | 73 // JS Message Handler |
| 60 void OnDialogCloseMessage(const base::ListValue* args); | 74 void OnDialogCloseMessage(const base::ListValue* args); |
| 61 | 75 |
| 62 DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlUI); | 76 DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlUI); |
| 63 }; | 77 }; |
| 64 | 78 |
| 65 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ | 79 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ |
| OLD | NEW |