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
3 // found in the LICENSE file.
5 #ifndef UI_WEB_DIALOGS_WEB_DIALOG_UI_H_
6 #define UI_WEB_DIALOGS_WEB_DIALOG_UI_H_
11 #include "base/compiler_specific.h"
12 #include "base/strings/string16.h"
13 #include "content/public/browser/web_contents_delegate.h"
14 #include "content/public/browser/web_ui_controller.h"
15 #include "ui/base/ui_base_types.h"
16 #include "ui/web_dialogs/web_dialogs_export.h"
21 class WebUIMessageHandler
;
22 struct ContextMenuParams
;
31 class WebDialogDelegate
;
33 // Displays file URL contents inside a modal web dialog.
35 // This application really should not use WebContents + WebUI. It should instead
36 // just embed a RenderView in a dialog and be done with it.
38 // Before loading a URL corresponding to this WebUI, the caller should set its
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
44 class WEB_DIALOGS_EXPORT WebDialogUI
: public content::WebUIController
{
46 struct WebDialogParams
{
47 // The URL for the content that will be loaded in the dialog.
49 // Width of the dialog.
51 // Height of the dialog.
53 // The JSON input to pass to the dialog when showing it.
54 std::string json_input
;
57 // When created, the delegate should already be set as user data on the
59 explicit WebDialogUI(content::WebUI
* web_ui
);
60 virtual ~WebDialogUI();
62 // Close the dialog, passing the specified arguments to the close handler.
63 void CloseDialog(const base::ListValue
* args
);
65 // Sets the delegate on the WebContents.
66 static void SetDelegate(content::WebContents
* web_contents
,
67 WebDialogDelegate
* delegate
);
71 virtual void RenderViewCreated(
72 content::RenderViewHost
* render_view_host
) OVERRIDE
;
74 // Gets the delegate for the WebContent set with SetDelegate.
75 static WebDialogDelegate
* GetDelegate(content::WebContents
* web_contents
);
77 // JS message handler.
78 void OnDialogClosed(const base::ListValue
* args
);
80 DISALLOW_COPY_AND_ASSIGN(WebDialogUI
);
83 // Displays external URL contents inside a modal web dialog.
85 // Intended to be the place to collect the settings and lockdowns
86 // necessary for running external UI components securely (e.g., the
87 // cloud print dialog).
88 class WEB_DIALOGS_EXPORT ExternalWebDialogUI
: public WebDialogUI
{
90 explicit ExternalWebDialogUI(content::WebUI
* web_ui
);
91 virtual ~ExternalWebDialogUI();
96 #endif // UI_WEB_DIALOGS_WEB_DIALOG_UI_H_