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

Side by Side Diff: webkit/plugins/npapi/webplugin_delegate_impl_win.cc

Issue 6373010: Allow multiple instances of the newer VLC plugins to load. The older versions... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 | « no previous file | 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) 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 "webkit/plugins/npapi/webplugin_delegate_impl.h" 5 #include "webkit/plugins/npapi/webplugin_delegate_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "app/win/iat_patch_function.h" 11 #include "app/win/iat_patch_function.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/lazy_instance.h" 13 #include "base/lazy_instance.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/metrics/stats_counters.h" 15 #include "base/metrics/stats_counters.h"
16 #include "base/scoped_ptr.h" 16 #include "base/scoped_ptr.h"
17 #include "base/string_number_conversions.h" 17 #include "base/string_number_conversions.h"
18 #include "base/string_split.h" 18 #include "base/string_split.h"
19 #include "base/string_util.h" 19 #include "base/string_util.h"
20 #include "base/stringprintf.h" 20 #include "base/stringprintf.h"
21 #include "base/version.h"
21 #include "base/win/registry.h" 22 #include "base/win/registry.h"
22 #include "base/win/windows_version.h" 23 #include "base/win/windows_version.h"
23 #include "skia/ext/platform_canvas.h" 24 #include "skia/ext/platform_canvas.h"
24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
25 #include "webkit/glue/webkit_glue.h" 26 #include "webkit/glue/webkit_glue.h"
26 #include "webkit/plugins/npapi/default_plugin_shared.h" 27 #include "webkit/plugins/npapi/default_plugin_shared.h"
27 #include "webkit/plugins/npapi/plugin_constants_win.h" 28 #include "webkit/plugins/npapi/plugin_constants_win.h"
29 #include "webkit/plugins/npapi/plugin_group.h"
28 #include "webkit/plugins/npapi/plugin_instance.h" 30 #include "webkit/plugins/npapi/plugin_instance.h"
29 #include "webkit/plugins/npapi/plugin_lib.h" 31 #include "webkit/plugins/npapi/plugin_lib.h"
30 #include "webkit/plugins/npapi/plugin_list.h" 32 #include "webkit/plugins/npapi/plugin_list.h"
31 #include "webkit/plugins/npapi/plugin_stream_url.h" 33 #include "webkit/plugins/npapi/plugin_stream_url.h"
32 #include "webkit/plugins/npapi/webplugin.h" 34 #include "webkit/plugins/npapi/webplugin.h"
33 35
34 using WebKit::WebCursorInfo; 36 using WebKit::WebCursorInfo;
35 using WebKit::WebKeyboardEvent; 37 using WebKit::WebKeyboardEvent;
36 using WebKit::WebInputEvent; 38 using WebKit::WebInputEvent;
37 using WebKit::WebMouseEvent; 39 using WebKit::WebMouseEvent;
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 176
175 result = func(key, KeyNameInformation, buffer.get(), size, &size); 177 result = func(key, KeyNameInformation, buffer.get(), size, &size);
176 if (result != STATUS_SUCCESS) 178 if (result != STATUS_SUCCESS)
177 return L""; 179 return L"";
178 180
179 KEY_NAME_INFORMATION* info = 181 KEY_NAME_INFORMATION* info =
180 reinterpret_cast<KEY_NAME_INFORMATION*>(buffer.get()); 182 reinterpret_cast<KEY_NAME_INFORMATION*>(buffer.get());
181 return std::wstring(info->Name, info->NameLength / sizeof(wchar_t)); 183 return std::wstring(info->Name, info->NameLength / sizeof(wchar_t));
182 } 184 }
183 185
186 int GetPluginMajorVersion(const WebPluginInfo& plugin_info) {
187 scoped_ptr<Version> plugin_version(PluginGroup::CreateVersionFromString(
188 plugin_info.version));
189 int major_version = 0;
190 if (plugin_version.get()) {
191 major_version = plugin_version->components()[0];
192 }
193 return major_version;
194 }
195
184 } // namespace 196 } // namespace
185 197
186 bool WebPluginDelegateImpl::IsPluginDelegateWindow(HWND window) { 198 bool WebPluginDelegateImpl::IsPluginDelegateWindow(HWND window) {
187 static const int kBufLen = 64; 199 static const int kBufLen = 64;
188 wchar_t class_name[kBufLen]; 200 wchar_t class_name[kBufLen];
189 if (!GetClassNameW(window, class_name, kBufLen)) 201 if (!GetClassNameW(window, class_name, kBufLen))
190 return false; 202 return false;
191 return wcscmp(class_name, kNativeWindowClassName) == 0; 203 return wcscmp(class_name, kNativeWindowClassName) == 0;
192 } 204 }
193 205
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 filename == kFlashPlugin) { 295 filename == kFlashPlugin) {
284 // Flash only requests windowless plugins if we return a Mozilla user 296 // Flash only requests windowless plugins if we return a Mozilla user
285 // agent. 297 // agent.
286 instance_->set_use_mozilla_user_agent(); 298 instance_->set_use_mozilla_user_agent();
287 quirks_ |= PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE; 299 quirks_ |= PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE;
288 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR; 300 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR;
289 quirks_ |= PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS; 301 quirks_ |= PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS;
290 quirks_ |= PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE; 302 quirks_ |= PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE;
291 } else if (filename == kAcrobatReaderPlugin) { 303 } else if (filename == kAcrobatReaderPlugin) {
292 // Check for the version number above or equal 9. 304 // Check for the version number above or equal 9.
293 std::vector<std::wstring> version; 305 int major_version = GetPluginMajorVersion(plugin_info);
294 base::SplitString(plugin_info.version, L'.', &version); 306 if (major_version >= 9) {
295 if (version.size() > 0) { 307 quirks_ |= PLUGIN_QUIRK_DIE_AFTER_UNLOAD;
296 int major; 308 // 9.2 needs this.
297 base::StringToInt(version[0], &major); 309 quirks_ |= PLUGIN_QUIRK_SETWINDOW_TWICE;
298 if (major >= 9) {
299 quirks_ |= PLUGIN_QUIRK_DIE_AFTER_UNLOAD;
300
301 // 9.2 needs this.
302 quirks_ |= PLUGIN_QUIRK_SETWINDOW_TWICE;
303 }
304 } 310 }
305 quirks_ |= PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS; 311 quirks_ |= PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS;
306 } else if (plugin_info.name.find(L"Windows Media Player") != 312 } else if (plugin_info.name.find(L"Windows Media Player") !=
307 std::wstring::npos) { 313 std::wstring::npos) {
308 // Windows Media Player needs two NPP_SetWindow calls. 314 // Windows Media Player needs two NPP_SetWindow calls.
309 quirks_ |= PLUGIN_QUIRK_SETWINDOW_TWICE; 315 quirks_ |= PLUGIN_QUIRK_SETWINDOW_TWICE;
310 316
311 // Windowless mode doesn't work in the WMP NPAPI plugin. 317 // Windowless mode doesn't work in the WMP NPAPI plugin.
312 quirks_ |= PLUGIN_QUIRK_NO_WINDOWLESS; 318 quirks_ |= PLUGIN_QUIRK_NO_WINDOWLESS;
313 319
314 // The media player plugin sets its size on the first NPP_SetWindow call 320 // The media player plugin sets its size on the first NPP_SetWindow call
315 // and never updates its size. We should call the underlying NPP_SetWindow 321 // and never updates its size. We should call the underlying NPP_SetWindow
316 // only when we have the correct size. 322 // only when we have the correct size.
317 quirks_ |= PLUGIN_QUIRK_IGNORE_FIRST_SETWINDOW_CALL; 323 quirks_ |= PLUGIN_QUIRK_IGNORE_FIRST_SETWINDOW_CALL;
318 324
319 if (filename == kOldWMPPlugin) { 325 if (filename == kOldWMPPlugin) {
320 // Non-admin users on XP couldn't modify the key to force the new UI. 326 // Non-admin users on XP couldn't modify the key to force the new UI.
321 quirks_ |= PLUGIN_QUIRK_PATCH_REGENUMKEYEXW; 327 quirks_ |= PLUGIN_QUIRK_PATCH_REGENUMKEYEXW;
322 } 328 }
323 } else if (instance_->mime_type() == "audio/x-pn-realaudio-plugin" || 329 } else if (instance_->mime_type() == "audio/x-pn-realaudio-plugin" ||
324 filename == kRealPlayerPlugin) { 330 filename == kRealPlayerPlugin) {
325 quirks_ |= PLUGIN_QUIRK_DONT_CALL_WND_PROC_RECURSIVELY; 331 quirks_ |= PLUGIN_QUIRK_DONT_CALL_WND_PROC_RECURSIVELY;
326 } else if (plugin_info.name.find(L"VLC Multimedia Plugin") != 332 } else if (plugin_info.name.find(L"VLC Multimedia Plugin") !=
327 std::wstring::npos || 333 std::wstring::npos ||
328 plugin_info.name.find(L"VLC Multimedia Plug-in") != 334 plugin_info.name.find(L"VLC Multimedia Plug-in") !=
329 std::wstring::npos) { 335 std::wstring::npos) {
330 // VLC hangs on NPP_Destroy if we call NPP_SetWindow with a null window 336 // VLC hangs on NPP_Destroy if we call NPP_SetWindow with a null window
331 // handle 337 // handle
332 quirks_ |= PLUGIN_QUIRK_DONT_SET_NULL_WINDOW_HANDLE_ON_DESTROY; 338 quirks_ |= PLUGIN_QUIRK_DONT_SET_NULL_WINDOW_HANDLE_ON_DESTROY;
333 // VLC 0.8.6d and 0.8.6e crash if multiple instances are created. 339 int major_version = GetPluginMajorVersion(plugin_info);
334 quirks_ |= PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES; 340 if (major_version == 0) {
341 // VLC 0.8.6d and 0.8.6e crash if multiple instances are created.
342 quirks_ |= PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES;
343 }
335 } else if (filename == kSilverlightPlugin) { 344 } else if (filename == kSilverlightPlugin) {
336 // Explanation for this quirk can be found in 345 // Explanation for this quirk can be found in
337 // WebPluginDelegateImpl::Initialize. 346 // WebPluginDelegateImpl::Initialize.
338 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR; 347 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR;
339 } else if (plugin_info.name.find(L"DivX Web Player") != 348 } else if (plugin_info.name.find(L"DivX Web Player") !=
340 std::wstring::npos) { 349 std::wstring::npos) {
341 // The divx plugin sets its size on the first NPP_SetWindow call and never 350 // The divx plugin sets its size on the first NPP_SetWindow call and never
342 // updates its size. We should call the underlying NPP_SetWindow only when 351 // updates its size. We should call the underlying NPP_SetWindow only when
343 // we have the correct size. 352 // we have the correct size.
344 quirks_ |= PLUGIN_QUIRK_IGNORE_FIRST_SETWINDOW_CALL; 353 quirks_ |= PLUGIN_QUIRK_IGNORE_FIRST_SETWINDOW_CALL;
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 ::ReleaseCapture(); 1414 ::ReleaseCapture();
1406 break; 1415 break;
1407 1416
1408 default: 1417 default:
1409 break; 1418 break;
1410 } 1419 }
1411 } 1420 }
1412 1421
1413 } // namespace npapi 1422 } // namespace npapi
1414 } // namespace webkit 1423 } // namespace webkit
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698