| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/glue/plugins/webplugin_delegate_impl.h" | 5 #include "webkit/glue/plugins/webplugin_delegate_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 std::wstring::npos) { | 291 std::wstring::npos) { |
| 292 // VLC hangs on NPP_Destroy if we call NPP_SetWindow with a null window | 292 // VLC hangs on NPP_Destroy if we call NPP_SetWindow with a null window |
| 293 // handle | 293 // handle |
| 294 quirks_ |= PLUGIN_QUIRK_DONT_SET_NULL_WINDOW_HANDLE_ON_DESTROY; | 294 quirks_ |= PLUGIN_QUIRK_DONT_SET_NULL_WINDOW_HANDLE_ON_DESTROY; |
| 295 // VLC 0.8.6d and 0.8.6e crash if multiple instances are created. | 295 // VLC 0.8.6d and 0.8.6e crash if multiple instances are created. |
| 296 quirks_ |= PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES; | 296 quirks_ |= PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES; |
| 297 } else if (filename == kSilverlightPlugin) { | 297 } else if (filename == kSilverlightPlugin) { |
| 298 // Explanation for this quirk can be found in | 298 // Explanation for this quirk can be found in |
| 299 // WebPluginDelegateImpl::Initialize. | 299 // WebPluginDelegateImpl::Initialize. |
| 300 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR; | 300 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR; |
| 301 } else if (instance_->mime_type() == "application/x-nacl-srpc") { | |
| 302 // NaCl plugin runs in the sandbox - it cannot use the hwnd | |
| 303 quirks_ |= PLUGIN_QUIRK_DONT_CREATE_DUMMY_WINDOW; | |
| 304 } | 301 } |
| 305 } | 302 } |
| 306 | 303 |
| 307 WebPluginDelegateImpl::~WebPluginDelegateImpl() { | 304 WebPluginDelegateImpl::~WebPluginDelegateImpl() { |
| 308 if (::IsWindow(dummy_window_for_activation_)) { | 305 if (::IsWindow(dummy_window_for_activation_)) { |
| 309 ::DestroyWindow(dummy_window_for_activation_); | 306 ::DestroyWindow(dummy_window_for_activation_); |
| 310 } | 307 } |
| 311 | 308 |
| 312 DestroyInstance(); | 309 DestroyInstance(); |
| 313 | 310 |
| 314 if (!windowless_) | 311 if (!windowless_) |
| 315 WindowedDestroyWindow(); | 312 WindowedDestroyWindow(); |
| 316 | 313 |
| 317 if (handle_event_pump_messages_event_) { | 314 if (handle_event_pump_messages_event_) { |
| 318 CloseHandle(handle_event_pump_messages_event_); | 315 CloseHandle(handle_event_pump_messages_event_); |
| 319 } | 316 } |
| 320 } | 317 } |
| 321 | 318 |
| 322 void WebPluginDelegateImpl::PluginDestroyed() { | 319 void WebPluginDelegateImpl::PluginDestroyed() { |
| 323 if (handle_event_depth_) { | 320 if (handle_event_depth_) { |
| 324 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 321 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 325 } else { | 322 } else { |
| 326 delete this; | 323 delete this; |
| 327 } | 324 } |
| 328 } | 325 } |
| 329 | 326 |
| 330 void WebPluginDelegateImpl::PlatformInitialize() { | 327 void WebPluginDelegateImpl::PlatformInitialize() { |
| 331 plugin_->SetWindow(windowed_handle_); | 328 plugin_->SetWindow(windowed_handle_); |
| 332 | 329 if (windowless_) { |
| 333 if (windowless_ && !(quirks_ & PLUGIN_QUIRK_DONT_CREATE_DUMMY_WINDOW)) { | |
| 334 CreateDummyWindowForActivation(); | 330 CreateDummyWindowForActivation(); |
| 335 handle_event_pump_messages_event_ = CreateEvent(NULL, TRUE, FALSE, NULL); | 331 handle_event_pump_messages_event_ = CreateEvent(NULL, TRUE, FALSE, NULL); |
| 336 plugin_->SetWindowlessPumpEvent(handle_event_pump_messages_event_); | 332 plugin_->SetWindowlessPumpEvent(handle_event_pump_messages_event_); |
| 337 } | 333 } |
| 338 | 334 |
| 339 // We cannot patch internal plugins as they are not shared libraries. | 335 // Windowless plugins call the WindowFromPoint API and passes the result of |
| 340 if (!instance_->plugin_lib()->internal()) { | 336 // that to the TrackPopupMenu API call as the owner window. This causes the |
| 341 // Windowless plugins call the WindowFromPoint API and passes the result of | 337 // API to fail as the API expects the window handle to live on the same thread |
| 342 // that to the TrackPopupMenu API call as the owner window. This causes the | 338 // as the caller. It works in the other browsers as the plugin lives on the |
| 343 // API to fail as the API expects the window handle to live on the same | 339 // browser thread. Our workaround is to intercept the TrackPopupMenu API and |
| 344 // thread as the caller. It works in the other browsers as the plugin lives | 340 // replace the window handle with the dummy activation window. |
| 345 // on the browser thread. Our workaround is to intercept the TrackPopupMenu | 341 if (windowless_ && !g_iat_patch_track_popup_menu.Pointer()->is_patched()) { |
| 346 // API and replace the window handle with the dummy activation window. | 342 g_iat_patch_track_popup_menu.Pointer()->Patch( |
| 347 if (windowless_ && !g_iat_patch_track_popup_menu.Pointer()->is_patched()) { | 343 GetPluginPath().value().c_str(), "user32.dll", "TrackPopupMenu", |
| 348 g_iat_patch_track_popup_menu.Pointer()->Patch( | 344 WebPluginDelegateImpl::TrackPopupMenuPatch); |
| 349 GetPluginPath().value().c_str(), "user32.dll", "TrackPopupMenu", | 345 } |
| 350 WebPluginDelegateImpl::TrackPopupMenuPatch); | |
| 351 } | |
| 352 | 346 |
| 353 // Windowless plugins can set cursors by calling the SetCursor API. This | 347 // Windowless plugins can set cursors by calling the SetCursor API. This |
| 354 // works because the thread inputs of the browser UI thread and the plugin | 348 // works because the thread inputs of the browser UI thread and the plugin |
| 355 // thread are attached. We intercept the SetCursor API for windowless | 349 // thread are attached. We intercept the SetCursor API for windowless plugins |
| 356 // plugins and remember the cursor being set. This is shipped over to the | 350 // and remember the cursor being set. This is shipped over to the browser |
| 357 // browser in the HandleEvent call, which ensures that the cursor does not | 351 // in the HandleEvent call, which ensures that the cursor does not change |
| 358 // change when a windowless plugin instance changes the cursor | 352 // when a windowless plugin instance changes the cursor in a background tab. |
| 359 // in a background tab. | 353 if (windowless_ && !g_iat_patch_set_cursor.Pointer()->is_patched() && |
| 360 if (windowless_ && !g_iat_patch_set_cursor.Pointer()->is_patched() && | 354 (quirks_ & PLUGIN_QUIRK_PATCH_SETCURSOR)) { |
| 361 (quirks_ & PLUGIN_QUIRK_PATCH_SETCURSOR)) { | 355 g_iat_patch_set_cursor.Pointer()->Patch( |
| 362 g_iat_patch_set_cursor.Pointer()->Patch( | 356 GetPluginPath().value().c_str(), "user32.dll", "SetCursor", |
| 363 GetPluginPath().value().c_str(), "user32.dll", "SetCursor", | 357 WebPluginDelegateImpl::SetCursorPatch); |
| 364 WebPluginDelegateImpl::SetCursorPatch); | |
| 365 } | |
| 366 } | 358 } |
| 367 | 359 |
| 368 // On XP, WMP will use its old UI unless a registry key under HKLM has the | 360 // On XP, WMP will use its old UI unless a registry key under HKLM has the |
| 369 // name of the current process. We do it in the installer for admin users, | 361 // name of the current process. We do it in the installer for admin users, |
| 370 // for the rest patch this function. | 362 // for the rest patch this function. |
| 371 if ((quirks_ & PLUGIN_QUIRK_PATCH_REGENUMKEYEXW) && | 363 if ((quirks_ & PLUGIN_QUIRK_PATCH_REGENUMKEYEXW) && |
| 372 win_util::GetWinVersion() == win_util::WINVERSION_XP && | 364 win_util::GetWinVersion() == win_util::WINVERSION_XP && |
| 373 !RegKey().Open(HKEY_LOCAL_MACHINE, | 365 !RegKey().Open(HKEY_LOCAL_MACHINE, |
| 374 L"SOFTWARE\\Microsoft\\MediaPlayer\\ShimInclusionList\\chrome.exe") && | 366 L"SOFTWARE\\Microsoft\\MediaPlayer\\ShimInclusionList\\chrome.exe") && |
| 375 !g_iat_patch_reg_enum_key_ex_w.Pointer()->is_patched()) { | 367 !g_iat_patch_reg_enum_key_ex_w.Pointer()->is_patched()) { |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 GetKeyPath(key).find(L"Microsoft\\MediaPlayer\\ShimInclusionList") != | 1257 GetKeyPath(key).find(L"Microsoft\\MediaPlayer\\ShimInclusionList") != |
| 1266 std::wstring::npos) { | 1258 std::wstring::npos) { |
| 1267 static const wchar_t kChromeExeName[] = L"chrome.exe"; | 1259 static const wchar_t kChromeExeName[] = L"chrome.exe"; |
| 1268 wcsncpy_s(name, orig_size, kChromeExeName, arraysize(kChromeExeName)); | 1260 wcsncpy_s(name, orig_size, kChromeExeName, arraysize(kChromeExeName)); |
| 1269 *name_size = | 1261 *name_size = |
| 1270 std::min(orig_size, static_cast<DWORD>(arraysize(kChromeExeName))); | 1262 std::min(orig_size, static_cast<DWORD>(arraysize(kChromeExeName))); |
| 1271 } | 1263 } |
| 1272 | 1264 |
| 1273 return rv; | 1265 return rv; |
| 1274 } | 1266 } |
| OLD | NEW |