blob: e6e29f4dbd27b5c3b63510bae0acb551b4ef122a [file] [log] [blame]
[email protected]707d6be62012-01-12 03:56:151// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]4acc19a62009-04-03 03:05:112// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]20c07f8e2012-05-31 08:43:145#ifndef UI_WEB_DIALOGS_WEB_DIALOG_UI_H_
6#define UI_WEB_DIALOGS_WEB_DIALOG_UI_H_
[email protected]4acc19a62009-04-03 03:05:117
[email protected]038d52e12009-10-14 16:53:418#include <string>
[email protected]2bc2de62009-06-29 23:37:429#include <vector>
10
[email protected]c63cedf22012-01-17 18:42:2211#include "base/compiler_specific.h"
[email protected]bdae5c12011-08-05 21:49:0612#include "base/string16.h"
[email protected]6936ace2012-01-31 02:48:1213#include "content/public/browser/web_contents_delegate.h"
[email protected]e14c959122012-01-13 16:58:2514#include "content/public/browser/web_ui_controller.h"
[email protected]4acc19a62009-04-03 03:05:1115#include "googleurl/src/gurl.h"
[email protected]707d6be62012-01-12 03:56:1516#include "ui/base/ui_base_types.h"
[email protected]20c07f8e2012-05-31 08:43:1417#include "ui/web_dialogs/web_dialogs_export.h"
[email protected]4acc19a62009-04-03 03:05:1118
[email protected]a81343d232011-12-27 07:39:2019namespace content {
20class WebContents;
[email protected]c63cedf22012-01-17 18:42:2221class WebUIMessageHandler;
[email protected]35be7ec2012-02-12 20:42:5122struct ContextMenuParams;
[email protected]a81343d232011-12-27 07:39:2023}
24
[email protected]45644f62011-11-23 00:58:2325namespace gfx {
26class Size;
[email protected]f3a1c642011-07-12 19:15:0327}
28
[email protected]20c07f8e2012-05-31 08:43:1429namespace ui {
30
[email protected]921495692012-05-03 03:57:4431class WebDialogDelegate;
[email protected]4acc19a62009-04-03 03:05:1132
[email protected]5835871a2012-04-25 21:56:5533// Displays file URL contents inside a modal web dialog.
[email protected]4acc19a62009-04-03 03:05:1134//
[email protected]0ec4898e2011-12-30 21:09:2435// This application really should not use WebContents + WebUI. It should instead
[email protected]4acc19a62009-04-03 03:05:1136// just embed a RenderView in a dialog and be done with it.
37//
[email protected]d21cdb12011-02-10 01:22:3238// Before loading a URL corresponding to this WebUI, the caller should set its
[email protected]36a22c42012-08-23 00:03:1139// 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]20c07f8e2012-05-31 08:43:1444class WEB_DIALOGS_EXPORT WebDialogUI : public content::WebUIController {
[email protected]4acc19a62009-04-03 03:05:1145 public:
[email protected]5835871a2012-04-25 21:56:5546 struct WebDialogParams {
[email protected]4acc19a62009-04-03 03:05:1147 // 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]36a22c42012-08-23 00:03:1157 // When created, the delegate should already be set as user data on the
58 // WebContents.
[email protected]5835871a2012-04-25 21:56:5559 explicit WebDialogUI(content::WebUI* web_ui);
60 virtual ~WebDialogUI();
[email protected]4acc19a62009-04-03 03:05:1161
[email protected]8befa1a2011-09-21 02:03:3862 // Close the dialog, passing the specified arguments to the close handler.
63 void CloseDialog(const base::ListValue* args);
64
[email protected]36a22c42012-08-23 00:03:1165 // Sets the delegate on the WebContents.
66 static void SetDelegate(content::WebContents* web_contents,
67 WebDialogDelegate* delegate);
[email protected]4acc19a62009-04-03 03:05:1168
69 private:
[email protected]e14c959122012-01-13 16:58:2570 // WebUIController
[email protected]eaabba22012-03-07 15:02:1171 virtual void RenderViewCreated(
72 content::RenderViewHost* render_view_host) OVERRIDE;
[email protected]4acc19a62009-04-03 03:05:1173
[email protected]36a22c42012-08-23 00:03:1174 // Gets the delegate for the WebContent set with SetDelegate.
75 static WebDialogDelegate* GetDelegate(content::WebContents* web_contents);
76
[email protected]4acc19a62009-04-03 03:05:1177 // JS message handler.
[email protected]f3a1c642011-07-12 19:15:0378 void OnDialogClosed(const base::ListValue* args);
[email protected]4acc19a62009-04-03 03:05:1179
[email protected]5835871a2012-04-25 21:56:5580 DISALLOW_COPY_AND_ASSIGN(WebDialogUI);
[email protected]4acc19a62009-04-03 03:05:1181};
82
[email protected]5835871a2012-04-25 21:56:5583// Displays external URL contents inside a modal web dialog.
[email protected]73852b8f2010-05-14 00:38:1284//
85// Intended to be the place to collect the settings and lockdowns
[email protected]78637b22011-12-02 20:51:5286// necessary for running external UI components securely (e.g., the
[email protected]73852b8f2010-05-14 00:38:1287// cloud print dialog).
[email protected]20c07f8e2012-05-31 08:43:1488class WEB_DIALOGS_EXPORT ExternalWebDialogUI : public WebDialogUI {
[email protected]73852b8f2010-05-14 00:38:1289 public:
[email protected]5835871a2012-04-25 21:56:5590 explicit ExternalWebDialogUI(content::WebUI* web_ui);
91 virtual ~ExternalWebDialogUI();
[email protected]73852b8f2010-05-14 00:38:1292};
93
[email protected]20c07f8e2012-05-31 08:43:1494} // namespace ui
95
96#endif // UI_WEB_DIALOGS_WEB_DIALOG_UI_H_