OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_ime_win.h" | 5 #include "content/child/npapi/webplugin_ime_win.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "webkit/plugins/npapi/plugin_constants_win.h" | 15 #include "content/child/npapi/plugin_instance.h" |
16 #include "webkit/plugins/npapi/plugin_instance.h" | 16 #include "content/common/plugin_constants_win.h" |
| 17 #include "webkit/plugins/npapi/plugin_utils.h" |
17 | 18 |
18 #pragma comment(lib, "imm32.lib") | 19 #pragma comment(lib, "imm32.lib") |
19 | 20 |
20 namespace webkit { | 21 namespace content { |
21 namespace npapi { | |
22 | 22 |
23 // A critical section that prevents two or more plug-ins from accessing a | 23 // A critical section that prevents two or more plug-ins from accessing a |
24 // WebPluginIMEWin instance through our patch function. | 24 // WebPluginIMEWin instance through our patch function. |
25 base::LazyInstance<base::Lock>::Leaky | 25 base::LazyInstance<base::Lock>::Leaky |
26 g_webplugin_ime_lock = LAZY_INSTANCE_INITIALIZER; | 26 g_webplugin_ime_lock = LAZY_INSTANCE_INITIALIZER; |
27 | 27 |
28 WebPluginIMEWin* WebPluginIMEWin::instance_ = NULL; | 28 WebPluginIMEWin* WebPluginIMEWin::instance_ = NULL; |
29 | 29 |
30 WebPluginIMEWin::WebPluginIMEWin() | 30 WebPluginIMEWin::WebPluginIMEWin() |
31 : cursor_position_(0), | 31 : cursor_position_(0), |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 HIMC WINAPI WebPluginIMEWin::ImmGetContext(HWND window) { | 266 HIMC WINAPI WebPluginIMEWin::ImmGetContext(HWND window) { |
267 // Call the original ImmGetContext() function if the given window is the one | 267 // Call the original ImmGetContext() function if the given window is the one |
268 // created in WebPluginDelegateImpl::WindowedCreatePlugin(). (We attached IME | 268 // created in WebPluginDelegateImpl::WindowedCreatePlugin(). (We attached IME |
269 // context only with the windows created in this function.) On the other hand, | 269 // context only with the windows created in this function.) On the other hand, |
270 // some windowless plug-ins (such as Flash) call this function with a dummy | 270 // some windowless plug-ins (such as Flash) call this function with a dummy |
271 // window handle. We return our dummy IME context for these plug-ins so they | 271 // window handle. We return our dummy IME context for these plug-ins so they |
272 // can use our IME emulator. | 272 // can use our IME emulator. |
273 if (IsWindow(window)) { | 273 if (IsWindow(window)) { |
274 wchar_t name[128]; | 274 wchar_t name[128]; |
275 GetClassName(window, &name[0], arraysize(name)); | 275 GetClassName(window, &name[0], arraysize(name)); |
276 if (!wcscmp(&name[0], kNativeWindowClassName)) | 276 if (!wcscmp(&name[0], webkit::npapi::kNativeWindowClassName)) |
277 return ::ImmGetContext(window); | 277 return ::ImmGetContext(window); |
278 } | 278 } |
279 | 279 |
280 WebPluginIMEWin* instance = instance_; | 280 WebPluginIMEWin* instance = instance_; |
281 if (instance) | 281 if (instance) |
282 instance->support_ime_messages_ = true; | 282 instance->support_ime_messages_ = true; |
283 return reinterpret_cast<HIMC>(instance); | 283 return reinterpret_cast<HIMC>(instance); |
284 } | 284 } |
285 | 285 |
286 // static | 286 // static |
(...skipping 27 matching lines...) Expand all Loading... |
314 | 314 |
315 int input_type = open ? 1 : 0; | 315 int input_type = open ? 1 : 0; |
316 if (instance->input_type_ != input_type) { | 316 if (instance->input_type_ != input_type) { |
317 instance->input_type_ = input_type; | 317 instance->input_type_ = input_type; |
318 instance->status_updated_ = true; | 318 instance->status_updated_ = true; |
319 } | 319 } |
320 | 320 |
321 return TRUE; | 321 return TRUE; |
322 } | 322 } |
323 | 323 |
324 } // namespace npapi | 324 } // namespace content |
325 } // namespace webkit | |
OLD | NEW |