| 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 | 329 if (windowless_) { |
| 330 if (windowless_ && !instance_->plugin_lib()->internal()) { | |
| 331 CreateDummyWindowForActivation(); | 330 CreateDummyWindowForActivation(); |
| 332 handle_event_pump_messages_event_ = CreateEvent(NULL, TRUE, FALSE, NULL); | 331 handle_event_pump_messages_event_ = CreateEvent(NULL, TRUE, FALSE, NULL); |
| 333 plugin_->SetWindowlessPumpEvent(handle_event_pump_messages_event_); | 332 plugin_->SetWindowlessPumpEvent(handle_event_pump_messages_event_); |
| 334 } | 333 } |
| 335 | 334 |
| 336 // We cannot patch internal plugins as they are not shared libraries. | 335 // Windowless plugins call the WindowFromPoint API and passes the result of |
| 337 if (!instance_->plugin_lib()->internal()) { | 336 // that to the TrackPopupMenu API call as the owner window. This causes the |
| 338 // 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 |
| 339 // 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 |
| 340 // 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 |
| 341 // thread as the caller. It works in the other browsers as the plugin lives | 340 // replace the window handle with the dummy activation window. |
| 342 // on the browser thread. Our workaround is to intercept the TrackPopupMenu | 341 if (windowless_ && !g_iat_patch_track_popup_menu.Pointer()->is_patched()) { |
| 343 // API and replace the window handle with the dummy activation window. | 342 g_iat_patch_track_popup_menu.Pointer()->Patch( |
| 344 if (windowless_ && !g_iat_patch_track_popup_menu.Pointer()->is_patched()) { | 343 GetPluginPath().value().c_str(), "user32.dll", "TrackPopupMenu", |
| 345 g_iat_patch_track_popup_menu.Pointer()->Patch( | 344 WebPluginDelegateImpl::TrackPopupMenuPatch); |
| 346 GetPluginPath().value().c_str(), "user32.dll", "TrackPopupMenu", | 345 } |
| 347 WebPluginDelegateImpl::TrackPopupMenuPatch); | |
| 348 } | |
| 349 | 346 |
| 350 // Windowless plugins can set cursors by calling the SetCursor API. This | 347 // Windowless plugins can set cursors by calling the SetCursor API. This |
| 351 // 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 |
| 352 // thread are attached. We intercept the SetCursor API for windowless | 349 // thread are attached. We intercept the SetCursor API for windowless plugins |
| 353 // 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 |
| 354 // 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 |
| 355 // change when a windowless plugin instance changes the cursor | 352 // when a windowless plugin instance changes the cursor in a background tab. |
| 356 // in a background tab. | 353 if (windowless_ && !g_iat_patch_set_cursor.Pointer()->is_patched() && |
| 357 if (windowless_ && !g_iat_patch_set_cursor.Pointer()->is_patched() && | 354 (quirks_ & PLUGIN_QUIRK_PATCH_SETCURSOR)) { |
| 358 (quirks_ & PLUGIN_QUIRK_PATCH_SETCURSOR)) { | 355 g_iat_patch_set_cursor.Pointer()->Patch( |
| 359 g_iat_patch_set_cursor.Pointer()->Patch( | 356 GetPluginPath().value().c_str(), "user32.dll", "SetCursor", |
| 360 GetPluginPath().value().c_str(), "user32.dll", "SetCursor", | 357 WebPluginDelegateImpl::SetCursorPatch); |
| 361 WebPluginDelegateImpl::SetCursorPatch); | |
| 362 } | |
| 363 } | 358 } |
| 364 | 359 |
| 365 // 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 |
| 366 // 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, |
| 367 // for the rest patch this function. | 362 // for the rest patch this function. |
| 368 if ((quirks_ & PLUGIN_QUIRK_PATCH_REGENUMKEYEXW) && | 363 if ((quirks_ & PLUGIN_QUIRK_PATCH_REGENUMKEYEXW) && |
| 369 win_util::GetWinVersion() == win_util::WINVERSION_XP && | 364 win_util::GetWinVersion() == win_util::WINVERSION_XP && |
| 370 !RegKey().Open(HKEY_LOCAL_MACHINE, | 365 !RegKey().Open(HKEY_LOCAL_MACHINE, |
| 371 L"SOFTWARE\\Microsoft\\MediaPlayer\\ShimInclusionList\\chrome.exe") && | 366 L"SOFTWARE\\Microsoft\\MediaPlayer\\ShimInclusionList\\chrome.exe") && |
| 372 !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... |
| 1262 GetKeyPath(key).find(L"Microsoft\\MediaPlayer\\ShimInclusionList") != | 1257 GetKeyPath(key).find(L"Microsoft\\MediaPlayer\\ShimInclusionList") != |
| 1263 std::wstring::npos) { | 1258 std::wstring::npos) { |
| 1264 static const wchar_t kChromeExeName[] = L"chrome.exe"; | 1259 static const wchar_t kChromeExeName[] = L"chrome.exe"; |
| 1265 wcsncpy_s(name, orig_size, kChromeExeName, arraysize(kChromeExeName)); | 1260 wcsncpy_s(name, orig_size, kChromeExeName, arraysize(kChromeExeName)); |
| 1266 *name_size = | 1261 *name_size = |
| 1267 std::min(orig_size, static_cast<DWORD>(arraysize(kChromeExeName))); | 1262 std::min(orig_size, static_cast<DWORD>(arraysize(kChromeExeName))); |
| 1268 } | 1263 } |
| 1269 | 1264 |
| 1270 return rv; | 1265 return rv; |
| 1271 } | 1266 } |
| OLD | NEW |