| 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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 listener_profile->GetExtensionService()->process_map(); | 321 listener_profile->GetExtensionService()->process_map(); |
| 322 // If the event is privileged, only send to extension processes. Otherwise, | 322 // If the event is privileged, only send to extension processes. Otherwise, |
| 323 // it's OK to send to normal renderers (e.g., for content scripts). | 323 // it's OK to send to normal renderers (e.g., for content scripts). |
| 324 if (ExtensionAPI::GetSharedInstance()->IsPrivileged(event->event_name) && | 324 if (ExtensionAPI::GetSharedInstance()->IsPrivileged(event->event_name) && |
| 325 !process_map->Contains(extension->id(), listener.process->GetID())) { | 325 !process_map->Contains(extension->id(), listener.process->GetID())) { |
| 326 return; | 326 return; |
| 327 } | 327 } |
| 328 | 328 |
| 329 const std::string* event_args; | 329 const std::string* event_args; |
| 330 if (!CanDispatchEventToProfile(listener_profile, extension, | 330 if (!CanDispatchEventToProfile(listener_profile, extension, |
| 331 event, &event_args)) | 331 event, &event_args)) { |
| 332 return; | 332 return; |
| 333 } |
| 333 | 334 |
| 334 DispatchEvent(listener.process, listener.extension_id, | 335 DispatchEvent(listener.process, listener.extension_id, |
| 335 event->event_name, *event_args, | 336 event->event_name, *event_args, |
| 336 event->event_url, event->user_gesture); | 337 event->event_url, event->user_gesture); |
| 337 IncrementInFlightEvents(listener_profile, extension); | 338 IncrementInFlightEvents(listener_profile, extension); |
| 338 } | 339 } |
| 339 | 340 |
| 340 bool ExtensionEventRouter::CanDispatchEventToProfile( | 341 bool ExtensionEventRouter::CanDispatchEventToProfile( |
| 341 Profile* profile, | 342 Profile* profile, |
| 342 const Extension* extension, | 343 const Extension* extension, |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 MessageLoop::current()->PostTask(FROM_HERE, | 506 MessageLoop::current()->PostTask(FROM_HERE, |
| 506 base::Bind(&extensions::RuntimeEventRouter::DispatchOnInstalledEvent, | 507 base::Bind(&extensions::RuntimeEventRouter::DispatchOnInstalledEvent, |
| 507 profile_, extension->id())); | 508 profile_, extension->id())); |
| 508 break; | 509 break; |
| 509 } | 510 } |
| 510 default: | 511 default: |
| 511 NOTREACHED(); | 512 NOTREACHED(); |
| 512 return; | 513 return; |
| 513 } | 514 } |
| 514 } | 515 } |
| OLD | NEW |