Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: chrome/browser/ui/webui/web_dialog_ui.h

Issue 10214001: WebDialogs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_WEB_DIALOG_UI_H_
6 #define CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ 6 #define CHROME_BROWSER_UI_WEBUI_WEB_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/compiler_specific.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 #include "content/public/browser/web_contents_delegate.h" 14 #include "content/public/browser/web_contents_delegate.h"
15 #include "content/public/browser/web_ui_controller.h" 15 #include "content/public/browser/web_ui_controller.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 #include "ui/base/ui_base_types.h" 17 #include "ui/base/ui_base_types.h"
18 18
19 19
20 namespace base { 20 namespace base {
21 class ListValue; 21 class ListValue;
22 template<class T> class PropertyAccessor; 22 template<class T> class PropertyAccessor;
23 } 23 }
24 24
25 namespace content { 25 namespace content {
26 class WebContents; 26 class WebContents;
27 class WebUIMessageHandler; 27 class WebUIMessageHandler;
28 struct ContextMenuParams; 28 struct ContextMenuParams;
29 } 29 }
30 30
31 namespace gfx { 31 namespace gfx {
32 class Size; 32 class Size;
33 } 33 }
34 34
35 // Implement this class to receive notifications. 35 // Implement this class to receive notifications.
36 class HtmlDialogUIDelegate { 36 class WebDialogDelegate {
37 public: 37 public:
38 // 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.
39 virtual ui::ModalType GetDialogModalType() const = 0; 39 virtual ui::ModalType GetDialogModalType() const = 0;
40 40
41 // Returns the title of the dialog. 41 // Returns the title of the dialog.
42 virtual string16 GetDialogTitle() const = 0; 42 virtual string16 GetDialogTitle() const = 0;
43 43
44 // Returns the dialog's name identifier. Used to identify this dialog for 44 // Returns the dialog's name identifier. Used to identify this dialog for
45 // state restoration. 45 // state restoration.
46 virtual std::string GetDialogName() const; 46 virtual std::string GetDialogName() const;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 virtual bool HandleAddNewContents(content::WebContents* source, 106 virtual bool HandleAddNewContents(content::WebContents* source,
107 content::WebContents* new_contents, 107 content::WebContents* new_contents,
108 WindowOpenDisposition disposition, 108 WindowOpenDisposition disposition,
109 const gfx::Rect& initial_pos, 109 const gfx::Rect& initial_pos,
110 bool user_gesture); 110 bool user_gesture);
111 111
112 // Stores the dialog bounds. 112 // Stores the dialog bounds.
113 virtual void StoreDialogSize(const gfx::Size& dialog_size) {} 113 virtual void StoreDialogSize(const gfx::Size& dialog_size) {}
114 114
115 protected: 115 protected:
116 virtual ~HtmlDialogUIDelegate() {} 116 virtual ~WebDialogDelegate() {}
117 }; 117 };
118 118
119 // Displays file URL contents inside a modal HTML dialog. 119 // Displays file URL contents inside a modal web dialog.
120 // 120 //
121 // This application really should not use WebContents + WebUI. It should instead 121 // This application really should not use WebContents + WebUI. It should instead
122 // just embed a RenderView in a dialog and be done with it. 122 // just embed a RenderView in a dialog and be done with it.
123 // 123 //
124 // Before loading a URL corresponding to this WebUI, the caller should set its 124 // Before loading a URL corresponding to this WebUI, the caller should set its
125 // delegate as a property on the WebContents. This WebUI will pick it up from 125 // delegate as a property on the WebContents. This WebUI will pick it up from
126 // there and call it back. This is a bit of a hack to allow the dialog to pass 126 // there and call it back. This is a bit of a hack to allow the dialog to pass
127 // its delegate to the Web UI without having nasty accessors on the WebContents. 127 // its delegate to the Web UI without having nasty accessors on the WebContents.
128 // The correct design using RVH directly would avoid all of this. 128 // The correct design using RVH directly would avoid all of this.
129 class HtmlDialogUI : public content::WebUIController { 129 class WebDialogUI : public content::WebUIController {
130 public: 130 public:
131 struct HtmlDialogParams { 131 struct WebDialogParams {
132 // The URL for the content that will be loaded in the dialog. 132 // The URL for the content that will be loaded in the dialog.
133 GURL url; 133 GURL url;
134 // Width of the dialog. 134 // Width of the dialog.
135 int width; 135 int width;
136 // Height of the dialog. 136 // Height of the dialog.
137 int height; 137 int height;
138 // The JSON input to pass to the dialog when showing it. 138 // The JSON input to pass to the dialog when showing it.
139 std::string json_input; 139 std::string json_input;
140 }; 140 };
141 141
142 // When created, the property should already be set on the WebContents. 142 // When created, the property should already be set on the WebContents.
143 explicit HtmlDialogUI(content::WebUI* web_ui); 143 explicit WebDialogUI(content::WebUI* web_ui);
144 virtual ~HtmlDialogUI(); 144 virtual ~WebDialogUI();
145 145
146 // Close the dialog, passing the specified arguments to the close handler. 146 // Close the dialog, passing the specified arguments to the close handler.
147 void CloseDialog(const base::ListValue* args); 147 void CloseDialog(const base::ListValue* args);
148 148
149 // Returns the PropertyBag accessor object used to write the delegate pointer 149 // Returns the PropertyBag accessor object used to write the delegate pointer
150 // into the WebContents (see class-level comment above). 150 // into the WebContents (see class-level comment above).
151 static base::PropertyAccessor<HtmlDialogUIDelegate*>& GetPropertyAccessor(); 151 static base::PropertyAccessor<WebDialogDelegate*>& GetPropertyAccessor();
152 152
153 private: 153 private:
154 // WebUIController 154 // WebUIController
155 virtual void RenderViewCreated( 155 virtual void RenderViewCreated(
156 content::RenderViewHost* render_view_host) OVERRIDE; 156 content::RenderViewHost* render_view_host) OVERRIDE;
157 157
158 // JS message handler. 158 // JS message handler.
159 void OnDialogClosed(const base::ListValue* args); 159 void OnDialogClosed(const base::ListValue* args);
160 160
161 DISALLOW_COPY_AND_ASSIGN(HtmlDialogUI); 161 DISALLOW_COPY_AND_ASSIGN(WebDialogUI);
162 }; 162 };
163 163
164 // Displays external URL contents inside a modal HTML dialog. 164 // Displays external URL contents inside a modal web dialog.
165 // 165 //
166 // Intended to be the place to collect the settings and lockdowns 166 // Intended to be the place to collect the settings and lockdowns
167 // necessary for running external UI components securely (e.g., the 167 // necessary for running external UI components securely (e.g., the
168 // cloud print dialog). 168 // cloud print dialog).
169 class ExternalHtmlDialogUI : public HtmlDialogUI { 169 class ExternalWebDialogUI : public WebDialogUI {
170 public: 170 public:
171 explicit ExternalHtmlDialogUI(content::WebUI* web_ui); 171 explicit ExternalWebDialogUI(content::WebUI* web_ui);
172 virtual ~ExternalHtmlDialogUI(); 172 virtual ~ExternalWebDialogUI();
173 }; 173 };
174 174
175 #endif // CHROME_BROWSER_UI_WEBUI_HTML_DIALOG_UI_H_ 175 #endif // CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_UI_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/web_dialog_controller_browsertest.cc ('k') | chrome/browser/ui/webui/web_dialog_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698