| 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/extension_event_router.h" | 5 #include "chrome/browser/extensions/extension_event_router.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 listener_profile->GetExtensionService()->process_map(); | 374 listener_profile->GetExtensionService()->process_map(); |
| 375 // If the event is privileged, only send to extension processes. Otherwise, | 375 // If the event is privileged, only send to extension processes. Otherwise, |
| 376 // it's OK to send to normal renderers (e.g., for content scripts). | 376 // it's OK to send to normal renderers (e.g., for content scripts). |
| 377 if (ExtensionAPI::GetSharedInstance()->IsPrivileged(event->event_name) && | 377 if (ExtensionAPI::GetSharedInstance()->IsPrivileged(event->event_name) && |
| 378 !process_map->Contains(extension->id(), listener.process->GetID())) { | 378 !process_map->Contains(extension->id(), listener.process->GetID())) { |
| 379 return; | 379 return; |
| 380 } | 380 } |
| 381 | 381 |
| 382 const Value* event_args = NULL; | 382 const Value* event_args = NULL; |
| 383 if (!CanDispatchEventToProfile(listener_profile, extension, | 383 if (!CanDispatchEventToProfile(listener_profile, extension, |
| 384 event, &event_args)) | 384 event, &event_args)) { |
| 385 return; | 385 return; |
| 386 } |
| 386 | 387 |
| 387 DispatchEvent(listener.process, listener.extension_id, | 388 DispatchEvent(listener.process, listener.extension_id, |
| 388 event->event_name, *event_args, | 389 event->event_name, *event_args, |
| 389 event->event_url, event->user_gesture); | 390 event->event_url, event->user_gesture); |
| 390 IncrementInFlightEvents(listener_profile, extension); | 391 IncrementInFlightEvents(listener_profile, extension); |
| 391 } | 392 } |
| 392 | 393 |
| 393 bool ExtensionEventRouter::CanDispatchEventToProfile( | 394 bool ExtensionEventRouter::CanDispatchEventToProfile( |
| 394 Profile* profile, | 395 Profile* profile, |
| 395 const Extension* extension, | 396 const Extension* extension, |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 MessageLoop::current()->PostTask(FROM_HERE, | 559 MessageLoop::current()->PostTask(FROM_HERE, |
| 559 base::Bind(&extensions::RuntimeEventRouter::DispatchOnInstalledEvent, | 560 base::Bind(&extensions::RuntimeEventRouter::DispatchOnInstalledEvent, |
| 560 profile_, extension->id())); | 561 profile_, extension->id())); |
| 561 break; | 562 break; |
| 562 } | 563 } |
| 563 default: | 564 default: |
| 564 NOTREACHED(); | 565 NOTREACHED(); |
| 565 return; | 566 return; |
| 566 } | 567 } |
| 567 } | 568 } |
| OLD | NEW |