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_HTML_DIALOG_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 // Stores the dialog bounds. | 80 // Stores the dialog bounds. |
81 virtual void StoreDialogSize(const gfx::Rect dialog_bounds) {} | 81 virtual void StoreDialogSize(const gfx::Rect dialog_bounds) {} |
82 | 82 |
83 protected: | 83 protected: |
84 virtual ~HtmlDialogUIDelegate() {} | 84 virtual ~HtmlDialogUIDelegate() {} |
85 }; | 85 }; |
86 | 86 |
87 // Displays file URL contents inside a modal HTML dialog. | 87 // Displays file URL contents inside a modal HTML dialog. |
88 // | 88 // |
89 // This application really should not use TabContents + WebUI. It should instead | 89 // This application really should not use WebContents + WebUI. It should instead |
90 // just embed a RenderView in a dialog and be done with it. | 90 // just embed a RenderView in a dialog and be done with it. |
91 // | 91 // |
92 // Before loading a URL corresponding to this WebUI, the caller should set its | 92 // Before loading a URL corresponding to this WebUI, the caller should set its |
93 // delegate as a property on the TabContents. This WebUI will pick it up from | 93 // delegate as a property on the WebContents. This WebUI will pick it up from |
94 // there and call it back. This is a bit of a hack to allow the dialog to pass | 94 // there and call it back. This is a bit of a hack to allow the dialog to pass |
95 // its delegate to the Web UI without having nasty accessors on the TabContents. | 95 // its delegate to the Web UI without having nasty accessors on the WebContents. |
96 // The correct design using RVH directly would avoid all of this. | 96 // The correct design using RVH directly would avoid all of this. |
97 class HtmlDialogUI : public ChromeWebUI { | 97 class HtmlDialogUI : public ChromeWebUI { |
98 public: | 98 public: |
99 struct HtmlDialogParams { | 99 struct HtmlDialogParams { |
100 // The URL for the content that will be loaded in the dialog. | 100 // The URL for the content that will be loaded in the dialog. |
101 GURL url; | 101 GURL url; |
102 // Width of the dialog. | 102 // Width of the dialog. |
103 int width; | 103 int width; |
104 // Height of the dialog. | 104 // Height of the dialog. |
105 int height; | 105 int height; |
106 // The JSON input to pass to the dialog when showing it. | 106 // The JSON input to pass to the dialog when showing it. |
107 std::string json_input; | 107 std::string json_input; |
108 }; | 108 }; |
109 | 109 |
110 // When created, the property should already be set on the TabContents. | 110 // When created, the property should already be set on the WebContents. |
111 explicit HtmlDialogUI(TabContents* tab_contents); | 111 explicit HtmlDialogUI(content::WebContents* web_contents); |
112 virtual ~HtmlDialogUI(); | 112 virtual ~HtmlDialogUI(); |
113 | 113 |
114 // Close the dialog, passing the specified arguments to the close handler. | 114 // Close the dialog, passing the specified arguments to the close handler. |
115 void CloseDialog(const base::ListValue* args); | 115 void CloseDialog(const base::ListValue* args); |
116 | 116 |
117 // Returns the PropertyBag accessor object used to write the delegate pointer | 117 // Returns the PropertyBag accessor object used to write the delegate pointer |
118 // into the TabContents (see class-level comment above). | 118 // into the WebContents (see class-level comment above). |
119 static base::PropertyAccessor<HtmlDialogUIDelegate*>& GetPropertyAccessor(); | 119 static base::PropertyAccessor<HtmlDialogUIDelegate*>& GetPropertyAccessor(); |
120 | 120 |
121 private: | 121 private: |
122 // WebUI | 122 // WebUI |
123 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; | 123 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
124 | 124 |
125 // JS message handler. | 125 // JS message handler. |
126 void OnDialogClosed(const base::ListValue* args); | 126 void OnDialogClosed(const base::ListValue* args); |
127 | 127 |
128 DISALLOW_COPY_AND_ASSIGN(HtmlDialogUI); | 128 DISALLOW_COPY_AND_ASSIGN(HtmlDialogUI); |
129 }; | 129 }; |
130 | 130 |
131 // Displays external URL contents inside a modal HTML dialog. | 131 // Displays external URL contents inside a modal HTML dialog. |
132 // | 132 // |
133 // Intended to be the place to collect the settings and lockdowns | 133 // Intended to be the place to collect the settings and lockdowns |
134 // necessary for running external UI components securely (e.g., the | 134 // necessary for running external UI components securely (e.g., the |
135 // cloud print dialog). | 135 // cloud print dialog). |
136 class ExternalHtmlDialogUI : public HtmlDialogUI { | 136 class ExternalHtmlDialogUI : public HtmlDialogUI { |
137 public: | 137 public: |
138 explicit ExternalHtmlDialogUI(TabContents* tab_contents); | 138 explicit ExternalHtmlDialogUI(content::WebContents* web_contents); |
139 virtual ~ExternalHtmlDialogUI(); | 139 virtual ~ExternalHtmlDialogUI(); |
140 }; | 140 }; |
141 | 141 |
142 #endif // CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ | 142 #endif // CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ |
OLD | NEW |