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/api/sync_file_system/extension_sync_event_ob
server.h" | 5 #include "chrome/browser/extensions/api/sync_file_system/extension_sync_event_ob
server.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api_he
lpers.h" | 8 #include "chrome/browser/extensions/api/sync_file_system/sync_file_system_api_he
lpers.h" |
9 #include "chrome/browser/sync_file_system/sync_event_observer.h" | 9 #include "chrome/browser/sync_file_system/sync_event_observer.h" |
10 #include "chrome/browser/sync_file_system/sync_file_system_service.h" | 10 #include "chrome/browser/sync_file_system/sync_file_system_service.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 void ExtensionSyncEventObserver::BroadcastOrDispatchEvent( | 118 void ExtensionSyncEventObserver::BroadcastOrDispatchEvent( |
119 const GURL& app_origin, | 119 const GURL& app_origin, |
120 const std::string& event_name, | 120 const std::string& event_name, |
121 scoped_ptr<base::ListValue> values) { | 121 scoped_ptr<base::ListValue> values) { |
122 // Check to see whether the event should be broadcasted to all listening | 122 // Check to see whether the event should be broadcasted to all listening |
123 // extensions or sent to a specific extension ID. | 123 // extensions or sent to a specific extension ID. |
124 bool broadcast_mode = app_origin.is_empty(); | 124 bool broadcast_mode = app_origin.is_empty(); |
125 EventRouter* event_router = EventRouter::Get(browser_context_); | 125 EventRouter* event_router = EventRouter::Get(browser_context_); |
126 DCHECK(event_router); | 126 DCHECK(event_router); |
127 | 127 |
128 scoped_ptr<Event> event(new Event(event_name, values.Pass())); | 128 scoped_ptr<Event> event( |
| 129 new Event(events::UNKNOWN, event_name, values.Pass())); |
129 event->restrict_to_browser_context = browser_context_; | 130 event->restrict_to_browser_context = browser_context_; |
130 | 131 |
131 // No app_origin, broadcast to all listening extensions for this event name. | 132 // No app_origin, broadcast to all listening extensions for this event name. |
132 if (broadcast_mode) { | 133 if (broadcast_mode) { |
133 event_router->BroadcastEvent(event.Pass()); | 134 event_router->BroadcastEvent(event.Pass()); |
134 return; | 135 return; |
135 } | 136 } |
136 | 137 |
137 // Dispatch to single extension ID. | 138 // Dispatch to single extension ID. |
138 const std::string extension_id = GetExtensionId(app_origin); | 139 const std::string extension_id = GetExtensionId(app_origin); |
139 if (extension_id.empty()) | 140 if (extension_id.empty()) |
140 return; | 141 return; |
141 event_router->DispatchEventToExtension(extension_id, event.Pass()); | 142 event_router->DispatchEventToExtension(extension_id, event.Pass()); |
142 } | 143 } |
143 | 144 |
144 template <> | 145 template <> |
145 void BrowserContextKeyedAPIFactory< | 146 void BrowserContextKeyedAPIFactory< |
146 ExtensionSyncEventObserver>::DeclareFactoryDependencies() { | 147 ExtensionSyncEventObserver>::DeclareFactoryDependencies() { |
147 DependsOn(sync_file_system::SyncFileSystemServiceFactory::GetInstance()); | 148 DependsOn(sync_file_system::SyncFileSystemServiceFactory::GetInstance()); |
148 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 149 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
149 } | 150 } |
150 | 151 |
151 } // namespace extensions | 152 } // namespace extensions |
OLD | NEW |