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

Side by Side Diff: webkit/glue/webplugin_impl.cc

Issue 196012: This changelist fixes some issues with the NPAPI WMP plugin work in Chrome. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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
« no previous file with comments | « webkit/glue/webplugin_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 "base/gfx/rect.h" 5 #include "base/gfx/rect.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "net/base/escape.h" 9 #include "net/base/escape.h"
10 #include "skia/ext/platform_canvas.h" 10 #include "skia/ext/platform_canvas.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 WebString content_encoding = 190 WebString content_encoding =
191 response.httpHeaderField(WebString::fromUTF8("Content-Encoding")); 191 response.httpHeaderField(WebString::fromUTF8("Content-Encoding"));
192 if (!content_encoding.isNull() && 192 if (!content_encoding.isNull() &&
193 !EqualsASCII(content_encoding, "identity")) { 193 !EqualsASCII(content_encoding, "identity")) {
194 // Don't send the compressed content length to the plugin, which only 194 // Don't send the compressed content length to the plugin, which only
195 // cares about the decoded length. 195 // cares about the decoded length.
196 response_info->expected_length = 0; 196 response_info->expected_length = 0;
197 } 197 }
198 } 198 }
199 199
200 // Utility function to convert a vector to an array of char*'s.
201 // Caller is responsible to free memory with DeleteArray().
202 static char** ToArray(const WebVector<WebString>& input) {
203 char** array = new char*[input.size() + 1];
204 size_t index;
205 for (index = 0; index < input.size(); ++index) {
206 const WebCString& src = input[index].utf8();
207 array[index] = new char[src.length() + 1];
208 base::strlcpy(array[index], src.data(), src.length() + 1);
209 array[index][src.length()] = '\0';
210 }
211 array[index] = 0;
212 return array;
213 }
214
215 static void DeleteArray(char** array) {
216 char** ptr = array;
217 while (*ptr) {
218 delete[] *ptr;
219 ++ptr;
220 }
221 delete[] array;
222 }
223
224 } // namespace 200 } // namespace
225 201
226 // WebKit::WebPlugin ---------------------------------------------------------- 202 // WebKit::WebPlugin ----------------------------------------------------------
227 203
228 bool WebPluginImpl::initialize(WebPluginContainer* container) { 204 bool WebPluginImpl::initialize(WebPluginContainer* container) {
229 if (!page_delegate_) 205 if (!page_delegate_)
230 return false; 206 return false;
231 207
232 // Get the classid and version from attributes of the object. 208 // Get the classid and version from attributes of the object.
233 std::string combined_clsid; 209 std::string combined_clsid;
234 #if defined(OS_WIN) 210 #if defined(OS_WIN)
235 std::string clsid, version; 211 std::string clsid, version;
236 if (activex_shim::IsMimeTypeActiveX(mime_type_)) { 212 if (activex_shim::IsMimeTypeActiveX(mime_type_)) {
237 for (size_t i = 0; i < arg_count_; i++) { 213 for (size_t i = 0; i < arg_names_.size(); i++) {
238 const char* param_name = arg_names_[i]; 214 const char* param_name = arg_names_[i].c_str();
239 const char* param_value = arg_values_[i]; 215 const char* param_value = arg_values_[i].c_str();
240 if (base::strcasecmp(param_name, "classid") == 0) { 216 if (base::strcasecmp(param_name, "classid") == 0) {
241 activex_shim::GetClsidFromClassidAttribute(param_value, &clsid); 217 activex_shim::GetClsidFromClassidAttribute(param_value, &clsid);
242 } else if (base::strcasecmp(param_name, "codebase") == 0) { 218 } else if (base::strcasecmp(param_name, "codebase") == 0) {
243 version = activex_shim::GetVersionFromCodebaseAttribute(param_value); 219 version = activex_shim::GetVersionFromCodebaseAttribute(param_value);
244 } 220 }
245 } 221 }
246 222
247 // Attempt to map this clsid to a known NPAPI mime type if possible, failing 223 // Attempt to map this clsid to a known NPAPI mime type if possible, failing
248 // which we attempt to load the activex shim for the clsid. 224 // which we attempt to load the activex shim for the clsid.
249 if (!activex_shim::GetMimeTypeForClsid(clsid, &mime_type_)) { 225 if (!activex_shim::GetMimeTypeForClsid(clsid, &mime_type_)) {
250 // We need to pass the combined clsid + version to PluginsList, so that it 226 // We need to pass the combined clsid + version to PluginsList, so that it
251 // would detect if the requested version is installed. If not, it needs 227 // would detect if the requested version is installed. If not, it needs
252 // to use the default plugin to update the control. 228 // to use the default plugin to update the control.
253 if (!version.empty()) 229 if (!version.empty())
254 combined_clsid = clsid + "#" + version; 230 combined_clsid = clsid + "#" + version;
255 else 231 else
256 combined_clsid = clsid; 232 combined_clsid = clsid;
257 } 233 }
258 } 234 }
259 #endif 235 #endif
260 236
261 std::string actual_mime_type; 237 std::string actual_mime_type;
262 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( 238 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate(
263 plugin_url_, mime_type_, combined_clsid, &actual_mime_type); 239 plugin_url_, mime_type_, combined_clsid, &actual_mime_type);
264 if (!plugin_delegate) 240 if (!plugin_delegate)
265 return NULL; 241 return NULL;
266 242
267 bool ok = plugin_delegate->Initialize( 243 bool ok = plugin_delegate->Initialize(
268 plugin_url_, arg_names_, arg_values_, arg_count_, this, load_manually_); 244 plugin_url_, arg_names_, arg_values_, this, load_manually_);
269 if (!ok) { 245 if (!ok) {
270 plugin_delegate->PluginDestroyed(); 246 plugin_delegate->PluginDestroyed();
271 return false; 247 return false;
272 } 248 }
273 249
274 if (!actual_mime_type.empty()) 250 if (!actual_mime_type.empty())
275 mime_type_ = actual_mime_type; 251 mime_type_ = actual_mime_type;
276 delegate_ = plugin_delegate; 252 delegate_ = plugin_delegate;
277 253
278 SetContainer(container); 254 SetContainer(container);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 window_(NULL), 406 window_(NULL),
431 page_delegate_(page_delegate), 407 page_delegate_(page_delegate),
432 webframe_(webframe), 408 webframe_(webframe),
433 delegate_(NULL), 409 delegate_(NULL),
434 container_(NULL), 410 container_(NULL),
435 plugin_url_(params.url), 411 plugin_url_(params.url),
436 load_manually_(params.loadManually), 412 load_manually_(params.loadManually),
437 first_geometry_update_(true), 413 first_geometry_update_(true),
438 ignore_response_error_(false), 414 ignore_response_error_(false),
439 mime_type_(params.mimeType.utf8()), 415 mime_type_(params.mimeType.utf8()),
440 arg_names_(ToArray(params.attributeNames)),
441 arg_values_(ToArray(params.attributeValues)),
442 arg_count_(params.attributeNames.size()),
443 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { 416 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
444 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size()); 417 DCHECK_EQ(params.attributeNames.size(), params.attributeValues.size());
445 StringToLowerASCII(&mime_type_); 418 StringToLowerASCII(&mime_type_);
419
420 for (size_t i = 0; i < params.attributeNames.size(); ++i) {
421 arg_names_.push_back(params.attributeNames[i].utf8());
422 arg_values_.push_back(params.attributeValues[i].utf8());
423 }
446 } 424 }
447 425
448 WebPluginImpl::~WebPluginImpl() { 426 WebPluginImpl::~WebPluginImpl() {
449 if (arg_names_)
450 DeleteArray(arg_names_);
451 if (arg_values_)
452 DeleteArray(arg_values_);
453 } 427 }
454 428
455 void WebPluginImpl::SetWindow(gfx::PluginWindowHandle window) { 429 void WebPluginImpl::SetWindow(gfx::PluginWindowHandle window) {
456 if (window) { 430 if (window) {
457 DCHECK(!windowless_); // Make sure not called twice. 431 DCHECK(!windowless_); // Make sure not called twice.
458 window_ = window; 432 window_ = window;
459 if (page_delegate_) { 433 if (page_delegate_) {
460 // Tell the view delegate that the plugin window was created, so that it 434 // Tell the view delegate that the plugin window was created, so that it
461 // can create necessary container widgets. 435 // can create necessary container widgets.
462 page_delegate_->CreatedPluginWindow(window); 436 page_delegate_->CreatedPluginWindow(window);
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 TearDownPluginInstance(loader); 1020 TearDownPluginInstance(loader);
1047 1021
1048 container_ = container_widget; 1022 container_ = container_widget;
1049 webframe_ = webframe; 1023 webframe_ = webframe;
1050 1024
1051 std::string actual_mime_type; 1025 std::string actual_mime_type;
1052 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate( 1026 WebPluginDelegate* plugin_delegate = page_delegate_->CreatePluginDelegate(
1053 plugin_url_, mime_type_, std::string(), &actual_mime_type); 1027 plugin_url_, mime_type_, std::string(), &actual_mime_type);
1054 1028
1055 bool ok = plugin_delegate->Initialize( 1029 bool ok = plugin_delegate->Initialize(
1056 plugin_url_, arg_names_, arg_values_, arg_count_, this, load_manually_); 1030 plugin_url_, arg_names_, arg_values_, this, load_manually_);
1057 1031
1058 if (!ok) { 1032 if (!ok) {
1059 container_ = NULL; 1033 container_ = NULL;
1060 // TODO(iyengar) Should we delete the current plugin instance here? 1034 // TODO(iyengar) Should we delete the current plugin instance here?
1061 return false; 1035 return false;
1062 } 1036 }
1063 1037
1064 mime_type_ = actual_mime_type; 1038 mime_type_ = actual_mime_type;
1065 delegate_ = plugin_delegate; 1039 delegate_ = plugin_delegate;
1066 1040
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 client_index = clients_.erase(client_index); 1081 client_index = clients_.erase(client_index);
1108 } 1082 }
1109 1083
1110 // This needs to be called now and not in the destructor since the 1084 // This needs to be called now and not in the destructor since the
1111 // webframe_ might not be valid anymore. 1085 // webframe_ might not be valid anymore.
1112 webframe_ = NULL; 1086 webframe_ = NULL;
1113 method_factory_.RevokeAll(); 1087 method_factory_.RevokeAll();
1114 } 1088 }
1115 1089
1116 } // namespace webkit_glue 1090 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/webplugin_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698