[email protected] | 707d6be6 | 2012-01-12 03:56:15 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | 20c07f8e | 2012-05-31 08:43:14 | [diff] [blame] | 5 | #ifndef UI_WEB_DIALOGS_WEB_DIALOG_UI_H_ |
6 | #define UI_WEB_DIALOGS_WEB_DIALOG_UI_H_ | ||||
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 7 | |
[email protected] | 038d52e1 | 2009-10-14 16:53:41 | [diff] [blame] | 8 | #include <string> |
[email protected] | 2bc2de6 | 2009-06-29 23:37:42 | [diff] [blame] | 9 | #include <vector> |
10 | |||||
[email protected] | c63cedf2 | 2012-01-17 18:42:22 | [diff] [blame] | 11 | #include "base/compiler_specific.h" |
[email protected] | bdae5c1 | 2011-08-05 21:49:06 | [diff] [blame] | 12 | #include "base/string16.h" |
[email protected] | 6936ace | 2012-01-31 02:48:12 | [diff] [blame] | 13 | #include "content/public/browser/web_contents_delegate.h" |
[email protected] | e14c95912 | 2012-01-13 16:58:25 | [diff] [blame] | 14 | #include "content/public/browser/web_ui_controller.h" |
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 15 | #include "googleurl/src/gurl.h" |
[email protected] | 707d6be6 | 2012-01-12 03:56:15 | [diff] [blame] | 16 | #include "ui/base/ui_base_types.h" |
[email protected] | 20c07f8e | 2012-05-31 08:43:14 | [diff] [blame] | 17 | #include "ui/web_dialogs/web_dialogs_export.h" |
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 18 | |
[email protected] | a81343d23 | 2011-12-27 07:39:20 | [diff] [blame] | 19 | namespace content { |
20 | class WebContents; | ||||
[email protected] | c63cedf2 | 2012-01-17 18:42:22 | [diff] [blame] | 21 | class WebUIMessageHandler; |
[email protected] | 35be7ec | 2012-02-12 20:42:51 | [diff] [blame] | 22 | struct ContextMenuParams; |
[email protected] | a81343d23 | 2011-12-27 07:39:20 | [diff] [blame] | 23 | } |
24 | |||||
[email protected] | 45644f6 | 2011-11-23 00:58:23 | [diff] [blame] | 25 | namespace gfx { |
26 | class Size; | ||||
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 27 | } |
28 | |||||
[email protected] | 20c07f8e | 2012-05-31 08:43:14 | [diff] [blame] | 29 | namespace ui { |
30 | |||||
[email protected] | 92149569 | 2012-05-03 03:57:44 | [diff] [blame] | 31 | class WebDialogDelegate; |
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 32 | |
[email protected] | 5835871a | 2012-04-25 21:56:55 | [diff] [blame] | 33 | // Displays file URL contents inside a modal web dialog. |
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 34 | // |
[email protected] | 0ec4898e | 2011-12-30 21:09:24 | [diff] [blame] | 35 | // This application really should not use WebContents + WebUI. It should instead |
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 36 | // just embed a RenderView in a dialog and be done with it. |
37 | // | ||||
[email protected] | d21cdb1 | 2011-02-10 01:22:32 | [diff] [blame] | 38 | // Before loading a URL corresponding to this WebUI, the caller should set its |
[email protected] | 36a22c4 | 2012-08-23 00:03:11 | [diff] [blame^] | 39 | // delegate as user data on the WebContents by calling SetDelegate(). This WebUI |
40 | // will pick it up from there and call it back. This is a bit of a hack to allow | ||||
41 | // the dialog to pass its delegate to the Web UI without having nasty accessors | ||||
42 | // on the WebContents. The correct design using RVH directly would avoid all of | ||||
43 | // this. | ||||
[email protected] | 20c07f8e | 2012-05-31 08:43:14 | [diff] [blame] | 44 | class WEB_DIALOGS_EXPORT WebDialogUI : public content::WebUIController { |
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 45 | public: |
[email protected] | 5835871a | 2012-04-25 21:56:55 | [diff] [blame] | 46 | struct WebDialogParams { |
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 47 | // The URL for the content that will be loaded in the dialog. |
48 | GURL url; | ||||
49 | // Width of the dialog. | ||||
50 | int width; | ||||
51 | // Height of the dialog. | ||||
52 | int height; | ||||
53 | // The JSON input to pass to the dialog when showing it. | ||||
54 | std::string json_input; | ||||
55 | }; | ||||
56 | |||||
[email protected] | 36a22c4 | 2012-08-23 00:03:11 | [diff] [blame^] | 57 | // When created, the delegate should already be set as user data on the |
58 | // WebContents. | ||||
[email protected] | 5835871a | 2012-04-25 21:56:55 | [diff] [blame] | 59 | explicit WebDialogUI(content::WebUI* web_ui); |
60 | virtual ~WebDialogUI(); | ||||
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 61 | |
[email protected] | 8befa1a | 2011-09-21 02:03:38 | [diff] [blame] | 62 | // Close the dialog, passing the specified arguments to the close handler. |
63 | void CloseDialog(const base::ListValue* args); | ||||
64 | |||||
[email protected] | 36a22c4 | 2012-08-23 00:03:11 | [diff] [blame^] | 65 | // Sets the delegate on the WebContents. |
66 | static void SetDelegate(content::WebContents* web_contents, | ||||
67 | WebDialogDelegate* delegate); | ||||
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 68 | |
69 | private: | ||||
[email protected] | e14c95912 | 2012-01-13 16:58:25 | [diff] [blame] | 70 | // WebUIController |
[email protected] | eaabba2 | 2012-03-07 15:02:11 | [diff] [blame] | 71 | virtual void RenderViewCreated( |
72 | content::RenderViewHost* render_view_host) OVERRIDE; | ||||
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 73 | |
[email protected] | 36a22c4 | 2012-08-23 00:03:11 | [diff] [blame^] | 74 | // Gets the delegate for the WebContent set with SetDelegate. |
75 | static WebDialogDelegate* GetDelegate(content::WebContents* web_contents); | ||||
76 | |||||
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 77 | // JS message handler. |
[email protected] | f3a1c64 | 2011-07-12 19:15:03 | [diff] [blame] | 78 | void OnDialogClosed(const base::ListValue* args); |
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 79 | |
[email protected] | 5835871a | 2012-04-25 21:56:55 | [diff] [blame] | 80 | DISALLOW_COPY_AND_ASSIGN(WebDialogUI); |
[email protected] | 4acc19a6 | 2009-04-03 03:05:11 | [diff] [blame] | 81 | }; |
82 | |||||
[email protected] | 5835871a | 2012-04-25 21:56:55 | [diff] [blame] | 83 | // Displays external URL contents inside a modal web dialog. |
[email protected] | 73852b8f | 2010-05-14 00:38:12 | [diff] [blame] | 84 | // |
85 | // Intended to be the place to collect the settings and lockdowns | ||||
[email protected] | 78637b2 | 2011-12-02 20:51:52 | [diff] [blame] | 86 | // necessary for running external UI components securely (e.g., the |
[email protected] | 73852b8f | 2010-05-14 00:38:12 | [diff] [blame] | 87 | // cloud print dialog). |
[email protected] | 20c07f8e | 2012-05-31 08:43:14 | [diff] [blame] | 88 | class WEB_DIALOGS_EXPORT ExternalWebDialogUI : public WebDialogUI { |
[email protected] | 73852b8f | 2010-05-14 00:38:12 | [diff] [blame] | 89 | public: |
[email protected] | 5835871a | 2012-04-25 21:56:55 | [diff] [blame] | 90 | explicit ExternalWebDialogUI(content::WebUI* web_ui); |
91 | virtual ~ExternalWebDialogUI(); | ||||
[email protected] | 73852b8f | 2010-05-14 00:38:12 | [diff] [blame] | 92 | }; |
93 | |||||
[email protected] | 20c07f8e | 2012-05-31 08:43:14 | [diff] [blame] | 94 | } // namespace ui |
95 | |||||
96 | #endif // UI_WEB_DIALOGS_WEB_DIALOG_UI_H_ |