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_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> |
11 | 11 |
| 12 #include "base/compiler_specific.h" |
12 #include "base/string16.h" | 13 #include "base/string16.h" |
13 #include "content/browser/webui/web_ui.h" | |
14 #include "content/public/browser/web_ui_controller.h" | 14 #include "content/public/browser/web_ui_controller.h" |
15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
16 #include "ui/base/ui_base_types.h" | 16 #include "ui/base/ui_base_types.h" |
17 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
18 | 18 |
19 struct ContextMenuParams; | 19 struct ContextMenuParams; |
20 | 20 |
21 namespace base { | 21 namespace base { |
22 class ListValue; | 22 class ListValue; |
23 template<class T> class PropertyAccessor; | 23 template<class T> class PropertyAccessor; |
24 } | 24 } |
25 | 25 |
26 namespace content { | 26 namespace content { |
27 class WebContents; | 27 class WebContents; |
| 28 class WebUIMessageHandler; |
28 } | 29 } |
29 | 30 |
30 namespace gfx { | 31 namespace gfx { |
31 class Size; | 32 class Size; |
32 } | 33 } |
33 | 34 |
34 // Implement this class to receive notifications. | 35 // Implement this class to receive notifications. |
35 class HtmlDialogUIDelegate { | 36 class HtmlDialogUIDelegate { |
36 public: | 37 public: |
37 // Returns true if the contents needs to be run in a modal dialog. | 38 // Returns true if the contents needs to be run in a modal dialog. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // Displays file URL contents inside a modal HTML dialog. | 90 // Displays file URL contents inside a modal HTML dialog. |
90 // | 91 // |
91 // This application really should not use WebContents + WebUI. It should instead | 92 // This application really should not use WebContents + WebUI. It should instead |
92 // just embed a RenderView in a dialog and be done with it. | 93 // just embed a RenderView in a dialog and be done with it. |
93 // | 94 // |
94 // Before loading a URL corresponding to this WebUI, the caller should set its | 95 // Before loading a URL corresponding to this WebUI, the caller should set its |
95 // delegate as a property on the WebContents. This WebUI will pick it up from | 96 // delegate as a property on the WebContents. This WebUI will pick it up from |
96 // there and call it back. This is a bit of a hack to allow the dialog to pass | 97 // there and call it back. This is a bit of a hack to allow the dialog to pass |
97 // its delegate to the Web UI without having nasty accessors on the WebContents. | 98 // its delegate to the Web UI without having nasty accessors on the WebContents. |
98 // The correct design using RVH directly would avoid all of this. | 99 // The correct design using RVH directly would avoid all of this. |
99 class HtmlDialogUI : public WebUI, public content::WebUIController { | 100 class HtmlDialogUI : public content::WebUIController { |
100 public: | 101 public: |
101 struct HtmlDialogParams { | 102 struct HtmlDialogParams { |
102 // The URL for the content that will be loaded in the dialog. | 103 // The URL for the content that will be loaded in the dialog. |
103 GURL url; | 104 GURL url; |
104 // Width of the dialog. | 105 // Width of the dialog. |
105 int width; | 106 int width; |
106 // Height of the dialog. | 107 // Height of the dialog. |
107 int height; | 108 int height; |
108 // The JSON input to pass to the dialog when showing it. | 109 // The JSON input to pass to the dialog when showing it. |
109 std::string json_input; | 110 std::string json_input; |
110 }; | 111 }; |
111 | 112 |
112 // When created, the property should already be set on the WebContents. | 113 // When created, the property should already be set on the WebContents. |
113 explicit HtmlDialogUI(content::WebContents* web_contents); | 114 explicit HtmlDialogUI(WebUI* web_ui); |
114 virtual ~HtmlDialogUI(); | 115 virtual ~HtmlDialogUI(); |
115 | 116 |
116 // Close the dialog, passing the specified arguments to the close handler. | 117 // Close the dialog, passing the specified arguments to the close handler. |
117 void CloseDialog(const base::ListValue* args); | 118 void CloseDialog(const base::ListValue* args); |
118 | 119 |
119 // Returns the PropertyBag accessor object used to write the delegate pointer | 120 // Returns the PropertyBag accessor object used to write the delegate pointer |
120 // into the WebContents (see class-level comment above). | 121 // into the WebContents (see class-level comment above). |
121 static base::PropertyAccessor<HtmlDialogUIDelegate*>& GetPropertyAccessor(); | 122 static base::PropertyAccessor<HtmlDialogUIDelegate*>& GetPropertyAccessor(); |
122 | 123 |
123 private: | 124 private: |
124 // WebUIController | 125 // WebUIController |
125 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; | 126 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; |
126 | 127 |
127 // JS message handler. | 128 // JS message handler. |
128 void OnDialogClosed(const base::ListValue* args); | 129 void OnDialogClosed(const base::ListValue* args); |
129 | 130 |
130 DISALLOW_COPY_AND_ASSIGN(HtmlDialogUI); | 131 DISALLOW_COPY_AND_ASSIGN(HtmlDialogUI); |
131 }; | 132 }; |
132 | 133 |
133 // Displays external URL contents inside a modal HTML dialog. | 134 // Displays external URL contents inside a modal HTML dialog. |
134 // | 135 // |
135 // Intended to be the place to collect the settings and lockdowns | 136 // Intended to be the place to collect the settings and lockdowns |
136 // necessary for running external UI components securely (e.g., the | 137 // necessary for running external UI components securely (e.g., the |
137 // cloud print dialog). | 138 // cloud print dialog). |
138 class ExternalHtmlDialogUI : public HtmlDialogUI { | 139 class ExternalHtmlDialogUI : public HtmlDialogUI { |
139 public: | 140 public: |
140 explicit ExternalHtmlDialogUI(content::WebContents* web_contents); | 141 explicit ExternalHtmlDialogUI(WebUI* web_ui); |
141 virtual ~ExternalHtmlDialogUI(); | 142 virtual ~ExternalHtmlDialogUI(); |
142 }; | 143 }; |
143 | 144 |
144 #endif // CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ | 145 #endif // CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ |
OLD | NEW |