1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ICeeeBroker implementation
#include "ceee/ie/broker/broker.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "ceee/common/com_utils.h"
#include "ceee/ie/broker/api_dispatcher.h"
#include "ceee/ie/broker/chrome_postman.h"
#include "ceee/ie/broker/executors_manager.h"
#include "ceee/ie/common/ceee_module_util.h"
HRESULT CeeeBroker::FinalConstruct() {
// So that we get a pointer to the ExecutorsManager and let tests override it.
executors_manager_ = Singleton<ExecutorsManager,
ExecutorsManager::SingletonTraits>::get();
api_dispatcher_ = ProductionApiDispatcher::get();
return S_OK;
}
void CeeeBroker::OnAddConnection(bool first_lock) {
if (first_lock)
ceee_module_util::LockModule();
}
void CeeeBroker::OnReleaseConnection(bool last_unlock,
bool last_unlock_releases) {
if (last_unlock)
ceee_module_util::UnlockModule();
IExternalConnectionImpl<CeeeBroker>::OnReleaseConnection(
last_unlock, last_unlock_releases);
}
STDMETHODIMP CeeeBroker::Execute(BSTR function, BSTR* response) {
// This is DEPRECATED and we should use ChromePostman (see FireEvent).
api_dispatcher_->HandleApiRequest(function, response);
return S_OK;
}
STDMETHODIMP CeeeBroker::FireEvent(BSTR event_name, BSTR event_args) {
ChromePostman::GetInstance()->FireEvent(
WideToUTF8(com::ToString(event_name)).c_str(),
WideToUTF8(com::ToString(event_args)).c_str());
return S_OK;
}
STDMETHODIMP CeeeBroker::RegisterWindowExecutor(long thread_id,
IUnknown* executor) {
// TODO(mad@chromium.org): Add security check here.
return executors_manager_->RegisterWindowExecutor(thread_id, executor);
}
STDMETHODIMP CeeeBroker::UnregisterExecutor(long thread_id) {
// TODO(mad@chromium.org): Add security check here.
return executors_manager_->RemoveExecutor(thread_id);
}
STDMETHODIMP CeeeBroker::RegisterTabExecutor(long thread_id,
IUnknown* executor) {
// TODO(mad@chromium.org): Implement the proper manual/secure registration.
return executors_manager_->RegisterTabExecutor(thread_id, executor);
}
STDMETHODIMP CeeeBroker::SetTabIdForHandle(long tab_id,
CeeeWindowHandle handle) {
// TODO(mad@chromium.org): Add security check here.
DCHECK(tab_id != kInvalidChromeSessionId &&
handle != reinterpret_cast<CeeeWindowHandle>(INVALID_HANDLE_VALUE));
executors_manager_->SetTabIdForHandle(tab_id, reinterpret_cast<HWND>(handle));
return S_OK;
}
|