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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.h

Issue 19679002: <webview>: Implement dialog API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test Created 7 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 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 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 // A BrowserPluginGuest is the browser side of a browser <--> embedder 5 // A BrowserPluginGuest is the browser side of a browser <--> embedder
6 // renderer channel. A BrowserPlugin (a WebPlugin) is on the embedder 6 // renderer channel. A BrowserPlugin (a WebPlugin) is on the embedder
7 // renderer side of browser <--> embedder renderer communication. 7 // renderer side of browser <--> embedder renderer communication.
8 // 8 //
9 // BrowserPluginGuest lives on the UI thread of the browser process. It has a 9 // BrowserPluginGuest lives on the UI thread of the browser process. It has a
10 // helper, BrowserPluginGuestHelper, which is a RenderViewHostObserver. The 10 // helper, BrowserPluginGuestHelper, which is a RenderViewHostObserver. The
(...skipping 15 matching lines...) Expand all
26 26
27 #include "base/compiler_specific.h" 27 #include "base/compiler_specific.h"
28 #include "base/id_map.h" 28 #include "base/id_map.h"
29 #include "base/memory/shared_memory.h" 29 #include "base/memory/shared_memory.h"
30 #include "base/memory/weak_ptr.h" 30 #include "base/memory/weak_ptr.h"
31 #include "base/values.h" 31 #include "base/values.h"
32 #include "content/common/browser_plugin/browser_plugin_message_enums.h" 32 #include "content/common/browser_plugin/browser_plugin_message_enums.h"
33 #include "content/common/edit_command.h" 33 #include "content/common/edit_command.h"
34 #include "content/port/common/input_event_ack_state.h" 34 #include "content/port/common/input_event_ack_state.h"
35 #include "content/public/browser/browser_plugin_guest_delegate.h" 35 #include "content/public/browser/browser_plugin_guest_delegate.h"
36 #include "content/public/browser/javascript_dialog_manager.h"
36 #include "content/public/browser/notification_observer.h" 37 #include "content/public/browser/notification_observer.h"
37 #include "content/public/browser/notification_registrar.h" 38 #include "content/public/browser/notification_registrar.h"
38 #include "content/public/browser/render_view_host_observer.h" 39 #include "content/public/browser/render_view_host_observer.h"
39 #include "content/public/browser/web_contents_delegate.h" 40 #include "content/public/browser/web_contents_delegate.h"
40 #include "content/public/browser/web_contents_observer.h" 41 #include "content/public/browser/web_contents_observer.h"
41 #include "third_party/WebKit/public/web/WebDragOperation.h" 42 #include "third_party/WebKit/public/web/WebDragOperation.h"
42 #include "third_party/WebKit/public/web/WebDragStatus.h" 43 #include "third_party/WebKit/public/web/WebDragStatus.h"
43 #include "third_party/WebKit/public/web/WebInputEvent.h" 44 #include "third_party/WebKit/public/web/WebInputEvent.h"
44 #include "ui/gfx/rect.h" 45 #include "ui/gfx/rect.h"
45 #include "ui/surface/transport_dib.h" 46 #include "ui/surface/transport_dib.h"
(...skipping 30 matching lines...) Expand all
76 // the guest role and implements guest-specific overrides for ViewHostMsg_* 77 // the guest role and implements guest-specific overrides for ViewHostMsg_*
77 // messages. 78 // messages.
78 // 79 //
79 // When a guest is initially created, it is in an unattached state. That is, 80 // When a guest is initially created, it is in an unattached state. That is,
80 // it is not visible anywhere and has no embedder WebContents assigned. 81 // it is not visible anywhere and has no embedder WebContents assigned.
81 // A BrowserPluginGuest is said to be "attached" if it has an embedder. 82 // A BrowserPluginGuest is said to be "attached" if it has an embedder.
82 // A BrowserPluginGuest can also create a new unattached guest via 83 // A BrowserPluginGuest can also create a new unattached guest via
83 // CreateNewWindow. The newly created guest will live in the same partition, 84 // CreateNewWindow. The newly created guest will live in the same partition,
84 // which means it can share storage and can script this guest. 85 // which means it can share storage and can script this guest.
85 class CONTENT_EXPORT BrowserPluginGuest 86 class CONTENT_EXPORT BrowserPluginGuest
86 : public NotificationObserver, 87 : public JavaScriptDialogManager,
88 public NotificationObserver,
87 public WebContentsDelegate, 89 public WebContentsDelegate,
88 public WebContentsObserver, 90 public WebContentsObserver,
89 public base::SupportsWeakPtr<BrowserPluginGuest> { 91 public base::SupportsWeakPtr<BrowserPluginGuest> {
90 public: 92 public:
91 typedef base::Callback<void(bool)> GeolocationCallback; 93 typedef base::Callback<void(bool)> GeolocationCallback;
92 virtual ~BrowserPluginGuest(); 94 virtual ~BrowserPluginGuest();
93 95
94 static BrowserPluginGuest* Create( 96 static BrowserPluginGuest* Create(
95 int instance_id, 97 int instance_id,
96 WebContentsImpl* web_contents, 98 WebContentsImpl* web_contents,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 const GURL& url, 156 const GURL& url,
155 PageTransition transition_type, 157 PageTransition transition_type,
156 RenderViewHost* render_view_host) OVERRIDE; 158 RenderViewHost* render_view_host) OVERRIDE;
157 virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE; 159 virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE;
158 160
159 virtual void RenderViewReady() OVERRIDE; 161 virtual void RenderViewReady() OVERRIDE;
160 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE; 162 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
161 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 163 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
162 164
163 // WebContentsDelegate implementation. 165 // WebContentsDelegate implementation.
164
165 virtual bool AddMessageToConsole(WebContents* source, 166 virtual bool AddMessageToConsole(WebContents* source,
166 int32 level, 167 int32 level,
167 const string16& message, 168 const string16& message,
168 int32 line_no, 169 int32 line_no,
169 const string16& source_id) OVERRIDE; 170 const string16& source_id) OVERRIDE;
170 // If a new window is created with target="_blank" and rel="noreferrer", then 171 // If a new window is created with target="_blank" and rel="noreferrer", then
171 // this method is called, indicating that the new WebContents is ready to be 172 // this method is called, indicating that the new WebContents is ready to be
172 // attached. 173 // attached.
173 virtual void AddNewContents(WebContents* source, 174 virtual void AddNewContents(WebContents* source,
174 WebContents* new_contents, 175 WebContents* new_contents,
175 WindowOpenDisposition disposition, 176 WindowOpenDisposition disposition,
176 const gfx::Rect& initial_pos, 177 const gfx::Rect& initial_pos,
177 bool user_gesture, 178 bool user_gesture,
178 bool* was_blocked) OVERRIDE; 179 bool* was_blocked) OVERRIDE;
179 virtual void CanDownload(RenderViewHost* render_view_host, 180 virtual void CanDownload(RenderViewHost* render_view_host,
180 int request_id, 181 int request_id,
181 const std::string& request_method, 182 const std::string& request_method,
182 const base::Callback<void(bool)>& callback) OVERRIDE; 183 const base::Callback<void(bool)>& callback) OVERRIDE;
183 virtual void CloseContents(WebContents* source) OVERRIDE; 184 virtual void CloseContents(WebContents* source) OVERRIDE;
185 virtual JavaScriptDialogManager* GetJavaScriptDialogManager() OVERRIDE;
184 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; 186 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE;
185 virtual void HandleKeyboardEvent( 187 virtual void HandleKeyboardEvent(
186 WebContents* source, 188 WebContents* source,
187 const NativeWebKeyboardEvent& event) OVERRIDE; 189 const NativeWebKeyboardEvent& event) OVERRIDE;
188 virtual WebContents* OpenURLFromTab(WebContents* source, 190 virtual WebContents* OpenURLFromTab(WebContents* source,
189 const OpenURLParams& params) OVERRIDE; 191 const OpenURLParams& params) OVERRIDE;
190 virtual void WebContentsCreated(WebContents* source_contents, 192 virtual void WebContentsCreated(WebContents* source_contents,
191 int64 source_frame_id, 193 int64 source_frame_id,
192 const string16& frame_name, 194 const string16& frame_name,
193 const GURL& target_url, 195 const GURL& target_url,
194 WebContents* new_contents) OVERRIDE; 196 WebContents* new_contents) OVERRIDE;
195 virtual void RendererUnresponsive(WebContents* source) OVERRIDE; 197 virtual void RendererUnresponsive(WebContents* source) OVERRIDE;
196 virtual void RendererResponsive(WebContents* source) OVERRIDE; 198 virtual void RendererResponsive(WebContents* source) OVERRIDE;
197 virtual void RunFileChooser(WebContents* web_contents, 199 virtual void RunFileChooser(WebContents* web_contents,
198 const FileChooserParams& params) OVERRIDE; 200 const FileChooserParams& params) OVERRIDE;
199 virtual bool ShouldFocusPageAfterCrash() OVERRIDE; 201 virtual bool ShouldFocusPageAfterCrash() OVERRIDE;
200 virtual void RequestMediaAccessPermission( 202 virtual void RequestMediaAccessPermission(
201 WebContents* web_contents, 203 WebContents* web_contents,
202 const MediaStreamRequest& request, 204 const MediaStreamRequest& request,
203 const MediaResponseCallback& callback) OVERRIDE; 205 const MediaResponseCallback& callback) OVERRIDE;
204 206
207 // JavaScriptDialogManager implementation.
208 virtual void RunJavaScriptDialog(
209 WebContents* web_contents,
210 const GURL& origin_url,
211 const std::string& accept_lang,
212 JavaScriptMessageType javascript_message_type,
213 const string16& message_text,
214 const string16& default_prompt_text,
215 const DialogClosedCallback& callback,
216 bool* did_suppress_message) OVERRIDE;
217 virtual void RunBeforeUnloadDialog(
218 WebContents* web_contents,
219 const string16& message_text,
220 bool is_reload,
221 const DialogClosedCallback& callback) OVERRIDE;
222 virtual bool HandleJavaScriptDialog(WebContents* web_contents,
223 bool accept,
224 const string16* prompt_override) OVERRIDE;
225 virtual void ResetJavaScriptState(WebContents* web_contents) OVERRIDE;
226
205 // Exposes the protected web_contents() from WebContentsObserver. 227 // Exposes the protected web_contents() from WebContentsObserver.
206 WebContentsImpl* GetWebContents(); 228 WebContentsImpl* GetWebContents();
207 229
208 // Overridden in tests. 230 // Overridden in tests.
209 virtual void SetDamageBuffer( 231 virtual void SetDamageBuffer(
210 const BrowserPluginHostMsg_ResizeGuest_Params& params); 232 const BrowserPluginHostMsg_ResizeGuest_Params& params);
211 233
212 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; 234 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const;
213 235
214 // Helper to send messages to embedder. This methods fills the message with 236 // Helper to send messages to embedder. This methods fills the message with
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 279
258 // |this| takes ownership of |delegate|. 280 // |this| takes ownership of |delegate|.
259 void SetDelegate(BrowserPluginGuestDelegate* delegate); 281 void SetDelegate(BrowserPluginGuestDelegate* delegate);
260 282
261 private: 283 private:
262 class EmbedderRenderViewHostObserver; 284 class EmbedderRenderViewHostObserver;
263 friend class TestBrowserPluginGuest; 285 friend class TestBrowserPluginGuest;
264 286
265 class DownloadRequest; 287 class DownloadRequest;
266 class GeolocationRequest; 288 class GeolocationRequest;
289 class JavaScriptDialogRequest;
267 // MediaRequest because of naming conflicts with MediaStreamRequest. 290 // MediaRequest because of naming conflicts with MediaStreamRequest.
268 class MediaRequest; 291 class MediaRequest;
269 class NewWindowRequest; 292 class NewWindowRequest;
270 class PermissionRequest; 293 class PermissionRequest;
271 class PointerLockRequest; 294 class PointerLockRequest;
272 295
273 BrowserPluginGuest(int instance_id, 296 BrowserPluginGuest(int instance_id,
274 WebContentsImpl* web_contents, 297 WebContentsImpl* web_contents,
275 BrowserPluginGuest* opener, 298 BrowserPluginGuest* opener,
276 bool has_render_view); 299 bool has_render_view);
(...skipping 23 matching lines...) Expand all
300 void OnCompositorFrameACK(int instance_id, 323 void OnCompositorFrameACK(int instance_id,
301 int route_id, 324 int route_id,
302 uint32 output_surface_id, 325 uint32 output_surface_id,
303 int renderer_host_id, 326 int renderer_host_id,
304 const cc::CompositorFrameAck& ack); 327 const cc::CompositorFrameAck& ack);
305 328
306 // Allows or denies a permission request access, after the embedder has had a 329 // Allows or denies a permission request access, after the embedder has had a
307 // chance to decide. 330 // chance to decide.
308 void OnRespondPermission(int instance_id, 331 void OnRespondPermission(int instance_id,
309 int request_id, 332 int request_id,
310 bool should_allow); 333 bool should_allow,
334 const std::string& user_input);
311 // Handles drag events from the embedder. 335 // Handles drag events from the embedder.
312 // When dragging, the drag events go to the embedder first, and if the drag 336 // When dragging, the drag events go to the embedder first, and if the drag
313 // happens on the browser plugin, then the plugin sends a corresponding 337 // happens on the browser plugin, then the plugin sends a corresponding
314 // drag-message to the guest. This routes the drag-message to the guest 338 // drag-message to the guest. This routes the drag-message to the guest
315 // renderer. 339 // renderer.
316 void OnDragStatusUpdate(int instance_id, 340 void OnDragStatusUpdate(int instance_id,
317 WebKit::WebDragStatus drag_status, 341 WebKit::WebDragStatus drag_status,
318 const DropData& drop_data, 342 const DropData& drop_data,
319 WebKit::WebDragOperationsMask drag_mask, 343 WebKit::WebDragOperationsMask drag_mask,
320 const gfx::Point& location); 344 const gfx::Point& location);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 std::queue<IPC::Message*> pending_messages_; 507 std::queue<IPC::Message*> pending_messages_;
484 508
485 scoped_ptr<BrowserPluginGuestDelegate> delegate_; 509 scoped_ptr<BrowserPluginGuestDelegate> delegate_;
486 510
487 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 511 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
488 }; 512 };
489 513
490 } // namespace content 514 } // namespace content
491 515
492 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 516 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698