| 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 void WebPluginDelegateImpl::PluginDestroyed() { | 319 void WebPluginDelegateImpl::PluginDestroyed() { |
| 320 if (handle_event_depth_) { | 320 if (handle_event_depth_) { |
| 321 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 321 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 322 } else { | 322 } else { |
| 323 delete this; | 323 delete this; |
| 324 } | 324 } |
| 325 } | 325 } |
| 326 | 326 |
| 327 void WebPluginDelegateImpl::PlatformInitialize() { | 327 void WebPluginDelegateImpl::PlatformInitialize() { |
| 328 plugin_->SetWindow(windowed_handle_); | 328 plugin_->SetWindow(windowed_handle_); |
| 329 if (windowless_) { | 329 |
| 330 if (windowless_ && !instance_->plugin_lib()->internal()) { |
| 330 CreateDummyWindowForActivation(); | 331 CreateDummyWindowForActivation(); |
| 331 handle_event_pump_messages_event_ = CreateEvent(NULL, TRUE, FALSE, NULL); | 332 handle_event_pump_messages_event_ = CreateEvent(NULL, TRUE, FALSE, NULL); |
| 332 plugin_->SetWindowlessPumpEvent(handle_event_pump_messages_event_); | 333 plugin_->SetWindowlessPumpEvent(handle_event_pump_messages_event_); |
| 333 } | 334 } |
| 334 | 335 |
| 335 // Windowless plugins call the WindowFromPoint API and passes the result of | 336 // We cannot patch internal plugins as they are not shared libraries. |
| 336 // that to the TrackPopupMenu API call as the owner window. This causes the | 337 if (!instance_->plugin_lib()->internal()) { |
| 337 // API to fail as the API expects the window handle to live on the same thread | 338 // Windowless plugins call the WindowFromPoint API and passes the result of |
| 338 // as the caller. It works in the other browsers as the plugin lives on the | 339 // that to the TrackPopupMenu API call as the owner window. This causes the |
| 339 // browser thread. Our workaround is to intercept the TrackPopupMenu API and | 340 // API to fail as the API expects the window handle to live on the same |
| 340 // replace the window handle with the dummy activation window. | 341 // thread as the caller. It works in the other browsers as the plugin lives |
| 341 if (windowless_ && !g_iat_patch_track_popup_menu.Pointer()->is_patched()) { | 342 // on the browser thread. Our workaround is to intercept the TrackPopupMenu |
| 342 g_iat_patch_track_popup_menu.Pointer()->Patch( | 343 // API and replace the window handle with the dummy activation window. |
| 343 GetPluginPath().value().c_str(), "user32.dll", "TrackPopupMenu", | 344 if (windowless_ && !g_iat_patch_track_popup_menu.Pointer()->is_patched()) { |
| 344 WebPluginDelegateImpl::TrackPopupMenuPatch); | 345 g_iat_patch_track_popup_menu.Pointer()->Patch( |
| 345 } | 346 GetPluginPath().value().c_str(), "user32.dll", "TrackPopupMenu", |
| 347 WebPluginDelegateImpl::TrackPopupMenuPatch); |
| 348 } |
| 346 | 349 |
| 347 // Windowless plugins can set cursors by calling the SetCursor API. This | 350 // Windowless plugins can set cursors by calling the SetCursor API. This |
| 348 // works because the thread inputs of the browser UI thread and the plugin | 351 // works because the thread inputs of the browser UI thread and the plugin |
| 349 // thread are attached. We intercept the SetCursor API for windowless plugins | 352 // thread are attached. We intercept the SetCursor API for windowless |
| 350 // and remember the cursor being set. This is shipped over to the browser | 353 // plugins and remember the cursor being set. This is shipped over to the |
| 351 // in the HandleEvent call, which ensures that the cursor does not change | 354 // browser in the HandleEvent call, which ensures that the cursor does not |
| 352 // when a windowless plugin instance changes the cursor in a background tab. | 355 // change when a windowless plugin instance changes the cursor |
| 353 if (windowless_ && !g_iat_patch_set_cursor.Pointer()->is_patched() && | 356 // in a background tab. |
| 354 (quirks_ & PLUGIN_QUIRK_PATCH_SETCURSOR)) { | 357 if (windowless_ && !g_iat_patch_set_cursor.Pointer()->is_patched() && |
| 355 g_iat_patch_set_cursor.Pointer()->Patch( | 358 (quirks_ & PLUGIN_QUIRK_PATCH_SETCURSOR)) { |
| 356 GetPluginPath().value().c_str(), "user32.dll", "SetCursor", | 359 g_iat_patch_set_cursor.Pointer()->Patch( |
| 357 WebPluginDelegateImpl::SetCursorPatch); | 360 GetPluginPath().value().c_str(), "user32.dll", "SetCursor", |
| 361 WebPluginDelegateImpl::SetCursorPatch); |
| 362 } |
| 358 } | 363 } |
| 359 | 364 |
| 360 // On XP, WMP will use its old UI unless a registry key under HKLM has the | 365 // On XP, WMP will use its old UI unless a registry key under HKLM has the |
| 361 // name of the current process. We do it in the installer for admin users, | 366 // name of the current process. We do it in the installer for admin users, |
| 362 // for the rest patch this function. | 367 // for the rest patch this function. |
| 363 if ((quirks_ & PLUGIN_QUIRK_PATCH_REGENUMKEYEXW) && | 368 if ((quirks_ & PLUGIN_QUIRK_PATCH_REGENUMKEYEXW) && |
| 364 win_util::GetWinVersion() == win_util::WINVERSION_XP && | 369 win_util::GetWinVersion() == win_util::WINVERSION_XP && |
| 365 !RegKey().Open(HKEY_LOCAL_MACHINE, | 370 !RegKey().Open(HKEY_LOCAL_MACHINE, |
| 366 L"SOFTWARE\\Microsoft\\MediaPlayer\\ShimInclusionList\\chrome.exe") && | 371 L"SOFTWARE\\Microsoft\\MediaPlayer\\ShimInclusionList\\chrome.exe") && |
| 367 !g_iat_patch_reg_enum_key_ex_w.Pointer()->is_patched()) { | 372 !g_iat_patch_reg_enum_key_ex_w.Pointer()->is_patched()) { |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 GetKeyPath(key).find(L"Microsoft\\MediaPlayer\\ShimInclusionList") != | 1262 GetKeyPath(key).find(L"Microsoft\\MediaPlayer\\ShimInclusionList") != |
| 1258 std::wstring::npos) { | 1263 std::wstring::npos) { |
| 1259 static const wchar_t kChromeExeName[] = L"chrome.exe"; | 1264 static const wchar_t kChromeExeName[] = L"chrome.exe"; |
| 1260 wcsncpy_s(name, orig_size, kChromeExeName, arraysize(kChromeExeName)); | 1265 wcsncpy_s(name, orig_size, kChromeExeName, arraysize(kChromeExeName)); |
| 1261 *name_size = | 1266 *name_size = |
| 1262 std::min(orig_size, static_cast<DWORD>(arraysize(kChromeExeName))); | 1267 std::min(orig_size, static_cast<DWORD>(arraysize(kChromeExeName))); |
| 1263 } | 1268 } |
| 1264 | 1269 |
| 1265 return rv; | 1270 return rv; |
| 1266 } | 1271 } |
| OLD | NEW |