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

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

Issue 10353007: Extract a minimal subset of WebDialogUI/WebDialogDelegate from src/chrome -> src/ui/web_dialogs Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 7 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
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_UI_H_
6 #define CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_UI_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "base/compiler_specific.h"
13 #include "base/string16.h"
14 #include "content/public/browser/web_contents_delegate.h"
15 #include "content/public/browser/web_ui_controller.h"
16 #include "googleurl/src/gurl.h"
17 #include "ui/base/ui_base_types.h"
18
19
20 namespace base {
21 class ListValue;
22 template<class T> class PropertyAccessor;
23 }
24
25 namespace content {
26 class WebContents;
27 class WebUIMessageHandler;
28 struct ContextMenuParams;
29 }
30
31 namespace gfx {
32 class Size;
33 }
34
35 class WebDialogDelegate;
36
37 // Displays file URL contents inside a modal web dialog.
38 //
39 // This application really should not use WebContents + WebUI. It should instead
40 // just embed a RenderView in a dialog and be done with it.
41 //
42 // Before loading a URL corresponding to this WebUI, the caller should set its
43 // delegate as a property on the WebContents. This WebUI will pick it up from
44 // there and call it back. This is a bit of a hack to allow the dialog to pass
45 // its delegate to the Web UI without having nasty accessors on the WebContents.
46 // The correct design using RVH directly would avoid all of this.
47 class WebDialogUI : public content::WebUIController {
48 public:
49 struct WebDialogParams {
50 // The URL for the content that will be loaded in the dialog.
51 GURL url;
52 // Width of the dialog.
53 int width;
54 // Height of the dialog.
55 int height;
56 // The JSON input to pass to the dialog when showing it.
57 std::string json_input;
58 };
59
60 // When created, the property should already be set on the WebContents.
61 explicit WebDialogUI(content::WebUI* web_ui);
62 virtual ~WebDialogUI();
63
64 // Close the dialog, passing the specified arguments to the close handler.
65 void CloseDialog(const base::ListValue* args);
66
67 // Returns the PropertyBag accessor object used to write the delegate pointer
68 // into the WebContents (see class-level comment above).
69 static base::PropertyAccessor<WebDialogDelegate*>& GetPropertyAccessor();
70
71 private:
72 // WebUIController
73 virtual void RenderViewCreated(
74 content::RenderViewHost* render_view_host) OVERRIDE;
75
76 // JS message handler.
77 void OnDialogClosed(const base::ListValue* args);
78
79 DISALLOW_COPY_AND_ASSIGN(WebDialogUI);
80 };
81
82 // Displays external URL contents inside a modal web dialog.
83 //
84 // Intended to be the place to collect the settings and lockdowns
85 // necessary for running external UI components securely (e.g., the
86 // cloud print dialog).
87 class ExternalWebDialogUI : public WebDialogUI {
88 public:
89 explicit ExternalWebDialogUI(content::WebUI* web_ui);
90 virtual ~ExternalWebDialogUI();
91 };
92
93 #endif // CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_UI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698