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

Side by Side Diff: chrome/browser/ui/webui/web_dialog_delegate.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_DELEGATE_H_
6 #define CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_DELEGATE_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "base/string16.h"
13 #include "ui/base/ui_base_types.h"
14 #include "webkit/glue/window_open_disposition.h"
15
16 class GURL;
17
18 namespace content {
19 class WebUIMessageHandler;
20 class WebContents;
21 struct ContextMenuParams;
22 struct OpenURLParams;
23 }
24
25 namespace gfx {
26 class Rect;
27 class Size;
28 }
29
30 // Implement this class to receive notifications.
31 class WebDialogDelegate {
32 public:
33 // Returns true if the contents needs to be run in a modal dialog.
34 virtual ui::ModalType GetDialogModalType() const = 0;
35
36 // Returns the title of the dialog.
37 virtual string16 GetDialogTitle() const = 0;
38
39 // Returns the dialog's name identifier. Used to identify this dialog for
40 // state restoration.
41 virtual std::string GetDialogName() const;
42
43 // Get the HTML file path for the content to load in the dialog.
44 virtual GURL GetDialogContentURL() const = 0;
45
46 // Get WebUIMessageHandler objects to handle messages from the HTML/JS page.
47 // The handlers are used to send and receive messages from the page while it
48 // is still open. Ownership of each handler is taken over by the WebUI
49 // hosting the page.
50 virtual void GetWebUIMessageHandlers(
51 std::vector<content::WebUIMessageHandler*>* handlers) const = 0;
52
53 // Get the size of the dialog.
54 virtual void GetDialogSize(gfx::Size* size) const = 0;
55
56 // Get the size of the dialog.
57 virtual void GetMinimumDialogSize(gfx::Size* size) const;
58
59 // Gets the JSON string input to use when showing the dialog.
60 virtual std::string GetDialogArgs() const = 0;
61
62 // A callback to notify the delegate that |source|'s loading state has
63 // changed.
64 virtual void OnLoadingStateChanged(content::WebContents* source) {}
65
66 // A callback to notify the delegate that the dialog closed.
67 // IMPORTANT: Implementations should delete |this| here (unless they've
68 // arranged for the delegate to be deleted in some other way, e.g. by
69 // registering it as a message handler in the WebUI object).
70 virtual void OnDialogClosed(const std::string& json_retval) = 0;
71
72 // A callback to notify the delegate that the contents have gone
73 // away. Only relevant if your dialog hosts code that calls
74 // windows.close() and you've allowed that. If the output parameter
75 // is set to true, then the dialog is closed. The default is false.
76 virtual void OnCloseContents(content::WebContents* source,
77 bool* out_close_dialog) = 0;
78
79 // A callback to allow the delegate to dictate that the window should not
80 // have a title bar. This is useful when presenting branded interfaces.
81 virtual bool ShouldShowDialogTitle() const = 0;
82
83 // A callback to allow the delegate to inhibit context menu or show
84 // customized menu.
85 // Returns true iff you do NOT want the standard context menu to be
86 // shown (because you want to handle it yourself).
87 virtual bool HandleContextMenu(const content::ContextMenuParams& params);
88
89 // A callback to allow the delegate to open a new URL inside |source|.
90 // On return |out_new_contents| should contain the WebContents the URL
91 // is opened in. Return false to use the default handler.
92 virtual bool HandleOpenURLFromTab(content::WebContents* source,
93 const content::OpenURLParams& params,
94 content::WebContents** out_new_contents);
95
96 // A callback to create a new tab with |new_contents|. |source| is the
97 // WebContent where the operation originated. |disposition| controls how the
98 // new tab should be opened. |initial_pos| is the position of the window if a
99 // new window is created. |user_gesture| is true if the operation was started
100 // by a user gesture. Return false to use the default handler.
101 virtual bool HandleAddNewContents(content::WebContents* source,
102 content::WebContents* new_contents,
103 WindowOpenDisposition disposition,
104 const gfx::Rect& initial_pos,
105 bool user_gesture);
106
107 // Stores the dialog bounds.
108 virtual void StoreDialogSize(const gfx::Size& dialog_size) {}
109
110 protected:
111 virtual ~WebDialogDelegate() {}
112 };
113
114
115 #endif // CHROME_BROWSER_UI_WEBUI_WEB_DIALOG_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698