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

Side by Side Diff: chrome/renderer/webplugin_delegate_proxy.cc

Issue 6576020: Remove Gears from Chrome (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: ready to review Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
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 22 matching lines...) Expand all
33 #include "grit/renderer_resources.h" 33 #include "grit/renderer_resources.h"
34 #include "ipc/ipc_channel_handle.h" 34 #include "ipc/ipc_channel_handle.h"
35 #include "net/base/mime_util.h" 35 #include "net/base/mime_util.h"
36 #include "printing/native_metafile.h" 36 #include "printing/native_metafile.h"
37 #include "skia/ext/platform_canvas.h" 37 #include "skia/ext/platform_canvas.h"
38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" 39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h" 40 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragData.h"
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
45 #include "ui/base/resource/resource_bundle.h" 44 #include "ui/base/resource/resource_bundle.h"
46 #include "ui/gfx/blit.h" 45 #include "ui/gfx/blit.h"
47 #include "ui/gfx/canvas_skia.h" 46 #include "ui/gfx/canvas_skia.h"
48 #include "ui/gfx/native_widget_types.h" 47 #include "ui/gfx/native_widget_types.h"
49 #include "ui/gfx/size.h" 48 #include "ui/gfx/size.h"
50 #include "webkit/plugins/npapi/webplugin.h" 49 #include "webkit/plugins/npapi/webplugin.h"
51 #include "webkit/glue/webkit_glue.h" 50 #include "webkit/glue/webkit_glue.h"
52 51
53 #if defined(OS_POSIX) 52 #if defined(OS_POSIX)
54 #include "ipc/ipc_channel_posix.h" 53 #include "ipc/ipc_channel_posix.h"
55 #endif 54 #endif
56 55
57 using WebKit::WebBindings; 56 using WebKit::WebBindings;
58 using WebKit::WebCursorInfo; 57 using WebKit::WebCursorInfo;
59 using WebKit::WebDragData; 58 using WebKit::WebDragData;
60 using WebKit::WebInputEvent; 59 using WebKit::WebInputEvent;
61 using WebKit::WebString; 60 using WebKit::WebString;
62 using WebKit::WebVector;
63 using WebKit::WebView; 61 using WebKit::WebView;
64 62
65 // Proxy for WebPluginResourceClient. The object owns itself after creation, 63 // Proxy for WebPluginResourceClient. The object owns itself after creation,
66 // deleting itself after its callback has been called. 64 // deleting itself after its callback has been called.
67 class ResourceClientProxy : public webkit::npapi::WebPluginResourceClient { 65 class ResourceClientProxy : public webkit::npapi::WebPluginResourceClient {
68 public: 66 public:
69 ResourceClientProxy(PluginChannelHost* channel, int instance_id) 67 ResourceClientProxy(PluginChannelHost* channel, int instance_id)
70 : channel_(channel), instance_id_(instance_id), resource_id_(0), 68 : channel_(channel), instance_id_(instance_id), resource_id_(0),
71 multibyte_response_expected_(false) { 69 multibyte_response_expected_(false) {
72 } 70 }
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 OnSetWindowlessPumpEvent) 439 OnSetWindowlessPumpEvent)
442 #endif 440 #endif
443 IPC_MESSAGE_HANDLER(PluginHostMsg_CancelResource, OnCancelResource) 441 IPC_MESSAGE_HANDLER(PluginHostMsg_CancelResource, OnCancelResource)
444 IPC_MESSAGE_HANDLER(PluginHostMsg_InvalidateRect, OnInvalidateRect) 442 IPC_MESSAGE_HANDLER(PluginHostMsg_InvalidateRect, OnInvalidateRect)
445 IPC_MESSAGE_HANDLER(PluginHostMsg_GetWindowScriptNPObject, 443 IPC_MESSAGE_HANDLER(PluginHostMsg_GetWindowScriptNPObject,
446 OnGetWindowScriptNPObject) 444 OnGetWindowScriptNPObject)
447 IPC_MESSAGE_HANDLER(PluginHostMsg_GetPluginElement, 445 IPC_MESSAGE_HANDLER(PluginHostMsg_GetPluginElement,
448 OnGetPluginElement) 446 OnGetPluginElement)
449 IPC_MESSAGE_HANDLER(PluginHostMsg_SetCookie, OnSetCookie) 447 IPC_MESSAGE_HANDLER(PluginHostMsg_SetCookie, OnSetCookie)
450 IPC_MESSAGE_HANDLER(PluginHostMsg_GetCookies, OnGetCookies) 448 IPC_MESSAGE_HANDLER(PluginHostMsg_GetCookies, OnGetCookies)
451 IPC_MESSAGE_HANDLER(PluginHostMsg_ShowModalHTMLDialog,
452 OnShowModalHTMLDialog)
453 IPC_MESSAGE_HANDLER(PluginHostMsg_GetDragData, OnGetDragData);
454 IPC_MESSAGE_HANDLER(PluginHostMsg_SetDropEffect, OnSetDropEffect);
455 IPC_MESSAGE_HANDLER(PluginHostMsg_MissingPluginStatus, 449 IPC_MESSAGE_HANDLER(PluginHostMsg_MissingPluginStatus,
456 OnMissingPluginStatus) 450 OnMissingPluginStatus)
457 IPC_MESSAGE_HANDLER(PluginHostMsg_URLRequest, OnHandleURLRequest) 451 IPC_MESSAGE_HANDLER(PluginHostMsg_URLRequest, OnHandleURLRequest)
458 IPC_MESSAGE_HANDLER(PluginHostMsg_GetCPBrowsingContext,
459 OnGetCPBrowsingContext)
460 IPC_MESSAGE_HANDLER(PluginHostMsg_CancelDocumentLoad, OnCancelDocumentLoad) 452 IPC_MESSAGE_HANDLER(PluginHostMsg_CancelDocumentLoad, OnCancelDocumentLoad)
461 IPC_MESSAGE_HANDLER(PluginHostMsg_InitiateHTTPRangeRequest, 453 IPC_MESSAGE_HANDLER(PluginHostMsg_InitiateHTTPRangeRequest,
462 OnInitiateHTTPRangeRequest) 454 OnInitiateHTTPRangeRequest)
463 IPC_MESSAGE_HANDLER(PluginHostMsg_DeferResourceLoading, 455 IPC_MESSAGE_HANDLER(PluginHostMsg_DeferResourceLoading,
464 OnDeferResourceLoading) 456 OnDeferResourceLoading)
465 457
466 #if defined(OS_MACOSX) 458 #if defined(OS_MACOSX)
467 IPC_MESSAGE_HANDLER(PluginHostMsg_FocusChanged, 459 IPC_MESSAGE_HANDLER(PluginHostMsg_FocusChanged,
468 OnFocusChanged); 460 OnFocusChanged);
469 IPC_MESSAGE_HANDLER(PluginHostMsg_StartIme, 461 IPC_MESSAGE_HANDLER(PluginHostMsg_StartIme,
(...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 } 1131 }
1140 1132
1141 void WebPluginDelegateProxy::OnGetCookies(const GURL& url, 1133 void WebPluginDelegateProxy::OnGetCookies(const GURL& url,
1142 const GURL& first_party_for_cookies, 1134 const GURL& first_party_for_cookies,
1143 std::string* cookies) { 1135 std::string* cookies) {
1144 DCHECK(cookies); 1136 DCHECK(cookies);
1145 if (plugin_) 1137 if (plugin_)
1146 *cookies = plugin_->GetCookies(url, first_party_for_cookies); 1138 *cookies = plugin_->GetCookies(url, first_party_for_cookies);
1147 } 1139 }
1148 1140
1149 void WebPluginDelegateProxy::OnShowModalHTMLDialog(
1150 const GURL& url, int width, int height, const std::string& json_arguments,
1151 std::string* json_retval) {
1152 DCHECK(json_retval);
1153 if (render_view_) {
1154 render_view_->ShowModalHTMLDialogForPlugin(
1155 url, gfx::Size(width, height), json_arguments, json_retval);
1156 }
1157 }
1158
1159 static void EncodeDragData(const WebDragData& data, bool add_data,
1160 NPVariant* drag_type, NPVariant* drag_data) {
1161 const NPString* np_drag_type;
1162 if (data.containsFilenames()) {
1163 static const NPString kFiles = { "Files", 5 };
1164 np_drag_type = &kFiles;
1165 } else {
1166 static const NPString kEmpty = { "" , 0 };
1167 np_drag_type = &kEmpty;
1168 add_data = false;
1169 }
1170
1171 STRINGN_TO_NPVARIANT(np_drag_type->UTF8Characters,
1172 np_drag_type->UTF8Length,
1173 *drag_type);
1174 if (!add_data) {
1175 VOID_TO_NPVARIANT(*drag_data);
1176 return;
1177 }
1178
1179 WebVector<WebString> files;
1180 data.filenames(files);
1181
1182 static std::string utf8;
1183 utf8.clear();
1184 for (size_t i = 0; i < files.size(); ++i) {
1185 static const char kBackspaceDelimiter('\b');
1186 if (i != 0)
1187 utf8.append(1, kBackspaceDelimiter);
1188 utf8.append(files[i].utf8());
1189 }
1190
1191 STRINGN_TO_NPVARIANT(utf8.data(), utf8.length(), *drag_data);
1192 }
1193
1194 void WebPluginDelegateProxy::OnGetDragData(const NPVariant_Param& object,
1195 bool add_data,
1196 std::vector<NPVariant_Param>* values,
1197 bool* success) {
1198 DCHECK(values && success);
1199 *success = false;
1200
1201 WebView* webview = NULL;
1202 if (render_view_)
1203 webview = render_view_->webview();
1204 if (!webview)
1205 return;
1206
1207 int event_id;
1208 WebDragData data;
1209
1210 DCHECK(object.type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID);
1211 NPObjectBase* npobject_base =
1212 channel_host_->GetNPObjectListenerForRoute(object.npobject_routing_id);
1213 if (!npobject_base) {
1214 DLOG(WARNING) << "Invalid routing id passed in"
1215 << object.npobject_routing_id;
1216 return;
1217 }
1218
1219 NPObject* event = npobject_base->GetUnderlyingNPObject();
1220 DCHECK(event != NULL);
1221
1222 const int32 drag_id = webview->dragIdentity();
1223 if (!drag_id || !WebBindings::getDragData(event, &event_id, &data))
1224 return;
1225
1226 NPVariant results[4];
1227 INT32_TO_NPVARIANT(drag_id, results[0]);
1228 INT32_TO_NPVARIANT(event_id, results[1]);
1229 EncodeDragData(data, add_data, &results[2], &results[3]);
1230
1231 for (size_t i = 0; i < arraysize(results); ++i) {
1232 values->push_back(NPVariant_Param());
1233 CreateNPVariantParam(
1234 results[i], NULL, &values->back(), false, 0, page_url_);
1235 }
1236
1237 *success = true;
1238 }
1239
1240 void WebPluginDelegateProxy::OnSetDropEffect(const NPVariant_Param& object,
1241 int effect,
1242 bool* success) {
1243 DCHECK(success);
1244 *success = false;
1245
1246 WebView* webview = NULL;
1247 if (render_view_)
1248 webview = render_view_->webview();
1249 if (!webview)
1250 return;
1251
1252 DCHECK(object.type == NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID);
1253 NPObjectBase* npobject_base =
1254 channel_host_->GetNPObjectListenerForRoute(object.npobject_routing_id);
1255 if (!npobject_base) {
1256 DLOG(WARNING) << "Invalid routing id passed in"
1257 << object.npobject_routing_id;
1258 return;
1259 }
1260
1261 NPObject* event = npobject_base->GetUnderlyingNPObject();
1262 DCHECK(event != NULL);
1263
1264 const int32 drag_id = webview->dragIdentity();
1265 if (!drag_id || !WebBindings::isDragEvent(event))
1266 return;
1267
1268 *success = webview->setDropEffect(effect != 0);
1269 }
1270
1271 void WebPluginDelegateProxy::OnMissingPluginStatus(int status) { 1141 void WebPluginDelegateProxy::OnMissingPluginStatus(int status) {
1272 if (render_view_) 1142 if (render_view_)
1273 render_view_->OnMissingPluginStatus(this, status); 1143 render_view_->OnMissingPluginStatus(this, status);
1274 } 1144 }
1275 1145
1276 void WebPluginDelegateProxy::OnGetCPBrowsingContext(uint32* context) {
1277 *context = render_view_ ? render_view_->GetCPBrowsingContext() : 0;
1278 }
1279
1280 void WebPluginDelegateProxy::PaintSadPlugin(WebKit::WebCanvas* native_context, 1146 void WebPluginDelegateProxy::PaintSadPlugin(WebKit::WebCanvas* native_context,
1281 const gfx::Rect& rect) { 1147 const gfx::Rect& rect) {
1282 // Lazily load the sad plugin image. 1148 // Lazily load the sad plugin image.
1283 if (!sad_plugin_) { 1149 if (!sad_plugin_) {
1284 sad_plugin_ = ResourceBundle::GetSharedInstance().GetBitmapNamed( 1150 sad_plugin_ = ResourceBundle::GetSharedInstance().GetBitmapNamed(
1285 IDR_SAD_PLUGIN); 1151 IDR_SAD_PLUGIN);
1286 } 1152 }
1287 if (!sad_plugin_) 1153 if (!sad_plugin_)
1288 return; 1154 return;
1289 1155
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 } 1445 }
1580 #endif 1446 #endif
1581 1447
1582 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, 1448 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow,
1583 int resource_id) { 1449 int resource_id) {
1584 if (!plugin_) 1450 if (!plugin_)
1585 return; 1451 return;
1586 1452
1587 plugin_->URLRedirectResponse(allow, resource_id); 1453 plugin_->URLRedirectResponse(allow, resource_id);
1588 } 1454 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698