| 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 ActivityLog::GetInstance(profile)->LogEventAction( | 114 |
| 115 extension_id, event_name, event_args.get(), std::string()); | 115 // An ExtensionService might not be running during unit tests, or an |
| 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 } |
| 116 } | 133 } |
| 117 } | 134 } |
| 118 | 135 |
| 119 // static | 136 // static |
| 120 void EventRouter::DispatchExtensionMessage(IPC::Sender* ipc_sender, | 137 void EventRouter::DispatchExtensionMessage(IPC::Sender* ipc_sender, |
| 121 void* profile_id, | 138 void* profile_id, |
| 122 const std::string& extension_id, | 139 const std::string& extension_id, |
| 123 const std::string& event_name, | 140 const std::string& event_name, |
| 124 ListValue* event_args, | 141 ListValue* event_args, |
| 125 UserGestureState user_gesture, | 142 UserGestureState user_gesture, |
| (...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 copy->will_dispatch_callback = will_dispatch_callback; | 863 copy->will_dispatch_callback = will_dispatch_callback; |
| 847 return copy; | 864 return copy; |
| 848 } | 865 } |
| 849 | 866 |
| 850 EventListenerInfo::EventListenerInfo(const std::string& event_name, | 867 EventListenerInfo::EventListenerInfo(const std::string& event_name, |
| 851 const std::string& extension_id) | 868 const std::string& extension_id) |
| 852 : event_name(event_name), | 869 : event_name(event_name), |
| 853 extension_id(extension_id) {} | 870 extension_id(extension_id) {} |
| 854 | 871 |
| 855 } // namespace extensions | 872 } // namespace extensions |
| OLD | NEW |