| 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_proxy_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 GuestProxyHost, |
| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 RenderFrameHost* render_frame_host, | 158 RenderFrameHost* render_frame_host, |
| 160 const GURL& url, | 159 const GURL& url, |
| 161 ui::PageTransition transition_type) override; | 160 ui::PageTransition transition_type) override; |
| 162 | 161 |
| 163 void RenderViewReady() override; | 162 void RenderViewReady() override; |
| 164 void RenderProcessGone(base::TerminationStatus status) override; | 163 void RenderProcessGone(base::TerminationStatus status) override; |
| 165 bool OnMessageReceived(const IPC::Message& message) override; | 164 bool OnMessageReceived(const IPC::Message& message) override; |
| 166 bool OnMessageReceived(const IPC::Message& message, | 165 bool OnMessageReceived(const IPC::Message& message, |
| 167 RenderFrameHost* render_frame_host) override; | 166 RenderFrameHost* render_frame_host) override; |
| 168 | 167 |
| 169 // GuestSizer implementation. | 168 // GuestProxyHost implementation. |
| 169 int GetGuestProxyRoutingID() const override; |
| 170 int GetOrCreateGuestProxyInOwnerProcess() override; |
| 170 void SizeContents(const gfx::Size& new_size) override; | 171 void SizeContents(const gfx::Size& new_size) override; |
| 172 void WillDestroy() override; |
| 171 | 173 |
| 172 // Exposes the protected web_contents() from WebContentsObserver. | 174 // Exposes the protected web_contents() from WebContentsObserver. |
| 173 WebContentsImpl* GetWebContents() const; | 175 WebContentsImpl* GetWebContents() const; |
| 174 | 176 |
| 175 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; | 177 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; |
| 176 | 178 |
| 177 // Helper to send messages to embedder. If this guest is not yet attached, | 179 // Helper to send messages to embedder. If this guest is not yet attached, |
| 178 // then IPCs will be queued until attachment. | 180 // then IPCs will be queued until attachment. |
| 179 void SendMessageToEmbedder(IPC::Message* msg); | 181 void SendMessageToEmbedder(IPC::Message* msg); |
| 180 | 182 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 224 |
| 223 private: | 225 private: |
| 224 class EmbedderVisibilityObserver; | 226 class EmbedderVisibilityObserver; |
| 225 | 227 |
| 226 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and | 228 // BrowserPluginGuest is a WebContentsObserver of |web_contents| and |
| 227 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. | 229 // |web_contents| has to stay valid for the lifetime of BrowserPluginGuest. |
| 228 BrowserPluginGuest(bool has_render_view, | 230 BrowserPluginGuest(bool has_render_view, |
| 229 WebContentsImpl* web_contents, | 231 WebContentsImpl* web_contents, |
| 230 BrowserPluginGuestDelegate* delegate); | 232 BrowserPluginGuestDelegate* delegate); |
| 231 | 233 |
| 232 void WillDestroy(); | |
| 233 | |
| 234 void InitInternal(const BrowserPluginHostMsg_Attach_Params& params, | 234 void InitInternal(const BrowserPluginHostMsg_Attach_Params& params, |
| 235 WebContentsImpl* owner_web_contents); | 235 WebContentsImpl* owner_web_contents); |
| 236 | 236 |
| 237 bool InAutoSizeBounds(const gfx::Size& size) const; | 237 bool InAutoSizeBounds(const gfx::Size& size) const; |
| 238 | 238 |
| 239 // Message handlers for messages from embedder. | 239 // Message handlers for messages from embedder. |
| 240 void OnCompositorFrameSwappedACK( | 240 void OnCompositorFrameSwappedACK( |
| 241 int instance_id, | 241 int instance_id, |
| 242 const FrameHostMsg_CompositorFrameSwappedACK_Params& params); | 242 const FrameHostMsg_CompositorFrameSwappedACK_Params& params); |
| 243 void OnDetach(int instance_id); | 243 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 | 410 // Weak pointer used to ask GeolocationPermissionContext about geolocation |
| 411 // permission. | 411 // permission. |
| 412 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; | 412 base::WeakPtrFactory<BrowserPluginGuest> weak_ptr_factory_; |
| 413 | 413 |
| 414 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 414 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
| 415 }; | 415 }; |
| 416 | 416 |
| 417 } // namespace content | 417 } // namespace content |
| 418 | 418 |
| 419 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 419 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
| OLD | NEW |