OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // ICeeeBroker implementation | 5 // ICeeeBroker implementation |
6 | 6 |
7 #include "ceee/ie/broker/broker.h" | 7 #include "ceee/ie/broker/broker.h" |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/utf_string_conversions.h" |
| 11 #include "ceee/common/com_utils.h" |
10 #include "ceee/ie/broker/api_dispatcher.h" | 12 #include "ceee/ie/broker/api_dispatcher.h" |
11 #include "ceee/ie/broker/chrome_postman.h" | 13 #include "ceee/ie/broker/chrome_postman.h" |
12 #include "ceee/ie/broker/executors_manager.h" | 14 #include "ceee/ie/broker/executors_manager.h" |
13 #include "ceee/ie/common/ceee_module_util.h" | 15 #include "ceee/ie/common/ceee_module_util.h" |
14 | 16 |
15 | |
16 HRESULT CeeeBroker::FinalConstruct() { | 17 HRESULT CeeeBroker::FinalConstruct() { |
17 // So that we get a pointer to the ExecutorsManager and let tests override it. | 18 // So that we get a pointer to the ExecutorsManager and let tests override it. |
18 executors_manager_ = Singleton<ExecutorsManager, | 19 executors_manager_ = Singleton<ExecutorsManager, |
19 ExecutorsManager::SingletonTraits>::get(); | 20 ExecutorsManager::SingletonTraits>::get(); |
20 api_dispatcher_ = ProductionApiDispatcher::get(); | 21 api_dispatcher_ = ProductionApiDispatcher::get(); |
21 return S_OK; | 22 return S_OK; |
22 } | 23 } |
23 | 24 |
24 STDMETHODIMP CeeeBroker::Execute(BSTR function, BSTR* response) { | 25 STDMETHODIMP CeeeBroker::Execute(BSTR function, BSTR* response) { |
25 // This is DEPRECATED and we should use ChromePostman (see FireEvent). | 26 // This is DEPRECATED and we should use ChromePostman (see FireEvent). |
26 api_dispatcher_->HandleApiRequest(function, response); | 27 api_dispatcher_->HandleApiRequest(function, response); |
27 return S_OK; | 28 return S_OK; |
28 } | 29 } |
29 | 30 |
30 STDMETHODIMP CeeeBroker::FireEvent(BSTR event_name, BSTR event_args) { | 31 STDMETHODIMP CeeeBroker::FireEvent(BSTR event_name, BSTR event_args) { |
31 ChromePostman::GetInstance()->FireEvent(event_name, event_args); | 32 ChromePostman::GetInstance()->FireEvent( |
| 33 WideToUTF8(com::ToString(event_name)).c_str(), |
| 34 WideToUTF8(com::ToString(event_args)).c_str()); |
32 return S_OK; | 35 return S_OK; |
33 } | 36 } |
34 | 37 |
35 STDMETHODIMP CeeeBroker::RegisterWindowExecutor(long thread_id, | 38 STDMETHODIMP CeeeBroker::RegisterWindowExecutor(long thread_id, |
36 IUnknown* executor) { | 39 IUnknown* executor) { |
37 // TODO(mad@chromium.org): Add security check here. | 40 // TODO(mad@chromium.org): Add security check here. |
38 return executors_manager_->RegisterWindowExecutor(thread_id, executor); | 41 return executors_manager_->RegisterWindowExecutor(thread_id, executor); |
39 } | 42 } |
40 | 43 |
41 STDMETHODIMP CeeeBroker::UnregisterExecutor(long thread_id) { | 44 STDMETHODIMP CeeeBroker::UnregisterExecutor(long thread_id) { |
42 // TODO(mad@chromium.org): Add security check here. | 45 // TODO(mad@chromium.org): Add security check here. |
43 return executors_manager_->RemoveExecutor(thread_id); | 46 return executors_manager_->RemoveExecutor(thread_id); |
44 } | 47 } |
45 | 48 |
46 STDMETHODIMP CeeeBroker::RegisterTabExecutor(long thread_id, | 49 STDMETHODIMP CeeeBroker::RegisterTabExecutor(long thread_id, |
47 IUnknown* executor) { | 50 IUnknown* executor) { |
48 // TODO(mad@chromium.org): Implement the proper manual/secure registration. | 51 // TODO(mad@chromium.org): Implement the proper manual/secure registration. |
49 return executors_manager_->RegisterTabExecutor(thread_id, executor); | 52 return executors_manager_->RegisterTabExecutor(thread_id, executor); |
50 } | 53 } |
51 | 54 |
52 STDMETHODIMP CeeeBroker::SetTabIdForHandle(long tab_id, | 55 STDMETHODIMP CeeeBroker::SetTabIdForHandle(long tab_id, |
53 CeeeWindowHandle handle) { | 56 CeeeWindowHandle handle) { |
54 // TODO(mad@chromium.org): Add security check here. | 57 // TODO(mad@chromium.org): Add security check here. |
55 DCHECK(tab_id != kInvalidChromeSessionId && | 58 DCHECK(tab_id != kInvalidChromeSessionId && |
56 handle != reinterpret_cast<CeeeWindowHandle>(INVALID_HANDLE_VALUE)); | 59 handle != reinterpret_cast<CeeeWindowHandle>(INVALID_HANDLE_VALUE)); |
57 executors_manager_->SetTabIdForHandle(tab_id, reinterpret_cast<HWND>(handle)); | 60 executors_manager_->SetTabIdForHandle(tab_id, reinterpret_cast<HWND>(handle)); |
58 return S_OK; | 61 return S_OK; |
59 } | 62 } |
OLD | NEW |