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 "extensions/browser/event_router.h" | 5 #include "extensions/browser/event_router.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 ipc_sender->Send(new ExtensionMsg_MessageInvoke( | 115 ipc_sender->Send(new ExtensionMsg_MessageInvoke( |
116 MSG_ROUTING_CONTROL, | 116 MSG_ROUTING_CONTROL, |
117 extension_id, | 117 extension_id, |
118 kEventBindings, | 118 kEventBindings, |
119 "dispatchEvent", | 119 "dispatchEvent", |
120 args, | 120 args, |
121 user_gesture == USER_GESTURE_ENABLED)); | 121 user_gesture == USER_GESTURE_ENABLED)); |
122 | 122 |
123 // DispatchExtensionMessage does _not_ take ownership of event_args, so we | 123 // DispatchExtensionMessage does _not_ take ownership of event_args, so we |
124 // must ensure that the destruction of args does not attempt to free it. | 124 // must ensure that the destruction of args does not attempt to free it. |
125 scoped_ptr<Value> removed_event_args; | 125 scoped_ptr<base::Value> removed_event_args; |
126 args.Remove(1, &removed_event_args); | 126 args.Remove(1, &removed_event_args); |
127 ignore_result(removed_event_args.release()); | 127 ignore_result(removed_event_args.release()); |
128 } | 128 } |
129 | 129 |
130 // static | 130 // static |
131 std::string EventRouter::GetBaseEventName(const std::string& full_event_name) { | 131 std::string EventRouter::GetBaseEventName(const std::string& full_event_name) { |
132 size_t slash_sep = full_event_name.find('/'); | 132 size_t slash_sep = full_event_name.find('/'); |
133 return full_event_name.substr(0, slash_sep); | 133 return full_event_name.substr(0, slash_sep); |
134 } | 134 } |
135 | 135 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 events.insert(event); | 349 events.insert(event); |
350 } | 350 } |
351 return events; | 351 return events; |
352 } | 352 } |
353 | 353 |
354 void EventRouter::SetRegisteredEvents(const std::string& extension_id, | 354 void EventRouter::SetRegisteredEvents(const std::string& extension_id, |
355 const std::set<std::string>& events) { | 355 const std::set<std::string>& events) { |
356 ListValue* events_value = new ListValue; | 356 ListValue* events_value = new ListValue; |
357 for (std::set<std::string>::const_iterator iter = events.begin(); | 357 for (std::set<std::string>::const_iterator iter = events.begin(); |
358 iter != events.end(); ++iter) { | 358 iter != events.end(); ++iter) { |
359 events_value->Append(new StringValue(*iter)); | 359 events_value->Append(new base::StringValue(*iter)); |
360 } | 360 } |
361 extension_prefs_->UpdateExtensionPref( | 361 extension_prefs_->UpdateExtensionPref( |
362 extension_id, kRegisteredEvents, events_value); | 362 extension_id, kRegisteredEvents, events_value); |
363 } | 363 } |
364 | 364 |
365 void EventRouter::AddFilterToEvent(const std::string& event_name, | 365 void EventRouter::AddFilterToEvent(const std::string& event_name, |
366 const std::string& extension_id, | 366 const std::string& extension_id, |
367 const DictionaryValue* filter) { | 367 const DictionaryValue* filter) { |
368 ExtensionPrefs::ScopedDictionaryUpdate update( | 368 ExtensionPrefs::ScopedDictionaryUpdate update( |
369 extension_prefs_, extension_id, kFilteredEvents); | 369 extension_prefs_, extension_id, kFilteredEvents); |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 EventDispatchInfo::EventDispatchInfo(const std::string& extension_id, | 774 EventDispatchInfo::EventDispatchInfo(const std::string& extension_id, |
775 const std::string& event_name, | 775 const std::string& event_name, |
776 scoped_ptr<ListValue> event_args) | 776 scoped_ptr<ListValue> event_args) |
777 : extension_id(extension_id), | 777 : extension_id(extension_id), |
778 event_name(event_name), | 778 event_name(event_name), |
779 event_args(event_args.Pass()) {} | 779 event_args(event_args.Pass()) {} |
780 | 780 |
781 EventDispatchInfo::~EventDispatchInfo() {} | 781 EventDispatchInfo::~EventDispatchInfo() {} |
782 | 782 |
783 } // namespace extensions | 783 } // namespace extensions |
OLD | NEW |