Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/win/text_services_bridge.h" | |
| 6 | |
| 7 namespace base { | |
| 8 namespace win { | |
| 9 | |
| 10 TextServicesBridge::TextServicesBridge() : client_id_(TF_CLIENTID_NULL) { | |
| 11 is_initialized_ = scoped_com_initialiser_.succeeded(); | |
|
cpu_(ooo_6.6-7.5)
2012/08/22 21:37:18
COM is initialized on this thread, don't do this.
rvargas (doing something else)
2012/08/23 01:20:19
However, this CL is introducing requirements that
| |
| 12 if (!is_initialized_) { | |
| 13 return; | |
| 14 } | |
| 15 | |
| 16 is_initialized_ &= SUCCEEDED(thread_mgr_.CreateInstance(CLSID_TF_ThreadMgr)); | |
| 17 if (!is_initialized_) | |
| 18 return; | |
| 19 | |
| 20 is_initialized_ &= SUCCEEDED(message_pump_.QueryFrom(thread_mgr_)); | |
| 21 is_initialized_ &= SUCCEEDED(keystroke_mgr_.QueryFrom(thread_mgr_)); | |
| 22 // When activate succeeded, |client_id| is set valid value. | |
| 23 is_initialized_ &= SUCCEEDED(thread_mgr_->Activate(&client_id_)); | |
| 24 } | |
| 25 | |
| 26 TextServicesBridge::~TextServicesBridge() { | |
| 27 if (is_initialized_) | |
| 28 thread_mgr_->Deactivate(); | |
| 29 } | |
| 30 | |
| 31 bool TextServicesBridge::Init() { | |
| 32 return is_initialized_; | |
|
cpu_(ooo_6.6-7.5)
2012/08/22 21:37:18
maybe we should do lines 16 to 23 here instead.
| |
| 33 } | |
| 34 | |
| 35 // Wraps for ITfMessagePump::PeekMessage with win32 PeekMessage signature. | |
| 36 // Obtains messages from application message queue. | |
| 37 BOOL TextServicesBridge::DoPeekMessage(MSG* message, | |
| 38 HWND hwnd, | |
| 39 UINT msg_filter_min, | |
| 40 UINT msg_filter_max, | |
| 41 UINT remove_msg) { | |
| 42 BOOL result = FALSE; | |
| 43 if (FAILED(message_pump_->PeekMessage(message, hwnd, msg_filter_min, | |
| 44 msg_filter_max, | |
| 45 remove_msg, &result))) { | |
| 46 result = FALSE; | |
| 47 } | |
| 48 | |
| 49 return result; | |
| 50 } | |
| 51 | |
| 52 // Sends msg to Text Service Manager. | |
| 53 // The msg will be used to input composition text. | |
| 54 // Returns true if|msg| was consumed by text service manager. | |
| 55 bool TextServicesBridge::ProcessMessage(const MSG& msg) { | |
| 56 if (msg.message == WM_KEYDOWN) { | |
| 57 BOOL eaten = FALSE; | |
| 58 HRESULT hr = keystroke_mgr_->TestKeyDown(msg.wParam, msg.lParam, &eaten); | |
| 59 if (FAILED(hr) && !eaten) | |
| 60 return false; | |
| 61 eaten = FALSE; | |
| 62 hr = keystroke_mgr_->KeyDown(msg.wParam, msg.lParam, &eaten); | |
| 63 return (SUCCEEDED(hr) && eaten); | |
| 64 } | |
| 65 | |
| 66 if (msg.message == WM_KEYUP) { | |
| 67 BOOL eaten = FALSE; | |
| 68 HRESULT hr = keystroke_mgr_->TestKeyUp(msg.wParam, msg.lParam, &eaten); | |
| 69 if (FAILED(hr) && !eaten) | |
| 70 return false; | |
| 71 eaten = FALSE; | |
| 72 hr = keystroke_mgr_->KeyUp(msg.wParam, msg.lParam, &eaten); | |
| 73 return (SUCCEEDED(hr) && eaten); | |
| 74 } | |
| 75 | |
| 76 return false; | |
| 77 } | |
| 78 | |
| 79 } // namespace win | |
| 80 } // namespace base | |
| OLD | NEW |