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/browser_event_router.h" | 5 #include "chrome/browser/extensions/browser_event_router.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_
api_constants.h" | 9 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_
api_constants.h" |
10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 355 |
356 void BrowserEventRouter::DispatchEvent( | 356 void BrowserEventRouter::DispatchEvent( |
357 Profile* profile, | 357 Profile* profile, |
358 const char* event_name, | 358 const char* event_name, |
359 scoped_ptr<ListValue> args, | 359 scoped_ptr<ListValue> args, |
360 EventRouter::UserGestureState user_gesture) { | 360 EventRouter::UserGestureState user_gesture) { |
361 if (!profile_->IsSameProfile(profile) || | 361 if (!profile_->IsSameProfile(profile) || |
362 !extensions::ExtensionSystem::Get(profile)->event_router()) | 362 !extensions::ExtensionSystem::Get(profile)->event_router()) |
363 return; | 363 return; |
364 | 364 |
365 extensions::ExtensionSystem::Get(profile)->event_router()-> | 365 scoped_ptr<Event> event(new Event(event_name, args.Pass())); |
366 DispatchEventToRenderers(event_name, args.Pass(), profile, GURL(), | 366 event->restrict_to_profile = profile; |
367 user_gesture); | 367 event->user_gesture = user_gesture; |
| 368 ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); |
368 } | 369 } |
369 | 370 |
370 void BrowserEventRouter::DispatchEventToExtension( | 371 void BrowserEventRouter::DispatchEventToExtension( |
371 Profile* profile, | 372 Profile* profile, |
372 const std::string& extension_id, | 373 const std::string& extension_id, |
373 const char* event_name, | 374 const char* event_name, |
374 scoped_ptr<ListValue> event_args, | 375 scoped_ptr<ListValue> event_args, |
375 EventRouter::UserGestureState user_gesture) { | 376 EventRouter::UserGestureState user_gesture) { |
376 if (!profile_->IsSameProfile(profile) || | 377 if (!profile_->IsSameProfile(profile) || |
377 !extensions::ExtensionSystem::Get(profile)->event_router()) | 378 !extensions::ExtensionSystem::Get(profile)->event_router()) |
378 return; | 379 return; |
379 | 380 |
380 extensions::ExtensionSystem::Get(profile)->event_router()-> | 381 scoped_ptr<Event> event(new Event(event_name, event_args.Pass())); |
381 DispatchEventToExtension(extension_id, event_name, event_args.Pass(), | 382 event->restrict_to_profile = profile; |
382 profile, GURL(), user_gesture); | 383 event->user_gesture = user_gesture; |
| 384 ExtensionSystem::Get(profile)->event_router()-> |
| 385 DispatchEventToExtension(extension_id, event.Pass()); |
383 } | 386 } |
384 | 387 |
385 void BrowserEventRouter::DispatchSimpleBrowserEvent( | 388 void BrowserEventRouter::DispatchSimpleBrowserEvent( |
386 Profile* profile, const int window_id, const char* event_name) { | 389 Profile* profile, const int window_id, const char* event_name) { |
387 if (!profile_->IsSameProfile(profile)) | 390 if (!profile_->IsSameProfile(profile)) |
388 return; | 391 return; |
389 | 392 |
390 scoped_ptr<ListValue> args(new ListValue()); | 393 scoped_ptr<ListValue> args(new ListValue()); |
391 args->Append(Value::CreateIntegerValue(window_id)); | 394 args->Append(Value::CreateIntegerValue(window_id)); |
392 | 395 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 | 591 |
589 DispatchEventToExtension(profile, | 592 DispatchEventToExtension(profile, |
590 extension_action.extension_id(), | 593 extension_action.extension_id(), |
591 event_name, | 594 event_name, |
592 args.Pass(), | 595 args.Pass(), |
593 EventRouter::USER_GESTURE_ENABLED); | 596 EventRouter::USER_GESTURE_ENABLED); |
594 } | 597 } |
595 } | 598 } |
596 | 599 |
597 } // namespace extensions | 600 } // namespace extensions |
OLD | NEW |