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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.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 content_browsertests 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 (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. Any 9 // BrowserPluginGuest lives on the UI thread of the browser process. Any
10 // messages about the guest render process that the embedder might be interested 10 // messages about the guest render process that the embedder might be interested
11 // in receiving should be listened for here. 11 // in receiving should be listened for here.
12 // 12 //
13 // BrowserPluginGuest is a WebContentsDelegate and WebContentsObserver for the 13 // BrowserPluginGuest is a WebContentsObserver for the guest WebContents.
14 // guest WebContents. BrowserPluginGuest operates under the assumption that the 14 // BrowserPluginGuest operates under the assumption that the guest will be
15 // guest will be accessible through only one RenderViewHost for the lifetime of 15 // accessible through only one RenderViewHost for the lifetime of
16 // the guest WebContents. Thus, cross-process navigation is not supported. 16 // the guest WebContents. Thus, cross-process navigation is not supported.
17 17
18 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 18 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
19 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 19 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
20 20
21 #include <map> 21 #include <map>
22 #include <queue> 22 #include <queue>
23 23
24 #include "base/compiler_specific.h" 24 #include "base/compiler_specific.h"
25 #include "base/memory/weak_ptr.h" 25 #include "base/memory/weak_ptr.h"
26 #include "base/values.h" 26 #include "base/values.h"
27 #include "content/common/edit_command.h" 27 #include "content/common/edit_command.h"
28 #include "content/common/input/input_event_ack_state.h" 28 #include "content/common/input/input_event_ack_state.h"
29 #include "content/public/browser/browser_plugin_guest_delegate.h" 29 #include "content/public/browser/browser_plugin_guest_delegate.h"
30 #include "content/public/browser/web_contents_delegate.h"
31 #include "content/public/browser/web_contents_observer.h" 30 #include "content/public/browser/web_contents_observer.h"
32 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 31 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
33 #include "third_party/WebKit/public/web/WebDragOperation.h" 32 #include "third_party/WebKit/public/web/WebDragOperation.h"
34 #include "third_party/WebKit/public/web/WebDragStatus.h" 33 #include "third_party/WebKit/public/web/WebDragStatus.h"
35 #include "third_party/WebKit/public/web/WebInputEvent.h" 34 #include "third_party/WebKit/public/web/WebInputEvent.h"
36 #include "ui/base/ime/text_input_mode.h" 35 #include "ui/base/ime/text_input_mode.h"
37 #include "ui/base/ime/text_input_type.h" 36 #include "ui/base/ime/text_input_type.h"
38 #include "ui/gfx/rect.h" 37 #include "ui/gfx/rect.h"
39 #include "ui/surface/transport_dib.h"
40 38
39 class SkBitmap;
41 struct BrowserPluginHostMsg_AutoSize_Params; 40 struct BrowserPluginHostMsg_AutoSize_Params;
42 struct BrowserPluginHostMsg_Attach_Params; 41 struct BrowserPluginHostMsg_Attach_Params;
43 struct BrowserPluginHostMsg_ResizeGuest_Params; 42 struct BrowserPluginHostMsg_ResizeGuest_Params;
44 struct FrameHostMsg_CompositorFrameSwappedACK_Params; 43 struct FrameHostMsg_CompositorFrameSwappedACK_Params;
45 struct FrameHostMsg_ReclaimCompositorResources_Params; 44 struct FrameHostMsg_ReclaimCompositorResources_Params;
46 #if defined(OS_MACOSX) 45 #if defined(OS_MACOSX)
47 struct ViewHostMsg_ShowPopup_Params; 46 struct ViewHostMsg_ShowPopup_Params;
48 #endif 47 #endif
49 struct ViewHostMsg_UpdateRect_Params; 48 struct ViewHostMsg_UpdateRect_Params;
50 49
51 namespace blink { 50 namespace blink {
52 class WebInputEvent; 51 class WebInputEvent;
53 } 52 }
54 53
55 namespace gfx { 54 namespace gfx {
56 class Range; 55 class Range;
57 } 56 }
58 57
59 namespace content { 58 namespace content {
60 59
61 class BrowserPluginGuestManager; 60 class BrowserPluginGuestManager;
62 class BrowserPluginHostFactory; 61 class BrowserPluginHostFactory;
63 class RenderWidgetHostView; 62 class RenderWidgetHostView;
64 class SiteInstance; 63 class SiteInstance;
65 class WebCursor; 64 class WebCursor;
66 struct DropData; 65 struct DropData;
67 struct MediaStreamRequest;
68 66
69 // A browser plugin guest provides functionality for WebContents to operate in 67 // A browser plugin guest provides functionality for WebContents to operate in
70 // the guest role and implements guest-specific overrides for ViewHostMsg_* 68 // the guest role and implements guest-specific overrides for ViewHostMsg_*
71 // messages. 69 // messages.
72 // 70 //
73 // When a guest is initially created, it is in an unattached state. That is, 71 // When a guest is initially created, it is in an unattached state. That is,
74 // it is not visible anywhere and has no embedder WebContents assigned. 72 // it is not visible anywhere and has no embedder WebContents assigned.
75 // A BrowserPluginGuest is said to be "attached" if it has an embedder. 73 // A BrowserPluginGuest is said to be "attached" if it has an embedder.
76 // A BrowserPluginGuest can also create a new unattached guest via 74 // A BrowserPluginGuest can also create a new unattached guest via
77 // CreateNewWindow. The newly created guest will live in the same partition, 75 // CreateNewWindow. The newly created guest will live in the same partition,
78 // which means it can share storage and can script this guest. 76 // which means it can share storage and can script this guest.
79 class CONTENT_EXPORT BrowserPluginGuest 77 class CONTENT_EXPORT BrowserPluginGuest : public WebContentsObserver {
80 : public WebContentsDelegate,
81 public WebContentsObserver {
82 public: 78 public:
83 virtual ~BrowserPluginGuest(); 79 virtual ~BrowserPluginGuest();
84 80
85 // The WebContents passed into the factory method here has not been 81 // The WebContents passed into the factory method here has not been
86 // initialized yet and so it does not yet hold a SiteInstance. 82 // initialized yet and so it does not yet hold a SiteInstance.
87 // BrowserPluginGuest must be constructed and installed into a WebContents 83 // BrowserPluginGuest must be constructed and installed into a WebContents
88 // prior to its initialization because WebContents needs to determine what 84 // prior to its initialization because WebContents needs to determine what
89 // type of WebContentsView to construct on initialization. The content 85 // type of WebContentsView to construct on initialization. The content
90 // embedder needs to be aware of |guest_site_instance| on the guest's 86 // embedder needs to be aware of |guest_site_instance| on the guest's
91 // construction and so we pass it in here. 87 // construction and so we pass it in here.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 bool is_main_frame, 150 bool is_main_frame,
155 const GURL& url, 151 const GURL& url,
156 PageTransition transition_type, 152 PageTransition transition_type,
157 RenderViewHost* render_view_host) OVERRIDE; 153 RenderViewHost* render_view_host) OVERRIDE;
158 virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE; 154 virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE;
159 155
160 virtual void RenderViewReady() OVERRIDE; 156 virtual void RenderViewReady() OVERRIDE;
161 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE; 157 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
162 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 158 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
163 159
164 // WebContentsDelegate implementation.
165 virtual bool AddMessageToConsole(WebContents* source,
166 int32 level,
167 const base::string16& message,
168 int32 line_no,
169 const base::string16& source_id) OVERRIDE;
170 // 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 // attached.
173 virtual void AddNewContents(WebContents* source,
174 WebContents* new_contents,
175 WindowOpenDisposition disposition,
176 const gfx::Rect& initial_pos,
177 bool user_gesture,
178 bool* was_blocked) OVERRIDE;
179 virtual void CanDownload(RenderViewHost* render_view_host,
180 const GURL& url,
181 const std::string& request_method,
182 const base::Callback<void(bool)>& callback) OVERRIDE;
183 virtual void LoadProgressChanged(WebContents* source,
184 double progress) OVERRIDE;
185 virtual void CloseContents(WebContents* source) OVERRIDE;
186 virtual JavaScriptDialogManager* GetJavaScriptDialogManager() OVERRIDE;
187 virtual ColorChooser* OpenColorChooser(
188 WebContents* web_contents,
189 SkColor color,
190 const std::vector<ColorSuggestion>& suggestions) OVERRIDE;
191 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE;
192 virtual void HandleKeyboardEvent(
193 WebContents* source,
194 const NativeWebKeyboardEvent& event) OVERRIDE;
195 virtual void FindReply(WebContents* contents,
196 int request_id,
197 int number_of_matches,
198 const gfx::Rect& selection_rect,
199 int active_match_ordinal,
200 bool final_update) OVERRIDE;
201 virtual WebContents* OpenURLFromTab(WebContents* source,
202 const OpenURLParams& params) OVERRIDE;
203 virtual void WebContentsCreated(WebContents* source_contents,
204 int opener_render_frame_id,
205 const base::string16& frame_name,
206 const GURL& target_url,
207 WebContents* new_contents) OVERRIDE;
208 virtual void RendererUnresponsive(WebContents* source) OVERRIDE;
209 virtual void RendererResponsive(WebContents* source) OVERRIDE;
210 virtual void RunFileChooser(WebContents* web_contents,
211 const FileChooserParams& params) OVERRIDE;
212 virtual bool ShouldFocusPageAfterCrash() OVERRIDE;
213 virtual void RequestMediaAccessPermission(
214 WebContents* web_contents,
215 const MediaStreamRequest& request,
216 const MediaResponseCallback& callback) OVERRIDE;
217 virtual bool PreHandleGestureEvent(
218 content::WebContents* source,
219 const blink::WebGestureEvent& event) OVERRIDE;
220
221 // Exposes the protected web_contents() from WebContentsObserver. 160 // Exposes the protected web_contents() from WebContentsObserver.
222 WebContentsImpl* GetWebContents() const; 161 WebContentsImpl* GetWebContents() const;
223 162
224 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; 163 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const;
225 164
226 // Helper to send messages to embedder. This methods fills the message with 165 // Helper to send messages to embedder. This methods fills the message with
227 // the correct routing id. 166 // the correct routing id.
228 // Overridden in test implementation since we want to intercept certain 167 // Overridden in test implementation since we want to intercept certain
229 // messages for testing. 168 // messages for testing.
230 virtual void SendMessageToEmbedder(IPC::Message* msg); 169 virtual void SendMessageToEmbedder(IPC::Message* msg);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 // Weak pointer used to ask GeolocationPermissionContext about geolocation 398 // Weak pointer used to ask GeolocationPermissionContext about geolocation
460 // permission. 399 // permission.
461 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; 400 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_;
462 401
463 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); 402 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest);
464 }; 403 };
465 404
466 } // namespace content 405 } // namespace content
467 406
468 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ 407 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698