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 // Dispatcher and registry for Chrome Extension APIs. | 5 // Dispatcher and registry for Chrome Extension APIs. |
6 | 6 |
7 #include "ceee/ie/broker/api_dispatcher.h" | 7 #include "ceee/ie/broker/api_dispatcher.h" |
8 | 8 |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 DCHECK(iter != factories_.end()); | 69 DCHECK(iter != factories_.end()); |
70 if (iter == factories_.end()) { | 70 if (iter == factories_.end()) { |
71 return; | 71 return; |
72 } | 72 } |
73 | 73 |
74 scoped_ptr<Invocation> invocation(iter->second()); | 74 scoped_ptr<Invocation> invocation(iter->second()); |
75 DCHECK(invocation.get()); | 75 DCHECK(invocation.get()); |
76 invocation->Execute(*args_list, request_id); | 76 invocation->Execute(*args_list, request_id); |
77 } | 77 } |
78 | 78 |
79 void ApiDispatcher::FireEvent(BSTR event_name, BSTR event_args) { | 79 void ApiDispatcher::FireEvent(const char* event_name, const char* event_args) { |
80 DCHECK(IsRunningInSingleThread()); | 80 DCHECK(IsRunningInSingleThread()); |
81 DLOG(INFO) << "ApiDispatcher::FireEvent. " << event_name << " - " << | 81 DLOG(INFO) << "ApiDispatcher::FireEvent. " << event_name << " - " << |
82 event_args; | 82 event_args; |
83 std::string event_args_str(CW2A(event_args).m_psz); | 83 std::string event_args_str(event_args); |
84 std::string event_name_str(CW2A(event_name).m_psz); | 84 std::string event_name_str(event_name); |
85 // Start by going through the permanent event handlers map. | 85 // Start by going through the permanent event handlers map. |
86 PermanentEventHandlersMap::const_iterator iter = | 86 PermanentEventHandlersMap::const_iterator iter = |
87 permanent_event_handlers_.find(event_name_str); | 87 permanent_event_handlers_.find(event_name_str); |
88 bool fire_event = true; | 88 bool fire_event = true; |
89 std::string converted_event_args; | 89 std::string converted_event_args; |
90 if (iter != permanent_event_handlers_.end()) { | 90 if (iter != permanent_event_handlers_.end()) { |
91 fire_event = iter->second(event_args_str, &converted_event_args, this); | 91 fire_event = iter->second(event_args_str, &converted_event_args, this); |
92 } else { | 92 } else { |
93 // Some events don't need a handler and | 93 // Some events don't need a handler and |
94 // have all the info already available. | 94 // have all the info already available. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 #define REGISTER_INFOBAR_API_FUNCTIONS() infobar_api::RegisterInvocations(this) | 297 #define REGISTER_INFOBAR_API_FUNCTIONS() infobar_api::RegisterInvocations(this) |
298 #define REGISTER_WEBNAVIGATION_API_FUNCTIONS() \ | 298 #define REGISTER_WEBNAVIGATION_API_FUNCTIONS() \ |
299 webnavigation_api::RegisterInvocations(this) | 299 webnavigation_api::RegisterInvocations(this) |
300 #define REGISTER_WEBREQUEST_API_FUNCTIONS() \ | 300 #define REGISTER_WEBREQUEST_API_FUNCTIONS() \ |
301 webrequest_api::RegisterInvocations(this) | 301 webrequest_api::RegisterInvocations(this) |
302 #include "ceee/ie/common/api_registration.h" | 302 #include "ceee/ie/common/api_registration.h" |
303 | 303 |
304 ProductionApiDispatcher::ProductionApiDispatcher() { | 304 ProductionApiDispatcher::ProductionApiDispatcher() { |
305 REGISTER_ALL_API_FUNCTIONS(); | 305 REGISTER_ALL_API_FUNCTIONS(); |
306 } | 306 } |
OLD | NEW |