OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/renderer/webplugin_delegate_proxy.h" | 5 #include "chrome/renderer/webplugin_delegate_proxy.h" |
6 | 6 |
7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "net/base/mime_util.h" | 41 #include "net/base/mime_util.h" |
42 #include "printing/native_metafile.h" | 42 #include "printing/native_metafile.h" |
43 #include "skia/ext/platform_canvas.h" | 43 #include "skia/ext/platform_canvas.h" |
44 #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" | 44 #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" |
45 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" | 45 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" |
46 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" | 46 #include "third_party/WebKit/WebKit/chromium/public/WebDragData.h" |
47 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 47 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
48 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 48 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
49 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" | 49 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" |
50 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" | 50 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" |
51 #include "webkit/plugins/npapi/webplugin.h" | 51 #include "webkit/glue/plugins/webplugin.h" |
52 #include "webkit/glue/webkit_glue.h" | 52 #include "webkit/glue/webkit_glue.h" |
53 | 53 |
54 #if defined(OS_POSIX) | 54 #if defined(OS_POSIX) |
55 #include "ipc/ipc_channel_posix.h" | 55 #include "ipc/ipc_channel_posix.h" |
56 #endif | 56 #endif |
57 | 57 |
58 using WebKit::WebBindings; | 58 using WebKit::WebBindings; |
59 using WebKit::WebCursorInfo; | 59 using WebKit::WebCursorInfo; |
60 using WebKit::WebDragData; | 60 using WebKit::WebDragData; |
61 using WebKit::WebInputEvent; | 61 using WebKit::WebInputEvent; |
62 using WebKit::WebString; | 62 using WebKit::WebString; |
63 using WebKit::WebVector; | 63 using WebKit::WebVector; |
64 using WebKit::WebView; | 64 using WebKit::WebView; |
65 | 65 |
66 // Proxy for WebPluginResourceClient. The object owns itself after creation, | 66 // Proxy for WebPluginResourceClient. The object owns itself after creation, |
67 // deleting itself after its callback has been called. | 67 // deleting itself after its callback has been called. |
68 class ResourceClientProxy : public webkit::npapi::WebPluginResourceClient { | 68 class ResourceClientProxy : public webkit_glue::WebPluginResourceClient { |
69 public: | 69 public: |
70 ResourceClientProxy(PluginChannelHost* channel, int instance_id) | 70 ResourceClientProxy(PluginChannelHost* channel, int instance_id) |
71 : channel_(channel), instance_id_(instance_id), resource_id_(0), | 71 : channel_(channel), instance_id_(instance_id), resource_id_(0), |
72 multibyte_response_expected_(false) { | 72 multibyte_response_expected_(false) { |
73 } | 73 } |
74 | 74 |
75 ~ResourceClientProxy() { | 75 ~ResourceClientProxy() { |
76 } | 76 } |
77 | 77 |
78 void Initialize(unsigned long resource_id, const GURL& url, int notify_id) { | 78 void Initialize(unsigned long resource_id, const GURL& url, int notify_id) { |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 base::SplitString(value_string, ',', &components); | 260 base::SplitString(value_string, ',', &components); |
261 if (components.size() == 4 && !StartsWithASCII(components[0], "1", false)) | 261 if (components.size() == 4 && !StartsWithASCII(components[0], "1", false)) |
262 return true; | 262 return true; |
263 } else if (LowerCaseEqualsASCII(color, "transparent")) { | 263 } else if (LowerCaseEqualsASCII(color, "transparent")) { |
264 return true; | 264 return true; |
265 } | 265 } |
266 // Anything else is a named, opaque color or an RGB form with no alpha. | 266 // Anything else is a named, opaque color or an RGB form with no alpha. |
267 return false; | 267 return false; |
268 } | 268 } |
269 | 269 |
270 bool WebPluginDelegateProxy::Initialize( | 270 bool WebPluginDelegateProxy::Initialize(const GURL& url, |
271 const GURL& url, | |
272 const std::vector<std::string>& arg_names, | 271 const std::vector<std::string>& arg_names, |
273 const std::vector<std::string>& arg_values, | 272 const std::vector<std::string>& arg_values, |
274 webkit::npapi::WebPlugin* plugin, | 273 webkit_glue::WebPlugin* plugin, |
275 bool load_manually) { | 274 bool load_manually) { |
276 IPC::ChannelHandle channel_handle; | 275 IPC::ChannelHandle channel_handle; |
277 if (!RenderThread::current()->Send(new ViewHostMsg_OpenChannelToPlugin( | 276 if (!RenderThread::current()->Send(new ViewHostMsg_OpenChannelToPlugin( |
278 url, mime_type_, &channel_handle, &info_))) { | 277 url, mime_type_, &channel_handle, &info_))) { |
279 return false; | 278 return false; |
280 } | 279 } |
281 | 280 |
282 if (channel_handle.name.empty()) { | 281 if (channel_handle.name.empty()) { |
283 // We got an invalid handle. Either the plugin couldn't be found (which | 282 // We got an invalid handle. Either the plugin couldn't be found (which |
284 // shouldn't happen, since if we got here the plugin should exist) or the | 283 // shouldn't happen, since if we got here the plugin should exist) or the |
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1343 const char* target = NULL; | 1342 const char* target = NULL; |
1344 if (params.target.length()) | 1343 if (params.target.length()) |
1345 target = params.target.c_str(); | 1344 target = params.target.c_str(); |
1346 | 1345 |
1347 plugin_->HandleURLRequest( | 1346 plugin_->HandleURLRequest( |
1348 params.url.c_str(), params.method.c_str(), target, data, | 1347 params.url.c_str(), params.method.c_str(), target, data, |
1349 static_cast<unsigned int>(params.buffer.size()), params.notify_id, | 1348 static_cast<unsigned int>(params.buffer.size()), params.notify_id, |
1350 params.popups_allowed, params.notify_redirects); | 1349 params.popups_allowed, params.notify_redirects); |
1351 } | 1350 } |
1352 | 1351 |
1353 webkit::npapi::WebPluginResourceClient* | 1352 webkit_glue::WebPluginResourceClient* |
1354 WebPluginDelegateProxy::CreateResourceClient( | 1353 WebPluginDelegateProxy::CreateResourceClient( |
1355 unsigned long resource_id, const GURL& url, int notify_id) { | 1354 unsigned long resource_id, const GURL& url, int notify_id) { |
1356 if (!channel_host_) | 1355 if (!channel_host_) |
1357 return NULL; | 1356 return NULL; |
1358 | 1357 |
1359 ResourceClientProxy* proxy = new ResourceClientProxy(channel_host_, | 1358 ResourceClientProxy* proxy = new ResourceClientProxy(channel_host_, |
1360 instance_id_); | 1359 instance_id_); |
1361 proxy->Initialize(resource_id, url, notify_id); | 1360 proxy->Initialize(resource_id, url, notify_id); |
1362 return proxy; | 1361 return proxy; |
1363 } | 1362 } |
1364 | 1363 |
1365 webkit::npapi::WebPluginResourceClient* | 1364 webkit_glue::WebPluginResourceClient* |
1366 WebPluginDelegateProxy::CreateSeekableResourceClient( | 1365 WebPluginDelegateProxy::CreateSeekableResourceClient( |
1367 unsigned long resource_id, int range_request_id) { | 1366 unsigned long resource_id, int range_request_id) { |
1368 if (!channel_host_) | 1367 if (!channel_host_) |
1369 return NULL; | 1368 return NULL; |
1370 | 1369 |
1371 ResourceClientProxy* proxy = new ResourceClientProxy(channel_host_, | 1370 ResourceClientProxy* proxy = new ResourceClientProxy(channel_host_, |
1372 instance_id_); | 1371 instance_id_); |
1373 proxy->InitializeForSeekableStream(resource_id, range_request_id); | 1372 proxy->InitializeForSeekableStream(resource_id, range_request_id); |
1374 return proxy; | 1373 return proxy; |
1375 } | 1374 } |
(...skipping 22 matching lines...) Expand all Loading... |
1398 return false; | 1397 return false; |
1399 OnSetWindow(fake_window); | 1398 OnSetWindow(fake_window); |
1400 if (!Send(new PluginMsg_SetFakeAcceleratedSurfaceWindowHandle(instance_id_, | 1399 if (!Send(new PluginMsg_SetFakeAcceleratedSurfaceWindowHandle(instance_id_, |
1401 fake_window))) { | 1400 fake_window))) { |
1402 return false; | 1401 return false; |
1403 } | 1402 } |
1404 | 1403 |
1405 // Since this isn't a real window, it doesn't get initial size and location | 1404 // Since this isn't a real window, it doesn't get initial size and location |
1406 // information the way a real windowed plugin would, so we need to feed it its | 1405 // information the way a real windowed plugin would, so we need to feed it its |
1407 // starting geometry. | 1406 // starting geometry. |
1408 webkit::npapi::WebPluginGeometry geom; | 1407 webkit_glue::WebPluginGeometry geom; |
1409 geom.window = fake_window; | 1408 geom.window = fake_window; |
1410 geom.window_rect = plugin_rect_; | 1409 geom.window_rect = plugin_rect_; |
1411 geom.clip_rect = clip_rect_; | 1410 geom.clip_rect = clip_rect_; |
1412 geom.rects_valid = true; | 1411 geom.rects_valid = true; |
1413 geom.visible = true; | 1412 geom.visible = true; |
1414 render_view_->DidMovePlugin(geom); | 1413 render_view_->DidMovePlugin(geom); |
1415 // Invalidate the plugin region to ensure that the move event actually gets | 1414 // Invalidate the plugin region to ensure that the move event actually gets |
1416 // dispatched (for a plugin on an otherwise static page). | 1415 // dispatched (for a plugin on an otherwise static page). |
1417 render_view_->didInvalidateRect(WebKit::WebRect(plugin_rect_.x(), | 1416 render_view_->didInvalidateRect(WebKit::WebRect(plugin_rect_.x(), |
1418 plugin_rect_.y(), | 1417 plugin_rect_.y(), |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 #if defined(OS_WIN) | 1536 #if defined(OS_WIN) |
1538 bool WebPluginDelegateProxy::UseSynchronousGeometryUpdates() { | 1537 bool WebPluginDelegateProxy::UseSynchronousGeometryUpdates() { |
1539 // Need to update geometry synchronously with WMP, otherwise if a site | 1538 // Need to update geometry synchronously with WMP, otherwise if a site |
1540 // scripts the plugin to start playing while it's in the middle of handling | 1539 // scripts the plugin to start playing while it's in the middle of handling |
1541 // an update geometry message, videos don't play. See urls in bug 20260. | 1540 // an update geometry message, videos don't play. See urls in bug 20260. |
1542 if (info_.name.find(ASCIIToUTF16("Windows Media Player")) != string16::npos) | 1541 if (info_.name.find(ASCIIToUTF16("Windows Media Player")) != string16::npos) |
1543 return true; | 1542 return true; |
1544 | 1543 |
1545 // The move networks plugin needs to be informed of geometry updates | 1544 // The move networks plugin needs to be informed of geometry updates |
1546 // synchronously. | 1545 // synchronously. |
1547 std::vector<webkit::npapi::WebPluginMimeType>::iterator index; | 1546 std::vector<WebPluginMimeType>::iterator index; |
1548 for (index = info_.mime_types.begin(); index != info_.mime_types.end(); | 1547 for (index = info_.mime_types.begin(); index != info_.mime_types.end(); |
1549 index++) { | 1548 index++) { |
1550 if (index->mime_type == "application/x-vnd.moveplayer.qm" || | 1549 if (index->mime_type == "application/x-vnd.moveplayer.qm" || |
1551 index->mime_type == "application/x-vnd.moveplay2.qm" || | 1550 index->mime_type == "application/x-vnd.moveplay2.qm" || |
1552 index->mime_type == "application/x-vnd.movenetworks.qm" || | 1551 index->mime_type == "application/x-vnd.movenetworks.qm" || |
1553 index->mime_type == "application/x-vnd.mnplayer.qm") { | 1552 index->mime_type == "application/x-vnd.mnplayer.qm") { |
1554 return true; | 1553 return true; |
1555 } | 1554 } |
1556 } | 1555 } |
1557 return false; | 1556 return false; |
1558 } | 1557 } |
1559 #endif | 1558 #endif |
1560 | 1559 |
1561 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, | 1560 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, |
1562 int resource_id) { | 1561 int resource_id) { |
1563 if (!plugin_) | 1562 if (!plugin_) |
1564 return; | 1563 return; |
1565 | 1564 |
1566 plugin_->URLRedirectResponse(allow, resource_id); | 1565 plugin_->URLRedirectResponse(allow, resource_id); |
1567 } | 1566 } |
1568 | 1567 |
OLD | NEW |