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 "chrome/browser/extensions/event_router.h" | 5 #include "chrome/browser/extensions/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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 FROM_HERE, | 104 FROM_HERE, |
105 base::Bind(&LogExtensionEventMessage, | 105 base::Bind(&LogExtensionEventMessage, |
106 profile_id, | 106 profile_id, |
107 extension_id, | 107 extension_id, |
108 event_name, | 108 event_name, |
109 base::Passed(&event_args))); | 109 base::Passed(&event_args))); |
110 } else { | 110 } else { |
111 Profile* profile = reinterpret_cast<Profile*>(profile_id); | 111 Profile* profile = reinterpret_cast<Profile*>(profile_id); |
112 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) | 112 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) |
113 return; | 113 return; |
114 | 114 ActivityLog::GetInstance(profile)->LogEventAction( |
115 // An ExtensionService might not be running during unit tests, or an | 115 extension_id, event_name, event_args.get(), std::string()); |
116 // extension might have been unloaded by the time we get to logging it. In | |
117 // those cases log a warning. | |
118 ExtensionService* extension_service = | |
119 ExtensionSystem::Get(profile)->extension_service(); | |
120 if (!extension_service) { | |
121 LOG(WARNING) << "ExtensionService does not seem to be available " | |
122 << "(this may be normal for unit tests)"; | |
123 } else { | |
124 const Extension* extension = | |
125 extension_service->extensions()->GetByID(extension_id); | |
126 if (!extension) { | |
127 LOG(WARNING) << "Extension " << extension_id << " not found!"; | |
128 } else { | |
129 ActivityLog::GetInstance(profile)->LogEventAction( | |
130 extension, event_name, event_args.get(), std::string()); | |
131 } | |
132 } | |
133 } | 116 } |
134 } | 117 } |
135 | 118 |
136 // static | 119 // static |
137 void EventRouter::DispatchExtensionMessage(IPC::Sender* ipc_sender, | 120 void EventRouter::DispatchExtensionMessage(IPC::Sender* ipc_sender, |
138 void* profile_id, | 121 void* profile_id, |
139 const std::string& extension_id, | 122 const std::string& extension_id, |
140 const std::string& event_name, | 123 const std::string& event_name, |
141 ListValue* event_args, | 124 ListValue* event_args, |
142 UserGestureState user_gesture, | 125 UserGestureState user_gesture, |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 copy->will_dispatch_callback = will_dispatch_callback; | 846 copy->will_dispatch_callback = will_dispatch_callback; |
864 return copy; | 847 return copy; |
865 } | 848 } |
866 | 849 |
867 EventListenerInfo::EventListenerInfo(const std::string& event_name, | 850 EventListenerInfo::EventListenerInfo(const std::string& event_name, |
868 const std::string& extension_id) | 851 const std::string& extension_id) |
869 : event_name(event_name), | 852 : event_name(event_name), |
870 extension_id(extension_id) {} | 853 extension_id(extension_id) {} |
871 | 854 |
872 } // namespace extensions | 855 } // namespace extensions |
OLD | NEW |