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