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 #ifndef CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ | 5 #ifndef CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ |
6 #define CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ | 6 #define CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "ui/gl/gpu_preference.h" | 22 #include "ui/gl/gpu_preference.h" |
23 #include "ui/surface/transport_dib.h" | 23 #include "ui/surface/transport_dib.h" |
24 #include "url/gurl.h" | 24 #include "url/gurl.h" |
25 | 25 |
26 #if defined(OS_MACOSX) | 26 #if defined(OS_MACOSX) |
27 #include <ApplicationServices/ApplicationServices.h> | 27 #include <ApplicationServices/ApplicationServices.h> |
28 | 28 |
29 #include "base/mac/scoped_cftyperef.h" | 29 #include "base/mac/scoped_cftyperef.h" |
30 #endif | 30 #endif |
31 | 31 |
32 struct PluginMsg_FetchURL_Params; | |
33 | |
34 namespace content { | 32 namespace content { |
35 class PluginChannel; | 33 class PluginChannel; |
36 class WebPluginDelegateImpl; | 34 class WebPluginDelegateImpl; |
37 | 35 |
38 #if defined(OS_MACOSX) | 36 #if defined(OS_MACOSX) |
39 class WebPluginAcceleratedSurfaceProxy; | 37 class WebPluginAcceleratedSurfaceProxy; |
40 #endif | 38 #endif |
41 | 39 |
42 // This is an implementation of WebPlugin that proxies all calls to the | 40 // This is an implementation of WebPlugin that proxies all calls to the |
43 // renderer. | 41 // renderer. |
44 class WebPluginProxy : public WebPlugin, | 42 class WebPluginProxy : public WebPlugin, |
45 public IPC::Sender { | 43 public IPC::Sender { |
46 public: | 44 public: |
47 // Creates a new proxy for WebPlugin, using the given sender to send the | 45 // Creates a new proxy for WebPlugin, using the given sender to send the |
48 // marshalled WebPlugin calls. | 46 // marshalled WebPlugin calls. |
49 WebPluginProxy(PluginChannel* channel, | 47 WebPluginProxy(PluginChannel* channel, |
50 int route_id, | 48 int route_id, |
51 const GURL& page_url, | 49 const GURL& page_url, |
52 int host_render_view_routing_id); | 50 int host_render_view_routing_id); |
53 ~WebPluginProxy() override; | 51 ~WebPluginProxy() override; |
54 | 52 |
55 void set_delegate(WebPluginDelegateImpl* d) { delegate_ = d; } | 53 void set_delegate(WebPluginDelegateImpl* d) { delegate_ = d; } |
56 | 54 |
57 // WebPlugin overrides | 55 // WebPlugin overrides |
58 void SetWindow(gfx::PluginWindowHandle window) override; | 56 void SetWindow(gfx::PluginWindowHandle window) override; |
59 void SetAcceptsInputEvents(bool accepts) override; | 57 void SetAcceptsInputEvents(bool accepts) override; |
60 void WillDestroyWindow(gfx::PluginWindowHandle window) override; | 58 void WillDestroyWindow(gfx::PluginWindowHandle window) override; |
61 void CancelResource(unsigned long id) override; | |
62 void Invalidate() override; | 59 void Invalidate() override; |
63 void InvalidateRect(const gfx::Rect& rect) override; | 60 void InvalidateRect(const gfx::Rect& rect) override; |
64 NPObject* GetWindowScriptNPObject() override; | 61 NPObject* GetWindowScriptNPObject() override; |
65 NPObject* GetPluginElement() override; | 62 NPObject* GetPluginElement() override; |
66 bool FindProxyForUrl(const GURL& url, std::string* proxy_list) override; | 63 bool FindProxyForUrl(const GURL& url, std::string* proxy_list) override; |
67 void SetCookie(const GURL& url, | 64 void SetCookie(const GURL& url, |
68 const GURL& first_party_for_cookies, | 65 const GURL& first_party_for_cookies, |
69 const std::string& cookie) override; | 66 const std::string& cookie) override; |
70 std::string GetCookies(const GURL& url, | 67 std::string GetCookies(const GURL& url, |
71 const GURL& first_party_for_cookies) override; | 68 const GURL& first_party_for_cookies) override; |
72 void UpdateGeometry(const gfx::Rect& window_rect, | 69 void UpdateGeometry(const gfx::Rect& window_rect, |
73 const gfx::Rect& clip_rect, | 70 const gfx::Rect& clip_rect, |
74 const TransportDIB::Handle& windowless_buffer0, | 71 const TransportDIB::Handle& windowless_buffer0, |
75 const TransportDIB::Handle& windowless_buffer1, | 72 const TransportDIB::Handle& windowless_buffer1, |
76 int windowless_buffer_index); | 73 int windowless_buffer_index); |
77 void CancelDocumentLoad() override; | 74 void CancelDocumentLoad() override; |
78 void DidStartLoading() override; | 75 void DidStartLoading() override; |
79 void DidStopLoading() override; | 76 void DidStopLoading() override; |
80 void SetDeferResourceLoading(unsigned long resource_id, bool defer) override; | |
81 bool IsOffTheRecord() override; | 77 bool IsOffTheRecord() override; |
82 void ResourceClientDeleted(WebPluginResourceClient* resource_client) override; | |
83 void URLRedirectResponse(bool allow, int resource_id) override; | |
84 #if defined(OS_WIN) | 78 #if defined(OS_WIN) |
85 void SetWindowlessData(HANDLE pump_messages_event, | 79 void SetWindowlessData(HANDLE pump_messages_event, |
86 gfx::NativeViewId dummy_activation_window) override; | 80 gfx::NativeViewId dummy_activation_window) override; |
87 #endif | 81 #endif |
88 #if defined(OS_MACOSX) | 82 #if defined(OS_MACOSX) |
89 void FocusChanged(bool focused) override; | 83 void FocusChanged(bool focused) override; |
90 void StartIme() override; | 84 void StartIme() override; |
91 WebPluginAcceleratedSurface* GetAcceleratedSurface( | 85 WebPluginAcceleratedSurface* GetAcceleratedSurface( |
92 gfx::GpuPreference gpu_preference) override; | 86 gfx::GpuPreference gpu_preference) override; |
93 void AcceleratedPluginEnabledRendering() override; | 87 void AcceleratedPluginEnabledRendering() override; |
94 void AcceleratedPluginAllocatedIOSurface(int32_t width, | 88 void AcceleratedPluginAllocatedIOSurface(int32_t width, |
95 int32_t height, | 89 int32_t height, |
96 uint32_t surface_id) override; | 90 uint32_t surface_id) override; |
97 void AcceleratedPluginSwappedIOSurface() override; | 91 void AcceleratedPluginSwappedIOSurface() override; |
98 #endif | 92 #endif |
99 | 93 |
100 // IPC::Sender implementation. | 94 // IPC::Sender implementation. |
101 bool Send(IPC::Message* msg) override; | 95 bool Send(IPC::Message* msg) override; |
102 | 96 |
103 // class-specific methods | 97 // class-specific methods |
104 | 98 |
105 // Returns a WebPluginResourceClient object given its id, or NULL if no | |
106 // object with that id exists. | |
107 WebPluginResourceClient* GetResourceClient(int id); | |
108 | |
109 // Returns the id of the renderer that contains this plugin. | 99 // Returns the id of the renderer that contains this plugin. |
110 int GetRendererId(); | 100 int GetRendererId(); |
111 | 101 |
112 // Returns the id of the associated render view. | 102 // Returns the id of the associated render view. |
113 int host_render_view_routing_id() const { | 103 int host_render_view_routing_id() const { |
114 return host_render_view_routing_id_; | 104 return host_render_view_routing_id_; |
115 } | 105 } |
116 | 106 |
117 // For windowless plugins, paints the given rectangle into the local buffer. | 107 // For windowless plugins, paints the given rectangle into the local buffer. |
118 void Paint(const gfx::Rect& rect); | 108 void Paint(const gfx::Rect& rect); |
119 | 109 |
120 // Callback from the renderer to let us know that a paint occurred. | 110 // Callback from the renderer to let us know that a paint occurred. |
121 void DidPaint(); | 111 void DidPaint(); |
122 | 112 |
123 // Notification received on a plugin issued resource request creation. | |
124 void OnResourceCreated(int resource_id, WebPluginResourceClient* client); | |
125 | |
126 #if defined(OS_WIN) && !defined(USE_AURA) | 113 #if defined(OS_WIN) && !defined(USE_AURA) |
127 // Retrieves the IME status from a windowless plugin and sends it to a | 114 // Retrieves the IME status from a windowless plugin and sends it to a |
128 // renderer process. A renderer process will convert the coordinates from | 115 // renderer process. A renderer process will convert the coordinates from |
129 // local to the window coordinates and send the converted coordinates to a | 116 // local to the window coordinates and send the converted coordinates to a |
130 // browser process. | 117 // browser process. |
131 void UpdateIMEStatus(); | 118 void UpdateIMEStatus(); |
132 #endif | 119 #endif |
133 | 120 |
134 private: | 121 private: |
135 class SharedTransportDIB : public base::RefCounted<SharedTransportDIB> { | 122 class SharedTransportDIB : public base::RefCounted<SharedTransportDIB> { |
(...skipping 30 matching lines...) Expand all Loading... |
166 #if defined(OS_MACOSX) | 153 #if defined(OS_MACOSX) |
167 CGContextRef windowless_context() const { | 154 CGContextRef windowless_context() const { |
168 return windowless_contexts_[windowless_buffer_index_].get(); | 155 return windowless_contexts_[windowless_buffer_index_].get(); |
169 } | 156 } |
170 #else | 157 #else |
171 skia::RefPtr<SkCanvas> windowless_canvas() const { | 158 skia::RefPtr<SkCanvas> windowless_canvas() const { |
172 return windowless_canvases_[windowless_buffer_index_]; | 159 return windowless_canvases_[windowless_buffer_index_]; |
173 } | 160 } |
174 #endif | 161 #endif |
175 | 162 |
176 typedef base::hash_map<int, WebPluginResourceClient*> ResourceClientMap; | |
177 ResourceClientMap resource_clients_; | |
178 | |
179 scoped_refptr<PluginChannel> channel_; | 163 scoped_refptr<PluginChannel> channel_; |
180 int route_id_; | 164 int route_id_; |
181 NPObject* window_npobject_; | 165 NPObject* window_npobject_; |
182 NPObject* plugin_element_; | 166 NPObject* plugin_element_; |
183 WebPluginDelegateImpl* delegate_; | 167 WebPluginDelegateImpl* delegate_; |
184 gfx::Rect damaged_rect_; | 168 gfx::Rect damaged_rect_; |
185 bool waiting_for_paint_; | 169 bool waiting_for_paint_; |
186 // The url of the main frame hosting the plugin. | 170 // The url of the main frame hosting the plugin. |
187 GURL page_url_; | 171 GURL page_url_; |
188 | 172 |
(...skipping 13 matching lines...) Expand all Loading... |
202 | 186 |
203 // Contains the routing id of the host render view. | 187 // Contains the routing id of the host render view. |
204 int host_render_view_routing_id_; | 188 int host_render_view_routing_id_; |
205 | 189 |
206 base::WeakPtrFactory<WebPluginProxy> weak_factory_; | 190 base::WeakPtrFactory<WebPluginProxy> weak_factory_; |
207 }; | 191 }; |
208 | 192 |
209 } // namespace content | 193 } // namespace content |
210 | 194 |
211 #endif // CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ | 195 #endif // CONTENT_PLUGIN_WEBPLUGIN_PROXY_H_ |
OLD | NEW |