Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: chrome/browser/extensions/event_router.cc

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (!extension_service) { 112 if (!extension_service) {
113 LOG(WARNING) << "ExtensionService does not seem to be available " 113 LOG(WARNING) << "ExtensionService does not seem to be available "
114 << "(this may be normal for unit tests)"; 114 << "(this may be normal for unit tests)";
115 } else { 115 } else {
116 const Extension* extension = 116 const Extension* extension =
117 extension_service->extensions()->GetByID(extension_id); 117 extension_service->extensions()->GetByID(extension_id);
118 if (!extension) { 118 if (!extension) {
119 LOG(WARNING) << "Extension " << extension_id << " not found!"; 119 LOG(WARNING) << "Extension " << extension_id << " not found!";
120 } else { 120 } else {
121 extensions::ActivityLog::GetInstance(profile)->LogEventAction( 121 extensions::ActivityLog::GetInstance(profile)->LogEventAction(
122 extension, event_name, event_args.get(), ""); 122 extension, event_name, event_args.get(), std::string());
123 } 123 }
124 } 124 }
125 } 125 }
126 } 126 }
127 127
128 // static 128 // static
129 void EventRouter::DispatchExtensionMessage(IPC::Sender* ipc_sender, 129 void EventRouter::DispatchExtensionMessage(IPC::Sender* ipc_sender,
130 void* profile_id, 130 void* profile_id,
131 const std::string& extension_id, 131 const std::string& extension_id,
132 const std::string& event_name, 132 const std::string& event_name,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 if (observer != observers_.end()) 236 if (observer != observers_.end())
237 observer->second->OnListenerAdded(details); 237 observer->second->OnListenerAdded(details);
238 238
239 const Extension* extension = extensions::ExtensionSystem::Get(profile_)-> 239 const Extension* extension = extensions::ExtensionSystem::Get(profile_)->
240 extension_service()->GetExtensionById(listener->extension_id, 240 extension_service()->GetExtensionById(listener->extension_id,
241 ExtensionService::INCLUDE_ENABLED); 241 ExtensionService::INCLUDE_ENABLED);
242 if (extension) { 242 if (extension) {
243 scoped_ptr<ListValue> args(new ListValue()); 243 scoped_ptr<ListValue> args(new ListValue());
244 if (listener->filter) 244 if (listener->filter)
245 args->Append(listener->filter->DeepCopy()); 245 args->Append(listener->filter->DeepCopy());
246 activity_log_->LogAPIAction(extension, 246 activity_log_->LogAPIAction(
247 event_name + ".addListener", 247 extension, event_name + ".addListener", args.get(), std::string());
248 args.get(),
249 "");
250 } 248 }
251 } 249 }
252 250
253 void EventRouter::OnListenerRemoved(const EventListener* listener) { 251 void EventRouter::OnListenerRemoved(const EventListener* listener) {
254 const std::string& event_name = listener->event_name; 252 const std::string& event_name = listener->event_name;
255 const EventListenerInfo details(event_name, listener->extension_id); 253 const EventListenerInfo details(event_name, listener->extension_id);
256 ObserverMap::iterator observer = observers_.find(event_name); 254 ObserverMap::iterator observer = observers_.find(event_name);
257 if (observer != observers_.end()) 255 if (observer != observers_.end())
258 observer->second->OnListenerRemoved(details); 256 observer->second->OnListenerRemoved(details);
259 257
260 void* profile = 258 void* profile =
261 listener->process 259 listener->process
262 ? Profile::FromBrowserContext(listener->process->GetBrowserContext()) 260 ? Profile::FromBrowserContext(listener->process->GetBrowserContext())
263 : NULL; 261 : NULL;
264 BrowserThread::PostTask( 262 BrowserThread::PostTask(
265 BrowserThread::IO, FROM_HERE, 263 BrowserThread::IO, FROM_HERE,
266 base::Bind(&NotifyEventListenerRemovedOnIOThread, 264 base::Bind(&NotifyEventListenerRemovedOnIOThread,
267 profile, listener->extension_id, event_name)); 265 profile, listener->extension_id, event_name));
268 266
269 const Extension* extension = extensions::ExtensionSystem::Get(profile_)-> 267 const Extension* extension = extensions::ExtensionSystem::Get(profile_)->
270 extension_service()->GetExtensionById(listener->extension_id, 268 extension_service()->GetExtensionById(listener->extension_id,
271 ExtensionService::INCLUDE_ENABLED); 269 ExtensionService::INCLUDE_ENABLED);
272 if (extension) { 270 if (extension) {
273 scoped_ptr<ListValue> args(new ListValue()); 271 scoped_ptr<ListValue> args(new ListValue());
274 activity_log_->LogAPIAction(extension, 272 activity_log_->LogAPIAction(
275 event_name + ".removeListener", 273 extension, event_name + ".removeListener", args.get(), std::string());
276 args.get(),
277 "");
278 } 274 }
279 } 275 }
280 276
281 void EventRouter::AddLazyEventListener(const std::string& event_name, 277 void EventRouter::AddLazyEventListener(const std::string& event_name,
282 const std::string& extension_id) { 278 const std::string& extension_id) {
283 scoped_ptr<EventListener> listener(new EventListener( 279 scoped_ptr<EventListener> listener(new EventListener(
284 event_name, extension_id, NULL, scoped_ptr<DictionaryValue>())); 280 event_name, extension_id, NULL, scoped_ptr<DictionaryValue>()));
285 bool is_new = listeners_.AddListener(listener.Pass()); 281 bool is_new = listeners_.AddListener(listener.Pass());
286 282
287 if (is_new) { 283 if (is_new) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 373
378 for (std::set<ListenerProcess>::const_iterator listener = listeners.begin(); 374 for (std::set<ListenerProcess>::const_iterator listener = listeners.begin();
379 listener != listeners.end(); ++listener) { 375 listener != listeners.end(); ++listener) {
380 if (listener->extension_id == extension_id) 376 if (listener->extension_id == extension_id)
381 return true; 377 return true;
382 } 378 }
383 return false; 379 return false;
384 } 380 }
385 381
386 void EventRouter::BroadcastEvent(scoped_ptr<Event> event) { 382 void EventRouter::BroadcastEvent(scoped_ptr<Event> event) {
387 DispatchEventImpl("", linked_ptr<Event>(event.release())); 383 DispatchEventImpl(std::string(), linked_ptr<Event>(event.release()));
388 } 384 }
389 385
390 void EventRouter::DispatchEventToExtension(const std::string& extension_id, 386 void EventRouter::DispatchEventToExtension(const std::string& extension_id,
391 scoped_ptr<Event> event) { 387 scoped_ptr<Event> event) {
392 DCHECK(!extension_id.empty()); 388 DCHECK(!extension_id.empty());
393 DispatchEventImpl(extension_id, linked_ptr<Event>(event.release())); 389 DispatchEventImpl(extension_id, linked_ptr<Event>(event.release()));
394 } 390 }
395 391
396 void EventRouter::DispatchEventImpl(const std::string& restrict_to_extension_id, 392 void EventRouter::DispatchEventImpl(const std::string& restrict_to_extension_id,
397 const linked_ptr<Event>& event) { 393 const linked_ptr<Event>& event) {
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 copy->will_dispatch_callback = will_dispatch_callback; 716 copy->will_dispatch_callback = will_dispatch_callback;
721 return copy; 717 return copy;
722 } 718 }
723 719
724 EventListenerInfo::EventListenerInfo(const std::string& event_name, 720 EventListenerInfo::EventListenerInfo(const std::string& event_name,
725 const std::string& extension_id) 721 const std::string& extension_id)
726 : event_name(event_name), 722 : event_name(event_name),
727 extension_id(extension_id) {} 723 extension_id(extension_id) {}
728 724
729 } // namespace extensions 725 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/component_loader_unittest.cc ('k') | chrome/browser/extensions/event_router_forwarder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698