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

Side by Side Diff: content/public/browser/browser_plugin_guest_delegate.h

Issue 295083002: BrowserPluginGuest is no longer a WebContentsDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@make_context_menu_easier_to_refactor
Patch Set: Fixed focus after crash Created 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_
6 #define CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_ 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/process/kill.h" 9 #include "base/process/kill.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
lazyboy 2014/05/23 16:06:09 A lot of includes can be removed now.
Fady Samuel 2014/05/23 16:34:08 Done.
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "content/public/common/media_stream_request.h" 13 #include "content/public/common/media_stream_request.h"
lazyboy 2014/05/23 16:06:09 This one, etc.
Fady Samuel 2014/05/23 16:34:08 Done.
14 #include "third_party/skia/include/core/SkColor.h" 14 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/base/window_open_disposition.h" 15 #include "ui/base/window_open_disposition.h"
16 #include "ui/gfx/geometry/rect.h" 16 #include "ui/gfx/geometry/rect.h"
17 #include "ui/gfx/size.h" 17 #include "ui/gfx/size.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 namespace blink { 20 namespace blink {
21 class WebGestureEvent; 21 class WebGestureEvent;
22 } // namespace blink 22 } // namespace blink
23 23
24 namespace content { 24 namespace content {
25 25
26 class ColorChooser; 26 class ColorChooser;
27 class JavaScriptDialogManager; 27 class JavaScriptDialogManager;
lazyboy 2014/05/23 16:06:09 Remove this and other unused fwd decl.
Fady Samuel 2014/05/23 16:34:08 Done.
28 class RenderViewHost;
28 class WebContents; 29 class WebContents;
29 struct ColorSuggestion; 30 struct ColorSuggestion;
30 struct ContextMenuParams; 31 struct ContextMenuParams;
31 struct FileChooserParams; 32 struct FileChooserParams;
32 struct NativeWebKeyboardEvent; 33 struct NativeWebKeyboardEvent;
33 struct OpenURLParams; 34 struct OpenURLParams;
34 35
35 // Objects implement this interface to get notified about changes in the guest 36 // Objects implement this interface to get notified about changes in the guest
36 // WebContents and to provide necessary functionality. 37 // WebContents and to provide necessary functionality.
37 class CONTENT_EXPORT BrowserPluginGuestDelegate { 38 class CONTENT_EXPORT BrowserPluginGuestDelegate {
38 public: 39 public:
39 virtual ~BrowserPluginGuestDelegate() {} 40 virtual ~BrowserPluginGuestDelegate() {}
40 41
41 // Add a message to the console.
42 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
43 // WebContentsDelegate.
44 virtual void AddMessageToConsole(int32 level,
45 const base::string16& message,
46 int32 line_no,
47 const base::string16& source_id) {}
48
49 // Request the delegate to close this guest, and do whatever cleanup it needs
50 // to do.
51 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
52 // WebContentsDelegate.
53 virtual void Close() {}
54
55 // Notification that the embedder has completed attachment. 42 // Notification that the embedder has completed attachment.
56 virtual void DidAttach() {} 43 virtual void DidAttach() {}
57 44
58 // Informs the delegate that the guest render process is gone. |status| 45 // Informs the delegate that the guest render process is gone. |status|
59 // indicates whether the guest was killed, crashed, or was terminated 46 // indicates whether the guest was killed, crashed, or was terminated
60 // gracefully. 47 // gracefully.
61 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a 48 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
62 // WebContentsDelegate. 49 // WebContentsDelegate.
63 virtual void GuestProcessGone(base::TerminationStatus status) {} 50 virtual void GuestProcessGone(base::TerminationStatus status) {}
64 51
65 // Informs the delegate that the embedder has been destroyed. 52 // Informs the delegate that the embedder has been destroyed.
66 virtual void EmbedderDestroyed() {} 53 virtual void EmbedderDestroyed() {}
67 54
68 // Informs the delegate of a reply to the find request specified by
69 // |request_id|.
70 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
71 // WebContentsDelegate.
72 virtual void FindReply(int request_id,
73 int number_of_matches,
74 const gfx::Rect& selection_rect,
75 int active_match_ordinal,
76 bool final_update) {}
77
78 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
79 // WebContentsDelegate.
80 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {}
81
82 // Requests setting the zoom level to the provided |zoom_level|. 55 // Requests setting the zoom level to the provided |zoom_level|.
83 virtual void SetZoom(double zoom_factor) {} 56 virtual void SetZoom(double zoom_factor) {}
84 57
85 virtual bool IsDragAndDropEnabled(); 58 virtual bool IsDragAndDropEnabled();
86 59
87 // Notification that the page has made some progress loading. |progress| is a
88 // value between 0.0 (nothing loaded) and 1.0 (page loaded completely).
89 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
90 // WebContentsDelegate.
91 virtual void LoadProgressed(double progress) {}
92
93 // Notification that the guest is no longer hung.
94 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
95 // WebContentsDelegate.
96 virtual void RendererResponsive() {}
97
98 // Notification that the guest is hung.
99 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
100 // WebContentsDelegate.
101 virtual void RendererUnresponsive() {}
102
103 // Notifies that the content size of the guest has changed in autosize mode. 60 // Notifies that the content size of the guest has changed in autosize mode.
104 virtual void SizeChanged(const gfx::Size& old_size, 61 virtual void SizeChanged(const gfx::Size& old_size,
105 const gfx::Size& new_size) {} 62 const gfx::Size& new_size) {}
106 63
107 // Asks permission to use the camera and/or microphone. If permission is
108 // granted, a call should be made to |callback| with the devices. If the
109 // request is denied, a call should be made to |callback| with an empty list
110 // of devices. |request| has the details of the request (e.g. which of audio
111 // and/or video devices are requested, and lists of available devices).
112 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
113 // WebContentsDelegate.
114 virtual void RequestMediaAccessPermission(
115 const MediaStreamRequest& request,
116 const MediaResponseCallback& callback);
117
118 // Asks the delegate if the given guest can download.
119 // Invoking the |callback| synchronously is OK.
120 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
121 // WebContentsDelegate.
122 virtual void CanDownload(const std::string& request_method,
123 const GURL& url,
124 const base::Callback<void(bool)>& callback);
125
126 // Asks the delegate if the given guest can lock the pointer. 64 // Asks the delegate if the given guest can lock the pointer.
127 // Invoking the |callback| synchronously is OK. 65 // Invoking the |callback| synchronously is OK.
128 virtual void RequestPointerLockPermission( 66 virtual void RequestPointerLockPermission(
129 bool user_gesture, 67 bool user_gesture,
130 bool last_unlocked_by_target, 68 bool last_unlocked_by_target,
131 const base::Callback<void(bool)>& callback) {} 69 const base::Callback<void(bool)>& callback) {}
132 70
133 // Returns a pointer to a service to manage JavaScript dialogs. May return
134 // NULL in which case dialogs aren't shown.
135 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
136 // WebContentsDelegate.
137 virtual JavaScriptDialogManager* GetJavaScriptDialogManager();
138
139 // Called when color chooser should open. Returns the opened color chooser.
140 // Returns NULL if we failed to open the color chooser (e.g. when there is a
141 // ColorChooserDialog already open on Windows). Ownership of the returned
142 // pointer is transferred to the caller.
143 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
144 // WebContentsDelegate.
145 virtual ColorChooser* OpenColorChooser(
146 WebContents* web_contents,
147 SkColor color,
148 const std::vector<ColorSuggestion>& suggestions);
149
150 // Called when a file selection is to be done.
151 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
152 // WebContentsDelegate.
153 virtual void RunFileChooser(WebContents* web_contents,
154 const FileChooserParams& params) {}
155
156 // Returns true if the context menu operation was handled by the delegate.
157 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
158 // WebContentsDelegate.
159 virtual bool HandleContextMenu(const ContextMenuParams& params);
160
161 // Request navigating the guest to the provided |src| URL. 71 // Request navigating the guest to the provided |src| URL.
162 virtual void NavigateGuest(const std::string& src) {} 72 virtual void NavigateGuest(const std::string& src) {}
163 73
164 // Requests that the delegate destroy itself along with its associated 74 // Requests that the delegate destroy itself along with its associated
165 // WebContents. 75 // WebContents.
166 virtual void Destroy() {} 76 virtual void Destroy() {}
167 77
168 // Creates a new tab with the already-created WebContents |new_contents|.
169 // The window for the added contents should be reparented correctly when this
170 // method returns. If |disposition| is NEW_POPUP, |initial_pos| should hold
171 // the initial position. If |was_blocked| is non-NULL, then |*was_blocked|
172 // will be set to true if the popup gets blocked, and left unchanged
173 // otherwise.
174 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
175 // WebContentsDelegate.
176 virtual void AddNewContents(WebContents* source,
177 WebContents* new_contents,
178 WindowOpenDisposition disposition,
179 const gfx::Rect& initial_pos,
180 bool user_gesture,
181 bool* was_blocked) {}
182
183 // Opens a new URL inside the passed in WebContents (if source is 0 open
184 // in the current front-most tab), unless |disposition| indicates the url
185 // should be opened in a new tab or window.
186 //
187 // A NULL source indicates the current tab (callers should probably use
188 // OpenURL() for these cases which does it for you).
189 //
190 // Returns the WebContents the URL is opened in, or NULL if the URL wasn't
191 // opened immediately.
192 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
193 // WebContentsDelegate.
194 virtual WebContents* OpenURLFromTab(WebContents* source,
195 const OpenURLParams& params);
196
197 // Notifies the delegate about the creation of a new WebContents. This
198 // typically happens when popups are created.
199 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
200 // WebContentsDelegate.
201 virtual void WebContentsCreated(WebContents* source_contents,
202 int opener_render_frame_id,
203 const base::string16& frame_name,
204 const GURL& target_url,
205 WebContents* new_contents) {}
206
207 // Registers a |callback| with the delegate that the delegate would call when 78 // Registers a |callback| with the delegate that the delegate would call when
208 // it is about to be destroyed. 79 // it is about to be destroyed.
209 typedef base::Callback<void(WebContents*)> DestructionCallback; 80 typedef base::Callback<void(WebContents*)> DestructionCallback;
210 virtual void RegisterDestructionCallback( 81 virtual void RegisterDestructionCallback(
211 const DestructionCallback& callback) {} 82 const DestructionCallback& callback) {}
212
213 // Allows delegates to handle gesture events before sending to the renderer.
214 // Returns true if the |event| was handled and thus shouldn't be processed
215 // by the renderer's event handler. Note that the touch events that create
216 // the gesture are always passed to the renderer since the gesture is created
217 // and dispatched after the touches return without being "preventDefault()"ed.
218 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
219 // WebContentsDelegate.
220 virtual bool PreHandleGestureEvent(WebContents* source,
221 const blink::WebGestureEvent& event);
222 }; 83 };
223 84
224 } // namespace content 85 } // namespace content
225 86
226 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_ 87 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698