| 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 "content/child/npapi/webplugin_ime_win.h" | 5 #include "content/child/npapi/webplugin_ime_win.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <cstring> | 10 #include <cstring> |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 return IMM_ERROR_NODATA; | 260 return IMM_ERROR_NODATA; |
| 261 | 261 |
| 262 if (dst_size >= src_size) | 262 if (dst_size >= src_size) |
| 263 memcpy(dst_data, src_data, src_size); | 263 memcpy(dst_data, src_data, src_size); |
| 264 | 264 |
| 265 return src_size; | 265 return src_size; |
| 266 } | 266 } |
| 267 | 267 |
| 268 // static | 268 // static |
| 269 HIMC WINAPI WebPluginIMEWin::ImmGetContext(HWND window) { | 269 HIMC WINAPI WebPluginIMEWin::ImmGetContext(HWND window) { |
| 270 // Call the original ImmGetContext() function if the given window is the one | |
| 271 // created in WebPluginDelegateImpl::WindowedCreatePlugin(). (We attached IME | |
| 272 // context only with the windows created in this function.) On the other hand, | |
| 273 // some windowless plugins (such as Flash) call this function with a dummy | |
| 274 // window handle. We return our dummy IME context for these plugins so they | |
| 275 // can use our IME emulator. | |
| 276 if (IsWindow(window)) { | |
| 277 wchar_t name[128]; | |
| 278 GetClassName(window, &name[0], arraysize(name)); | |
| 279 if (!wcscmp(&name[0], kNativeWindowClassName)) | |
| 280 return ::ImmGetContext(window); | |
| 281 } | |
| 282 | |
| 283 WebPluginIMEWin* instance = instance_; | 270 WebPluginIMEWin* instance = instance_; |
| 284 if (instance) | 271 if (instance) |
| 285 instance->support_ime_messages_ = true; | 272 instance->support_ime_messages_ = true; |
| 286 return reinterpret_cast<HIMC>(instance); | 273 return reinterpret_cast<HIMC>(instance); |
| 287 } | 274 } |
| 288 | 275 |
| 289 // static | 276 // static |
| 290 BOOL WINAPI WebPluginIMEWin::ImmReleaseContext(HWND window, HIMC context) { | 277 BOOL WINAPI WebPluginIMEWin::ImmReleaseContext(HWND window, HIMC context) { |
| 291 if (!GetInstance(context)) | 278 if (!GetInstance(context)) |
| 292 return ::ImmReleaseContext(window, context); | 279 return ::ImmReleaseContext(window, context); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 318 int input_type = open ? 1 : 0; | 305 int input_type = open ? 1 : 0; |
| 319 if (instance->input_type_ != input_type) { | 306 if (instance->input_type_ != input_type) { |
| 320 instance->input_type_ = input_type; | 307 instance->input_type_ = input_type; |
| 321 instance->status_updated_ = true; | 308 instance->status_updated_ = true; |
| 322 } | 309 } |
| 323 | 310 |
| 324 return TRUE; | 311 return TRUE; |
| 325 } | 312 } |
| 326 | 313 |
| 327 } // namespace content | 314 } // namespace content |
| OLD | NEW |