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

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

Issue 7082034: Send IME events to windowless plug-ins (Chromium side) (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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
(...skipping 14 matching lines...) Expand all
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
26 #include "webkit/glue/webkit_glue.h" 26 #include "webkit/glue/webkit_glue.h"
27 #include "webkit/plugins/npapi/default_plugin_shared.h" 27 #include "webkit/plugins/npapi/default_plugin_shared.h"
28 #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" 29 #include "webkit/plugins/npapi/plugin_group.h"
30 #include "webkit/plugins/npapi/plugin_instance.h" 30 #include "webkit/plugins/npapi/plugin_instance.h"
31 #include "webkit/plugins/npapi/plugin_lib.h" 31 #include "webkit/plugins/npapi/plugin_lib.h"
32 #include "webkit/plugins/npapi/plugin_list.h" 32 #include "webkit/plugins/npapi/plugin_list.h"
33 #include "webkit/plugins/npapi/plugin_stream_url.h" 33 #include "webkit/plugins/npapi/plugin_stream_url.h"
34 #include "webkit/plugins/npapi/webplugin.h" 34 #include "webkit/plugins/npapi/webplugin.h"
35 #include "webkit/plugins/npapi/webplugin_ime_win.h"
35 36
36 using WebKit::WebCursorInfo; 37 using WebKit::WebCursorInfo;
37 using WebKit::WebKeyboardEvent; 38 using WebKit::WebKeyboardEvent;
38 using WebKit::WebInputEvent; 39 using WebKit::WebInputEvent;
39 using WebKit::WebMouseEvent; 40 using WebKit::WebMouseEvent;
40 41
41 namespace webkit { 42 namespace webkit {
42 namespace npapi { 43 namespace npapi {
43 44
44 namespace { 45 namespace {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 base::LINKER_INITIALIZED); 80 base::LINKER_INITIALIZED);
80 81
81 // Helper object for patching the SetCursor API. 82 // Helper object for patching the SetCursor API.
82 base::LazyInstance<base::win::IATPatchFunction> g_iat_patch_set_cursor( 83 base::LazyInstance<base::win::IATPatchFunction> g_iat_patch_set_cursor(
83 base::LINKER_INITIALIZED); 84 base::LINKER_INITIALIZED);
84 85
85 // Helper object for patching the RegEnumKeyExW API. 86 // Helper object for patching the RegEnumKeyExW API.
86 base::LazyInstance<base::win::IATPatchFunction> g_iat_patch_reg_enum_key_ex_w( 87 base::LazyInstance<base::win::IATPatchFunction> g_iat_patch_reg_enum_key_ex_w(
87 base::LINKER_INITIALIZED); 88 base::LINKER_INITIALIZED);
88 89
90 // Helper object for patching the GetProcAddress API.
91 base::LazyInstance<base::win::IATPatchFunction> g_iat_patch_get_proc_address(
92 base::LINKER_INITIALIZED);
93
89 // Helper object for patching the GetKeyState API. 94 // Helper object for patching the GetKeyState API.
90 base::LazyInstance<base::win::IATPatchFunction> g_iat_patch_get_key_state( 95 base::LazyInstance<base::win::IATPatchFunction> g_iat_patch_get_key_state(
91 base::LINKER_INITIALIZED); 96 base::LINKER_INITIALIZED);
92 97
93 // Saved key state globals and helper access functions. 98 // Saved key state globals and helper access functions.
94 SHORT (WINAPI *g_iat_orig_get_key_state)(int vkey); 99 SHORT (WINAPI *g_iat_orig_get_key_state)(int vkey);
95 typedef size_t SavedStateType; 100 typedef size_t SavedStateType;
96 const size_t kBitsPerType = sizeof(SavedStateType) * 8; 101 const size_t kBitsPerType = sizeof(SavedStateType) * 8;
97 // Bit array of key state corresponding to virtual key index (0=up, 1=down). 102 // Bit array of key state corresponding to virtual key index (0=up, 1=down).
98 SavedStateType g_saved_key_state[256 / kBitsPerType]; 103 SavedStateType g_saved_key_state[256 / kBitsPerType];
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 instance_->set_use_mozilla_user_agent(); 346 instance_->set_use_mozilla_user_agent();
342 quirks_ |= PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE; 347 quirks_ |= PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE;
343 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR; 348 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR;
344 quirks_ |= PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS; 349 quirks_ |= PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS;
345 quirks_ |= PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE; 350 quirks_ |= PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE;
346 if (filename == kBuiltinFlashPlugin && 351 if (filename == kBuiltinFlashPlugin &&
347 base::win::GetVersion() >= base::win::VERSION_VISTA) { 352 base::win::GetVersion() >= base::win::VERSION_VISTA) {
348 quirks_ |= PLUGIN_QUIRK_REPARENT_IN_BROWSER | 353 quirks_ |= PLUGIN_QUIRK_REPARENT_IN_BROWSER |
349 PLUGIN_QUIRK_PATCH_GETKEYSTATE; 354 PLUGIN_QUIRK_PATCH_GETKEYSTATE;
350 } 355 }
356 quirks_ |= PLUGIN_QUIRK_EMULATE_IME;
351 } else if (filename == kAcrobatReaderPlugin) { 357 } else if (filename == kAcrobatReaderPlugin) {
352 // Check for the version number above or equal 9. 358 // Check for the version number above or equal 9.
353 int major_version = GetPluginMajorVersion(plugin_info); 359 int major_version = GetPluginMajorVersion(plugin_info);
354 if (major_version >= 9) { 360 if (major_version >= 9) {
355 quirks_ |= PLUGIN_QUIRK_DIE_AFTER_UNLOAD; 361 quirks_ |= PLUGIN_QUIRK_DIE_AFTER_UNLOAD;
356 // 9.2 needs this. 362 // 9.2 needs this.
357 quirks_ |= PLUGIN_QUIRK_SETWINDOW_TWICE; 363 quirks_ |= PLUGIN_QUIRK_SETWINDOW_TWICE;
358 } 364 }
359 quirks_ |= PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS; 365 quirks_ |= PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS;
360 } else if (plugin_info.name.find(L"Windows Media Player") != 366 } else if (plugin_info.name.find(L"Windows Media Player") !=
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 base::win::GetVersion() == base::win::VERSION_XP && 487 base::win::GetVersion() == base::win::VERSION_XP &&
482 (base::win::RegKey().Open(HKEY_LOCAL_MACHINE, 488 (base::win::RegKey().Open(HKEY_LOCAL_MACHINE,
483 L"SOFTWARE\\Microsoft\\MediaPlayer\\ShimInclusionList\\chrome.exe", 489 L"SOFTWARE\\Microsoft\\MediaPlayer\\ShimInclusionList\\chrome.exe",
484 KEY_READ) != ERROR_SUCCESS) && 490 KEY_READ) != ERROR_SUCCESS) &&
485 !g_iat_patch_reg_enum_key_ex_w.Pointer()->is_patched()) { 491 !g_iat_patch_reg_enum_key_ex_w.Pointer()->is_patched()) {
486 g_iat_patch_reg_enum_key_ex_w.Pointer()->Patch( 492 g_iat_patch_reg_enum_key_ex_w.Pointer()->Patch(
487 L"wmpdxm.dll", "advapi32.dll", "RegEnumKeyExW", 493 L"wmpdxm.dll", "advapi32.dll", "RegEnumKeyExW",
488 WebPluginDelegateImpl::RegEnumKeyExWPatch); 494 WebPluginDelegateImpl::RegEnumKeyExWPatch);
489 } 495 }
490 496
497 // Flash retrieves the pointers to IMM32 functions with GetProcAddress() calls
498 // and use them to retrieve IME data. We add a patch to this function so we
499 // can dispatch these IMM32 calls to the WebPluginIMEWin class, which emulates
500 // IMM32 functions for Flash.
501 if (!g_iat_patch_get_proc_address.Pointer()->is_patched() &&
502 (quirks_ & PLUGIN_QUIRK_EMULATE_IME)) {
503 g_iat_patch_get_proc_address.Pointer()->Patch(
504 GetPluginPath().value().c_str(), "kernel32.dll", "GetProcAddress",
505 GetProcAddressPatch);
506 }
507
491 // Under UIPI the key state does not get forwarded properly to the child 508 // Under UIPI the key state does not get forwarded properly to the child
492 // plugin window. So, instead we track the key state manually and intercept 509 // plugin window. So, instead we track the key state manually and intercept
493 // GetKeyState. 510 // GetKeyState.
494 if ((quirks_ & PLUGIN_QUIRK_PATCH_GETKEYSTATE) && 511 if ((quirks_ & PLUGIN_QUIRK_PATCH_GETKEYSTATE) &&
495 !g_iat_patch_get_key_state.Pointer()->is_patched()) { 512 !g_iat_patch_get_key_state.Pointer()->is_patched()) {
496 g_iat_orig_get_key_state = ::GetKeyState; 513 g_iat_orig_get_key_state = ::GetKeyState;
497 g_iat_patch_get_key_state.Pointer()->Patch( 514 g_iat_patch_get_key_state.Pointer()->Patch(
498 L"gcswf32.dll", "user32.dll", "GetKeyState", 515 L"gcswf32.dll", "user32.dll", "GetKeyState",
499 WebPluginDelegateImpl::GetKeyStatePatch); 516 WebPluginDelegateImpl::GetKeyStatePatch);
500 } 517 }
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 std::wstring::npos) { 1492 std::wstring::npos) {
1476 static const wchar_t kChromeExeName[] = L"chrome.exe"; 1493 static const wchar_t kChromeExeName[] = L"chrome.exe";
1477 wcsncpy_s(name, orig_size, kChromeExeName, arraysize(kChromeExeName)); 1494 wcsncpy_s(name, orig_size, kChromeExeName, arraysize(kChromeExeName));
1478 *name_size = 1495 *name_size =
1479 std::min(orig_size, static_cast<DWORD>(arraysize(kChromeExeName))); 1496 std::min(orig_size, static_cast<DWORD>(arraysize(kChromeExeName)));
1480 } 1497 }
1481 1498
1482 return rv; 1499 return rv;
1483 } 1500 }
1484 1501
1502 void WebPluginDelegateImpl::ImeCompositionUpdated(
1503 const string16& text,
1504 const std::vector<int>& clauses,
1505 const std::vector<int>& target,
1506 int cursor_position) {
1507 if (!plugin_ime_.get())
1508 plugin_ime_.reset(new WebPluginIMEWin);
1509
1510 plugin_ime_->CompositionUpdated(text, clauses, target, cursor_position);
1511 plugin_ime_->SendEvents(instance());
1512 }
1513
1514 void WebPluginDelegateImpl::ImeCompositionCompleted(const string16& text) {
1515 if (!plugin_ime_.get())
1516 plugin_ime_.reset(new WebPluginIMEWin);
1517 plugin_ime_->CompositionCompleted(text);
1518 plugin_ime_->SendEvents(instance());
1519 }
1520
1521 bool WebPluginDelegateImpl::GetIMEStatus(int* input_type,
1522 gfx::Rect* caret_rect) {
1523 if (!plugin_ime_.get())
1524 return false;
1525 return plugin_ime_->GetStatus(input_type, caret_rect);
1526 }
1527
1528 // static
1529 FARPROC WINAPI WebPluginDelegateImpl::GetProcAddressPatch(HMODULE module,
1530 LPCSTR name) {
1531 FARPROC imm_function = WebPluginIMEWin::GetProcAddress(name);
1532 if (imm_function)
1533 return imm_function;
1534 return ::GetProcAddress(module, name);
1535 }
1536
1485 void WebPluginDelegateImpl::HandleCaptureForMessage(HWND window, 1537 void WebPluginDelegateImpl::HandleCaptureForMessage(HWND window,
1486 UINT message) { 1538 UINT message) {
1487 if (!WebPluginDelegateImpl::IsPluginDelegateWindow(window)) 1539 if (!WebPluginDelegateImpl::IsPluginDelegateWindow(window))
1488 return; 1540 return;
1489 1541
1490 switch (message) { 1542 switch (message) {
1491 case WM_LBUTTONDOWN: 1543 case WM_LBUTTONDOWN:
1492 case WM_MBUTTONDOWN: 1544 case WM_MBUTTONDOWN:
1493 case WM_RBUTTONDOWN: 1545 case WM_RBUTTONDOWN:
1494 ::SetCapture(window); 1546 ::SetCapture(window);
(...skipping 11 matching lines...) Expand all
1506 ::ReleaseCapture(); 1558 ::ReleaseCapture();
1507 break; 1559 break;
1508 1560
1509 default: 1561 default:
1510 break; 1562 break;
1511 } 1563 }
1512 } 1564 }
1513 1565
1514 } // namespace npapi 1566 } // namespace npapi
1515 } // namespace webkit 1567 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/npapi/webplugin_delegate_impl.h ('k') | webkit/plugins/npapi/webplugin_ime_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698