OLD | NEW |
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 |
(...skipping 10 matching lines...) Expand all Loading... |
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/linked_ptr.h" | 25 #include "base/memory/linked_ptr.h" |
26 #include "base/memory/weak_ptr.h" | 26 #include "base/memory/weak_ptr.h" |
27 #include "base/values.h" | 27 #include "base/values.h" |
28 #include "content/common/edit_command.h" | 28 #include "content/common/edit_command.h" |
29 #include "content/common/input/input_event_ack_state.h" | 29 #include "content/common/input/input_event_ack_state.h" |
30 #include "content/public/browser/browser_plugin_guest_delegate.h" | 30 #include "content/public/browser/browser_plugin_guest_delegate.h" |
| 31 #include "content/public/browser/guest_host.h" |
31 #include "content/public/browser/readback_types.h" | 32 #include "content/public/browser/readback_types.h" |
32 #include "content/public/browser/web_contents_observer.h" | 33 #include "content/public/browser/web_contents_observer.h" |
33 #include "third_party/WebKit/public/platform/WebFocusType.h" | 34 #include "third_party/WebKit/public/platform/WebFocusType.h" |
34 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 35 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
35 #include "third_party/WebKit/public/web/WebDragOperation.h" | 36 #include "third_party/WebKit/public/web/WebDragOperation.h" |
36 #include "third_party/WebKit/public/web/WebDragStatus.h" | 37 #include "third_party/WebKit/public/web/WebDragStatus.h" |
37 #include "third_party/WebKit/public/web/WebInputEvent.h" | 38 #include "third_party/WebKit/public/web/WebInputEvent.h" |
38 #include "ui/base/ime/text_input_mode.h" | 39 #include "ui/base/ime/text_input_mode.h" |
39 #include "ui/base/ime/text_input_type.h" | 40 #include "ui/base/ime/text_input_type.h" |
40 #include "ui/gfx/geometry/rect.h" | 41 #include "ui/gfx/geometry/rect.h" |
41 | 42 |
42 class GuestSizer; | |
43 class SkBitmap; | |
44 struct BrowserPluginHostMsg_Attach_Params; | 43 struct BrowserPluginHostMsg_Attach_Params; |
45 struct FrameHostMsg_CompositorFrameSwappedACK_Params; | 44 struct FrameHostMsg_CompositorFrameSwappedACK_Params; |
46 struct FrameHostMsg_ReclaimCompositorResources_Params; | 45 struct FrameHostMsg_ReclaimCompositorResources_Params; |
47 struct FrameMsg_CompositorFrameSwapped_Params; | 46 struct FrameMsg_CompositorFrameSwapped_Params; |
48 | 47 |
49 #if defined(OS_MACOSX) | 48 #if defined(OS_MACOSX) |
50 struct FrameHostMsg_ShowPopup_Params; | 49 struct FrameHostMsg_ShowPopup_Params; |
51 #endif | 50 #endif |
52 | 51 |
53 namespace cc { | 52 namespace cc { |
(...skipping 16 matching lines...) Expand all Loading... |
70 // A browser plugin guest provides functionality for WebContents to operate in | 69 // A browser plugin guest provides functionality for WebContents to operate in |
71 // the guest role and implements guest-specific overrides for ViewHostMsg_* | 70 // the guest role and implements guest-specific overrides for ViewHostMsg_* |
72 // messages. | 71 // messages. |
73 // | 72 // |
74 // When a guest is initially created, it is in an unattached state. That is, | 73 // When a guest is initially created, it is in an unattached state. That is, |
75 // it is not visible anywhere and has no embedder WebContents assigned. | 74 // it is not visible anywhere and has no embedder WebContents assigned. |
76 // A BrowserPluginGuest is said to be "attached" if it has an embedder. | 75 // A BrowserPluginGuest is said to be "attached" if it has an embedder. |
77 // A BrowserPluginGuest can also create a new unattached guest via | 76 // A BrowserPluginGuest can also create a new unattached guest via |
78 // CreateNewWindow. The newly created guest will live in the same partition, | 77 // CreateNewWindow. The newly created guest will live in the same partition, |
79 // which means it can share storage and can script this guest. | 78 // which means it can share storage and can script this guest. |
80 class CONTENT_EXPORT BrowserPluginGuest : public GuestSizer, | 79 class CONTENT_EXPORT BrowserPluginGuest : public GuestHost, |
81 public WebContentsObserver { | 80 public WebContentsObserver { |
82 public: | 81 public: |
83 ~BrowserPluginGuest() override; | 82 ~BrowserPluginGuest() override; |
84 | 83 |
85 // The WebContents passed into the factory method here has not been | 84 // The WebContents passed into the factory method here has not been |
86 // initialized yet and so it does not yet hold a SiteInstance. | 85 // initialized yet and so it does not yet hold a SiteInstance. |
87 // BrowserPluginGuest must be constructed and installed into a WebContents | 86 // BrowserPluginGuest must be constructed and installed into a WebContents |
88 // prior to its initialization because WebContents needs to determine what | 87 // prior to its initialization because WebContents needs to determine what |
89 // type of WebContentsView to construct on initialization. The content | 88 // type of WebContentsView to construct on initialization. The content |
90 // embedder needs to be aware of |guest_site_instance| on the guest's | 89 // embedder needs to be aware of |guest_site_instance| on the guest's |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 bool mouse_locked() const { return mouse_locked_; } | 124 bool mouse_locked() const { return mouse_locked_; } |
126 | 125 |
127 // Called when the embedder WebContents changes visibility. | 126 // Called when the embedder WebContents changes visibility. |
128 void EmbedderVisibilityChanged(bool visible); | 127 void EmbedderVisibilityChanged(bool visible); |
129 | 128 |
130 // Creates a new guest WebContentsImpl with the provided |params| with |this| | 129 // Creates a new guest WebContentsImpl with the provided |params| with |this| |
131 // as the |opener|. | 130 // as the |opener|. |
132 WebContentsImpl* CreateNewGuestWindow( | 131 WebContentsImpl* CreateNewGuestWindow( |
133 const WebContents::CreateParams& params); | 132 const WebContents::CreateParams& params); |
134 | 133 |
| 134 // Creates, if necessary, and returns the routing ID of a proxy for the guest |
| 135 // in the owner's renderer process. |
| 136 int GetGuestProxyRoutingID(); |
| 137 |
135 // Returns the identifier that uniquely identifies a browser plugin guest | 138 // Returns the identifier that uniquely identifies a browser plugin guest |
136 // within an embedder. | 139 // within an embedder. |
137 int browser_plugin_instance_id() const { return browser_plugin_instance_id_; } | 140 int browser_plugin_instance_id() const { return browser_plugin_instance_id_; } |
138 | 141 |
139 bool OnMessageReceivedFromEmbedder(const IPC::Message& message); | 142 bool OnMessageReceivedFromEmbedder(const IPC::Message& message); |
140 | 143 |
141 WebContentsImpl* embedder_web_contents() const { | 144 WebContentsImpl* embedder_web_contents() const { |
142 return attached_ ? owner_web_contents_ : nullptr; | 145 return attached_ ? owner_web_contents_ : nullptr; |
143 } | 146 } |
144 | 147 |
(...skipping 14 matching lines...) Expand all Loading... |
159 RenderFrameHost* render_frame_host, | 162 RenderFrameHost* render_frame_host, |
160 const GURL& url, | 163 const GURL& url, |
161 ui::PageTransition transition_type) override; | 164 ui::PageTransition transition_type) override; |
162 | 165 |
163 void RenderViewReady() override; | 166 void RenderViewReady() override; |
164 void RenderProcessGone(base::TerminationStatus status) override; | 167 void RenderProcessGone(base::TerminationStatus status) override; |
165 bool OnMessageReceived(const IPC::Message& message) override; | 168 bool OnMessageReceived(const IPC::Message& message) override; |
166 bool OnMessageReceived(const IPC::Message& message, | 169 bool OnMessageReceived(const IPC::Message& message, |
167 RenderFrameHost* render_frame_host) override; | 170 RenderFrameHost* render_frame_host) override; |
168 | 171 |
169 // GuestSizer implementation. | 172 // GuestHost implementation. |
| 173 int LoadURLWithParams( |
| 174 const NavigationController::LoadURLParams& load_params) override; |
170 void SizeContents(const gfx::Size& new_size) override; | 175 void SizeContents(const gfx::Size& new_size) override; |
| 176 void WillDestroy() override; |
171 | 177 |
172 // Exposes the protected web_contents() from WebContentsObserver. | 178 // Exposes the protected web_contents() from WebContentsObserver. |
173 WebContentsImpl* GetWebContents() const; | 179 WebContentsImpl* GetWebContents() const; |
174 | 180 |
175 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; | 181 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; |
176 | 182 |
177 // Helper to send messages to embedder. If this guest is not yet attached, | 183 // Helper to send messages to embedder. If this guest is not yet attached, |
178 // then IPCs will be queued until attachment. | 184 // then IPCs will be queued until attachment. |
179 void SendMessageToEmbedder(IPC::Message* msg); | 185 void SendMessageToEmbedder(IPC::Message* msg); |
180 | 186 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 228 |
223 private: | 229 private: |
224 class EmbedderVisibilityObserver; | 230 class EmbedderVisibilityObserver; |
225 | 231 |
226 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and | 232 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and |
227 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. | 233 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. |
228 BrowserPluginGuest(bool has_render_view, | 234 BrowserPluginGuest(bool has_render_view, |
229 WebContentsImpl* web_contents, | 235 WebContentsImpl* web_contents, |
230 BrowserPluginGuestDelegate* delegate); | 236 BrowserPluginGuestDelegate* delegate); |
231 | 237 |
232 void WillDestroy(); | |
233 | |
234 void InitInternal(const BrowserPluginHostMsg_Attach_Params& params, | 238 void InitInternal(const BrowserPluginHostMsg_Attach_Params& params, |
235 WebContentsImpl* owner_web_contents); | 239 WebContentsImpl* owner_web_contents); |
236 | 240 |
237 bool InAutoSizeBounds(const gfx::Size& size) const; | 241 bool InAutoSizeBounds(const gfx::Size& size) const; |
238 | 242 |
239 // Message handlers for messages from embedder. | 243 // Message handlers for messages from embedder. |
240 void OnCompositorFrameSwappedACK( | 244 void OnCompositorFrameSwappedACK( |
241 int instance_id, | 245 int instance_id, |
242 const FrameHostMsg_CompositorFrameSwappedACK_Params& params); | 246 const FrameHostMsg_CompositorFrameSwappedACK_Params& params); |
243 void OnDetach(int instance_id); | 247 void OnDetach(int instance_id); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 // Weak pointer used to ask GeolocationPermissionContext about geolocation | 414 // Weak pointer used to ask GeolocationPermissionContext about geolocation |
411 // permission. | 415 // permission. |
412 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; | 416 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; |
413 | 417 |
414 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 418 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
415 }; | 419 }; |
416 | 420 |
417 } // namespace content | 421 } // namespace content |
418 | 422 |
419 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 423 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
OLD | NEW |