diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-07 07:48:02 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-07 07:48:02 +0000 |
commit | 01f7a80416e36be6e5605b85646d0b7b8395a8b6 (patch) | |
tree | d0469815a4d2e014a54669c2e08f9afaa9e990f6 /chrome/browser | |
parent | 3bb6472100f89924f9fb6a4f794a06539e3bfc35 (diff) | |
download | chromium_src-01f7a80416e36be6e5605b85646d0b7b8395a8b6.zip chromium_src-01f7a80416e36be6e5605b85646d0b7b8395a8b6.tar.gz chromium_src-01f7a80416e36be6e5605b85646d0b7b8395a8b6.tar.bz2 |
Remove deprecated extension EventRouter APIs.
BUG=163246
TBR=tommi@chromium.org
TBR=sky@chromium.org
TBR=dmazzoni@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11440004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171719 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
47 files changed, 306 insertions, 378 deletions
diff --git a/chrome/browser/accessibility/accessibility_extension_api.cc b/chrome/browser/accessibility/accessibility_extension_api.cc index 7265c69..729e616 100644 --- a/chrome/browser/accessibility/accessibility_extension_api.cc +++ b/chrome/browser/accessibility/accessibility_extension_api.cc @@ -164,9 +164,10 @@ void ExtensionAccessibilityEventRouter::DispatchEvent( scoped_ptr<base::ListValue> event_args) { if (enabled_ && profile && extensions::ExtensionSystem::Get(profile)->event_router()) { + scoped_ptr<extensions::Event> event(new extensions::Event( + event_name, event_args.Pass())); extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToRenderers(event_name, event_args.Pass(), NULL, GURL(), - extensions::EventFilteringInfo()); + BroadcastEvent(event.Pass()); } } diff --git a/chrome/browser/bookmarks/bookmark_extension_api.cc b/chrome/browser/bookmarks/bookmark_extension_api.cc index a9bee42..c459057 100644 --- a/chrome/browser/bookmarks/bookmark_extension_api.cc +++ b/chrome/browser/bookmarks/bookmark_extension_api.cc @@ -151,9 +151,8 @@ void BookmarkExtensionEventRouter::DispatchEvent( const char* event_name, scoped_ptr<ListValue> event_args) { if (extensions::ExtensionSystem::Get(profile)->event_router()) { - extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToRenderers(event_name, event_args.Pass(), NULL, GURL(), - extensions::EventFilteringInfo()); + extensions::ExtensionSystem::Get(profile)->event_router()->BroadcastEvent( + make_scoped_ptr(new extensions::Event(event_name, event_args.Pass()))); } } diff --git a/chrome/browser/bookmarks/bookmark_manager_extension_api.cc b/chrome/browser/bookmarks/bookmark_manager_extension_api.cc index 1820d41..0d3a218 100644 --- a/chrome/browser/bookmarks/bookmark_manager_extension_api.cc +++ b/chrome/browser/bookmarks/bookmark_manager_extension_api.cc @@ -176,9 +176,10 @@ void BookmarkManagerExtensionEventRouter::DispatchEvent( if (!extensions::ExtensionSystem::Get(profile_)->event_router()) return; + scoped_ptr<extensions::Event> event(new extensions::Event( + event_name, args.Pass())); extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToRenderers(event_name, args.Pass(), NULL, GURL(), - extensions::EventFilteringInfo()); + BroadcastEvent(event.Pass()); } void BookmarkManagerExtensionEventRouter::DispatchDragEvent( diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.cc b/chrome/browser/chromeos/extensions/file_browser_event_router.cc index 5faa851..139686c 100644 --- a/chrome/browser/chromeos/extensions/file_browser_event_router.cc +++ b/chrome/browser/chromeos/extensions/file_browser_event_router.cc @@ -370,10 +370,11 @@ void FileBrowserEventRouter::OnNetworkManagerChanged( NOTREACHED(); return; } + scoped_ptr<extensions::Event> event(new extensions::Event( + extensions::event_names::kOnFileBrowserNetworkConnectionChanged, + scoped_ptr<ListValue>(new ListValue()))); extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToRenderers( - extensions::event_names::kOnFileBrowserNetworkConnectionChanged, - scoped_ptr<ListValue>(new ListValue()), NULL, GURL()); + BroadcastEvent(event.Pass()); } void FileBrowserEventRouter::OnExternalStorageDisabledChanged() { @@ -400,10 +401,11 @@ void FileBrowserEventRouter::OnFileBrowserPrefsChanged() { return; } + scoped_ptr<extensions::Event> event(new extensions::Event( + extensions::event_names::kOnFileBrowserPreferencesChanged, + scoped_ptr<ListValue>(new ListValue()))); extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToRenderers( - extensions::event_names::kOnFileBrowserPreferencesChanged, - scoped_ptr<ListValue>(new ListValue()), NULL, GURL()); + BroadcastEvent(event.Pass()); } void FileBrowserEventRouter::OnProgressUpdate( @@ -418,12 +420,10 @@ void FileBrowserEventRouter::OnProgressUpdate( scoped_ptr<ListValue> args(new ListValue()); args->Append(event_list.release()); - + scoped_ptr<extensions::Event> event(new extensions::Event( + extensions::event_names::kOnFileTransfersUpdated, args.Pass())); extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToExtension( - std::string(kFileBrowserDomain), - extensions::event_names::kOnFileTransfersUpdated, args.Pass(), NULL, - GURL()); + DispatchEventToExtension(std::string(kFileBrowserDomain), event.Pass()); } void FileBrowserEventRouter::OnDirectoryChanged( @@ -439,11 +439,10 @@ void FileBrowserEventRouter::OnDocumentFeedFetched( scoped_ptr<ListValue> args(new ListValue()); args->Append(base::Value::CreateIntegerValue(num_accumulated_entries)); + scoped_ptr<extensions::Event> event(new extensions::Event( + extensions::event_names::kOnDocumentFeedFetched, args.Pass())); extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToExtension( - std::string(kFileBrowserDomain), - extensions::event_names::kOnDocumentFeedFetched, args.Pass(), NULL, - GURL()); + DispatchEventToExtension(std::string(kFileBrowserDomain), event.Pass()); } void FileBrowserEventRouter::OnFileSystemMounted() { @@ -522,13 +521,10 @@ void FileBrowserEventRouter::DispatchDirectoryChangeEvent( ListValue* watch_info_entries = new ListValue(); watch_info->Set("changedEntries", watch_info_entries); + scoped_ptr<extensions::Event> event(new extensions::Event( + extensions::event_names::kOnDirectoryChanged, args.Pass())); extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToExtension( - iter->first, - extensions::event_names::kOnDirectoryChanged, - args.Pass(), - NULL, - GURL()); + DispatchEventToExtension(iter->first, event.Pass()); } } @@ -548,10 +544,10 @@ void FileBrowserEventRouter::DispatchDiskEvent( DictionaryValue* disk_info = DiskToDictionaryValue(disk); mount_info->Set("volumeInfo", disk_info); + scoped_ptr<extensions::Event> event(new extensions::Event( + extensions::event_names::kOnFileBrowserDiskChanged, args.Pass())); extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToRenderers( - extensions::event_names::kOnFileBrowserDiskChanged, args.Pass(), NULL, - GURL()); + BroadcastEvent(event.Pass()); } void FileBrowserEventRouter::DispatchMountEvent( @@ -604,10 +600,10 @@ void FileBrowserEventRouter::DispatchMountEvent( } } + scoped_ptr<extensions::Event> extension_event(new extensions::Event( + extensions::event_names::kOnFileBrowserMountCompleted, args.Pass())); extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToRenderers( - extensions::event_names::kOnFileBrowserMountCompleted, args.Pass(), - NULL, GURL()); + BroadcastEvent(extension_event.Pass()); // Do not attempt to open File Manager while the login is in progress or // the screen is locked. diff --git a/chrome/browser/chromeos/extensions/file_handler_util.cc b/chrome/browser/chromeos/extensions/file_handler_util.cc index b31eb43..ce18ea5 100644 --- a/chrome/browser/chromeos/extensions/file_handler_util.cc +++ b/chrome/browser/chromeos/extensions/file_handler_util.cc @@ -994,9 +994,10 @@ void ExtensionTaskExecutor::SetupPermissionsAndDispatchEvent( details->SetInteger("tab_id", tab_id_); - event_router->DispatchEventToExtension( - extension_id(), std::string("fileBrowserHandler.onExecute"), - event_args.Pass(), profile(), GURL()); + scoped_ptr<extensions::Event> event(new extensions::Event( + "fileBrowserHandler.onExecute", event_args.Pass())); + event->restrict_to_profile = profile(); + event_router->DispatchEventToExtension(extension_id(), event.Pass()); ExecuteDoneOnUIThread(true); } diff --git a/chrome/browser/chromeos/extensions/input_method_event_router.cc b/chrome/browser/chromeos/extensions/input_method_event_router.cc index 7d56a31..1dff75e 100644 --- a/chrome/browser/chromeos/extensions/input_method_event_router.cc +++ b/chrome/browser/chromeos/extensions/input_method_event_router.cc @@ -48,9 +48,11 @@ void ExtensionInputMethodEventRouter::InputMethodChanged( args->Append(input_method_name); // The router will only send the event to extensions that are listening. - router->DispatchEventToRenderers( - extensions::event_names::kOnInputMethodChanged, args.Pass(), profile, - GURL()); + scoped_ptr<extensions::Event> event(new extensions::Event( + extensions::event_names::kOnInputMethodChanged, args.Pass())); + event->restrict_to_profile = profile; + extensions::ExtensionSystem::Get(profile)->event_router()-> + BroadcastEvent(event.Pass()); } std::string ExtensionInputMethodEventRouter::GetInputMethodForXkb( diff --git a/chrome/browser/chromeos/extensions/media_player_event_router.cc b/chrome/browser/chromeos/extensions/media_player_event_router.cc index b5eb05d..667a02b 100644 --- a/chrome/browser/chromeos/extensions/media_player_event_router.cc +++ b/chrome/browser/chromeos/extensions/media_player_event_router.cc @@ -9,6 +9,16 @@ #include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/profiles/profile.h" +static void BroadcastEvent(Profile* profile, const std::string& event_name) { + if (profile && extensions::ExtensionSystem::Get(profile)->event_router()) { + scoped_ptr<ListValue> args(new ListValue()); + scoped_ptr<extensions::Event> event(new extensions::Event( + event_name, args.Pass())); + extensions::ExtensionSystem::Get(profile)->event_router()-> + BroadcastEvent(event.Pass()); + } +} + ExtensionMediaPlayerEventRouter::ExtensionMediaPlayerEventRouter() : profile_(NULL) { } @@ -23,37 +33,17 @@ void ExtensionMediaPlayerEventRouter::Init(Profile* profile) { } void ExtensionMediaPlayerEventRouter::NotifyNextTrack() { - if (profile_ && extensions::ExtensionSystem::Get(profile_)->event_router()) { - scoped_ptr<ListValue> args(new ListValue()); - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToRenderers("mediaPlayerPrivate.onNextTrack", args.Pass(), - NULL, GURL()); - } + BroadcastEvent(profile_, "mediaPlayerPrivate.onNextTrack"); } void ExtensionMediaPlayerEventRouter::NotifyPlaylistChanged() { - if (profile_ && extensions::ExtensionSystem::Get(profile_)->event_router()) { - scoped_ptr<ListValue> args(new ListValue()); - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToRenderers("mediaPlayerPrivate.onPlaylistChanged", - args.Pass(), NULL, GURL()); - } + BroadcastEvent(profile_, "mediaPlayerPrivate.onPlaylistChanged"); } void ExtensionMediaPlayerEventRouter::NotifyPrevTrack() { - if (profile_ && extensions::ExtensionSystem::Get(profile_)->event_router()) { - scoped_ptr<ListValue> args(new ListValue()); - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToRenderers("mediaPlayerPrivate.onPrevTrack", args.Pass(), - NULL, GURL()); - } + BroadcastEvent(profile_, "mediaPlayerPrivate.onPrevTrack"); } void ExtensionMediaPlayerEventRouter::NotifyTogglePlayState() { - if (profile_ && extensions::ExtensionSystem::Get(profile_)->event_router()) { - scoped_ptr<ListValue> args(new ListValue()); - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToRenderers("mediaPlayerPrivate.onTogglePlayState", - args.Pass(), NULL, GURL()); - } + BroadcastEvent(profile_, "mediaPlayerPrivate.onTogglePlayState"); } diff --git a/chrome/browser/extensions/api/alarms/alarm_manager.cc b/chrome/browser/extensions/api/alarms/alarm_manager.cc index 5df6fc4..11282da 100644 --- a/chrome/browser/extensions/api/alarms/alarm_manager.cc +++ b/chrome/browser/extensions/api/alarms/alarm_manager.cc @@ -40,8 +40,9 @@ class DefaultAlarmDelegate : public AlarmManager::Delegate { const Alarm& alarm) { scoped_ptr<ListValue> args(new ListValue()); args->Append(alarm.js_alarm->ToValue().release()); + scoped_ptr<Event> event(new Event(kOnAlarmEvent, args.Pass())); ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( - extension_id, kOnAlarmEvent, args.Pass(), NULL, GURL()); + extension_id, event.Pass()); } private: diff --git a/chrome/browser/extensions/api/api_resource_event_notifier.cc b/chrome/browser/extensions/api/api_resource_event_notifier.cc index 17b7144..a65f0b3a7 100644 --- a/chrome/browser/extensions/api/api_resource_event_notifier.cc +++ b/chrome/browser/extensions/api/api_resource_event_notifier.cc @@ -43,23 +43,25 @@ std::string ApiResourceEventNotifier::ApiResourceEventTypeToString( ApiResourceEventNotifier::~ApiResourceEventNotifier() {} -void ApiResourceEventNotifier::DispatchEvent(const std::string &extension, - DictionaryValue* event) { +void ApiResourceEventNotifier::DispatchEvent( + const std::string& event_name, DictionaryValue* args) { BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, base::Bind( - &ApiResourceEventNotifier::DispatchEventOnUIThread, this, extension, - event)); + &ApiResourceEventNotifier::DispatchEventOnUIThread, this, + event_name, args)); } void ApiResourceEventNotifier::DispatchEventOnUIThread( - const std::string &extension, DictionaryValue* event) { + const std::string& event_name, DictionaryValue* args) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); scoped_ptr<ListValue> arguments(new ListValue()); - arguments->Set(0, event); - router_->DispatchEventToExtension(src_extension_id_, extension, - arguments.Pass(), profile_, src_url_); + arguments->Set(0, args); + scoped_ptr<Event> event(new Event(event_name, arguments.Pass())); + event->restrict_to_profile = profile_; + event->event_url = src_url_; + router_->DispatchEventToExtension(src_extension_id_, event.Pass()); } DictionaryValue* ApiResourceEventNotifier::CreateApiResourceEvent( diff --git a/chrome/browser/extensions/api/api_resource_event_notifier.h b/chrome/browser/extensions/api/api_resource_event_notifier.h index b34326f..dc031fa 100644 --- a/chrome/browser/extensions/api/api_resource_event_notifier.h +++ b/chrome/browser/extensions/api/api_resource_event_notifier.h @@ -47,9 +47,9 @@ class ApiResourceEventNotifier virtual ~ApiResourceEventNotifier(); - void DispatchEvent(const std::string &extension, DictionaryValue* event); - void DispatchEventOnUIThread(const std::string& extension, - DictionaryValue* event); + void DispatchEvent(const std::string& event_name, DictionaryValue* args); + void DispatchEventOnUIThread(const std::string& event_name, + DictionaryValue* args); DictionaryValue* CreateApiResourceEvent(ApiResourceEventType event_type); EventRouter* router_; diff --git a/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc b/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc index fa7d5f3..4f22f3d 100644 --- a/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc +++ b/chrome/browser/extensions/api/app_runtime/app_runtime_api.cc @@ -19,6 +19,8 @@ #include "googleurl/src/gurl.h" #include "webkit/glue/web_intent_data.h" +namespace extensions { + namespace { const char kIntentIdKey[] = "intentId"; @@ -42,16 +44,15 @@ void DispatchOnLaunchedEventImpl(const std::string& extension_id, // ignored (but an app that doesn't listen for the onLaunched event doesn't // make sense anyway). system->event_router()->AddLazyEventListener(kOnLaunchedEvent, extension_id); - system->event_router()->DispatchEventToExtension( - extension_id, kOnLaunchedEvent, args.Pass(), profile, GURL()); + scoped_ptr<Event> event(new Event(kOnLaunchedEvent, args.Pass())); + event->restrict_to_profile = profile; + system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); system->event_router()->RemoveLazyEventListener(kOnLaunchedEvent, extension_id); } } // anonymous namespace -namespace extensions { - // static. void AppEventRouter::DispatchOnLaunchedEvent( Profile* profile, const Extension* extension) { @@ -63,9 +64,10 @@ void AppEventRouter::DispatchOnLaunchedEvent( void AppEventRouter::DispatchOnRestartedEvent( Profile* profile, const Extension* extension) { scoped_ptr<ListValue> arguments(new ListValue()); + scoped_ptr<Event> event(new Event(kOnRestartedEvent, arguments.Pass())); + event->restrict_to_profile = profile; extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToExtension(extension->id(), kOnRestartedEvent, - arguments.Pass(), profile, GURL()); + DispatchEventToExtension(extension->id(), event.Pass()); } // static. diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc index 38b2ab3..f10689a 100644 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc @@ -199,12 +199,10 @@ void BluetoothGetDevicesFunction::FinishDeviceSearch() { info->SetInteger("expectedEventCount", device_events_sent_); args->Append(info.release()); + scoped_ptr<extensions::Event> event(new extensions::Event( + extensions::event_names::kBluetoothOnDeviceSearchFinished, args.Pass())); extensions::ExtensionSystem::Get(profile())->event_router()-> - DispatchEventToRenderers( - extensions::event_names::kBluetoothOnDeviceSearchFinished, - args.Pass(), - NULL, - GURL()); + BroadcastEvent(event.Pass()); SendResponse(true); } diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc index 0687f43..e146f2d 100644 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc @@ -122,8 +122,8 @@ void ExtensionBluetoothEventRouter::DispatchDeviceEvent( const char* event_name, const extensions::api::bluetooth::Device& device) { scoped_ptr<ListValue> args(new ListValue()); args->Append(device.ToValue().release()); - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToRenderers(event_name, args.Pass(), NULL, GURL()); + scoped_ptr<Event> event(new Event(event_name, args.Pass())); + ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent(event.Pass()); } void ExtensionBluetoothEventRouter::AdapterPresentChanged( @@ -207,8 +207,8 @@ void ExtensionBluetoothEventRouter::DispatchBooleanValueEvent( const char* event_name, bool value) { scoped_ptr<ListValue> args(new ListValue()); args->Append(Value::CreateBooleanValue(value)); - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToRenderers(event_name, args.Pass(), NULL, GURL()); + scoped_ptr<Event> event(new Event(event_name, args.Pass())); + ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent(event.Pass()); } } // namespace extensions diff --git a/chrome/browser/extensions/api/cookies/cookies_api.cc b/chrome/browser/extensions/api/cookies/cookies_api.cc index 30ac29d..f5e10fd 100644 --- a/chrome/browser/extensions/api/cookies/cookies_api.cc +++ b/chrome/browser/extensions/api/cookies/cookies_api.cc @@ -132,8 +132,10 @@ void CookiesEventRouter::DispatchEvent( extensions::ExtensionSystem::Get(profile)->event_router() : NULL; if (!router) return; - router->DispatchEventToRenderers(event_name, event_args.Pass(), profile, - cookie_domain); + scoped_ptr<Event> event(new Event(event_name, event_args.Pass())); + event->restrict_to_profile = profile; + event->event_url = cookie_domain; + router->BroadcastEvent(event.Pass()); } bool CookiesFunction::ParseUrl(const std::string& url_string, GURL* url, diff --git a/chrome/browser/extensions/api/debugger/debugger_api.cc b/chrome/browser/extensions/api/debugger/debugger_api.cc index 12ab0dd..7cb36ef 100644 --- a/chrome/browser/extensions/api/debugger/debugger_api.cc +++ b/chrome/browser/extensions/api/debugger/debugger_api.cc @@ -283,9 +283,11 @@ void ExtensionDevToolsClientHost::SendDetachedEvent() { debuggee.tab_id = tab_id_; scoped_ptr<base::ListValue> args(OnDetach::Create(debuggee, detach_reason_)); + scoped_ptr<extensions::Event> event(new extensions::Event( + keys::kOnDetach, args.Pass())); + event->restrict_to_profile = profile; extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToExtension(extension_id_, keys::kOnDetach, args.Pass(), - profile, GURL()); + DispatchEventToExtension(extension_id_, event.Pass()); } } @@ -338,9 +340,11 @@ void ExtensionDevToolsClientHost::DispatchOnInspectorFrontend( params.additional_properties.Swap(params_value); scoped_ptr<ListValue> args(OnEvent::Create(debuggee, method_name, params)); + scoped_ptr<extensions::Event> event(new extensions::Event( + keys::kOnEvent, args.Pass())); + event->restrict_to_profile = profile; extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToExtension(extension_id_, keys::kOnEvent, args.Pass(), - profile, GURL()); + DispatchEventToExtension(extension_id_, event.Pass()); } else { SendCommandDebuggerFunction* function = pending_requests_[id]; if (!function) diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc index b9d24cf..164ce71 100644 --- a/chrome/browser/extensions/api/downloads/downloads_api.cc +++ b/chrome/browser/extensions/api/downloads/downloads_api.cc @@ -486,9 +486,11 @@ void DispatchEventInternal( scoped_ptr<base::ListValue> event_args) { if (!extensions::ExtensionSystem::Get(target_profile)->event_router()) return; + scoped_ptr<extensions::Event> event(new extensions::Event( + event_name, event_args.Pass())); + event->restrict_to_profile = target_profile; extensions::ExtensionSystem::Get(target_profile)->event_router()-> - DispatchEventToRenderers(event_name, event_args.Pass(), target_profile, - GURL(), extensions::EventFilteringInfo()); + BroadcastEvent(event.Pass()); ExtensionDownloadsEventRouter::DownloadsNotificationSource notification_source; notification_source.event_name = event_name; diff --git a/chrome/browser/extensions/api/idle/idle_manager.cc b/chrome/browser/extensions/api/idle/idle_manager.cc index d449059..c5fee7e 100644 --- a/chrome/browser/extensions/api/idle/idle_manager.cc +++ b/chrome/browser/extensions/api/idle/idle_manager.cc @@ -49,8 +49,10 @@ void DefaultEventDelegate::OnStateChanged(const std::string& extension_id, IdleState new_state) { scoped_ptr<ListValue> args(new ListValue()); args->Append(IdleManager::CreateIdleValue(new_state)); + scoped_ptr<Event> event(new Event(keys::kOnStateChanged, args.Pass())); + event->restrict_to_profile = profile_; ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( - extension_id, keys::kOnStateChanged, args.Pass(), profile_, GURL()); + extension_id, event.Pass()); } void DefaultEventDelegate::RegisterObserver( diff --git a/chrome/browser/extensions/api/input_ime/input_ime_api.cc b/chrome/browser/extensions/api/input_ime/input_ime_api.cc index 63a0dfe..4b76441 100644 --- a/chrome/browser/extensions/api/input_ime/input_ime_api.cc +++ b/chrome/browser/extensions/api/input_ime/input_ime_api.cc @@ -125,6 +125,17 @@ bool ReadMenuItems( return true; } +static void DispatchEventToExtension(Profile* profile, + const std::string& extension_id, + const std::string& event_name, + scoped_ptr<ListValue> args) { + scoped_ptr<extensions::Event> event(new extensions::Event( + event_name, args.Pass())); + event->restrict_to_profile = profile; + extensions::ExtensionSystem::Get(profile)->event_router()-> + DispatchEventToExtension(extension_id, event.Pass()); +} + } // namespace namespace events { @@ -159,9 +170,8 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer { scoped_ptr<base::ListValue> args(new ListValue()); args->Append(Value::CreateStringValue(engine_id)); - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToExtension(extension_id_, events::kOnActivate, - args.Pass(), profile_, GURL()); + DispatchEventToExtension(profile_, extension_id_, + events::kOnActivate, args.Pass()); } virtual void OnDeactivated(const std::string& engine_id) OVERRIDE { @@ -171,9 +181,8 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer { scoped_ptr<base::ListValue> args(new ListValue()); args->Append(Value::CreateStringValue(engine_id)); - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToExtension(extension_id_, events::kOnDeactivated, - args.Pass(), profile_, GURL()); + DispatchEventToExtension(profile_, extension_id_, + events::kOnDeactivated, args.Pass()); } virtual void OnFocus( @@ -188,9 +197,8 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer { scoped_ptr<base::ListValue> args(new ListValue()); args->Append(dict); - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToExtension(extension_id_, events::kOnFocus, - args.Pass(), profile_, GURL()); + DispatchEventToExtension(profile_, extension_id_, + events::kOnFocus, args.Pass()); } virtual void OnBlur(int context_id) OVERRIDE { @@ -200,9 +208,8 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer { scoped_ptr<base::ListValue> args(new ListValue()); args->Append(Value::CreateIntegerValue(context_id)); - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToExtension(extension_id_, events::kOnBlur, - args.Pass(), profile_, GURL()); + DispatchEventToExtension(profile_, extension_id_, + events::kOnBlur, args.Pass()); } virtual void OnInputContextUpdate( @@ -217,9 +224,8 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer { scoped_ptr<base::ListValue> args(new ListValue()); args->Append(dict); - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToExtension(extension_id_, events::kOnInputContextUpdate, - args.Pass(), profile_, GURL()); + DispatchEventToExtension(profile_, extension_id_, + events::kOnInputContextUpdate, args.Pass()); } virtual void OnKeyEvent( @@ -245,9 +251,8 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer { args->Append(Value::CreateStringValue(engine_id)); args->Append(dict); - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToExtension(extension_id_, events::kOnKeyEvent, - args.Pass(), profile_, GURL()); + DispatchEventToExtension(profile_, extension_id_, + events::kOnKeyEvent, args.Pass()); } virtual void OnCandidateClicked( @@ -276,9 +281,8 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer { break; } - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToExtension(extension_id_, events::kOnCandidateClicked, - args.Pass(), profile_, GURL()); + DispatchEventToExtension(profile_, extension_id_, + events::kOnCandidateClicked, args.Pass()); } virtual void OnMenuItemActivated(const std::string& engine_id, @@ -290,9 +294,8 @@ class ImeObserver : public chromeos::InputMethodEngine::Observer { args->Append(Value::CreateStringValue(engine_id)); args->Append(Value::CreateStringValue(menu_id)); - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToExtension(extension_id_, events::kOnMenuItemActivated, - args.Pass(), profile_, GURL()); + DispatchEventToExtension(profile_, extension_id_, + events::kOnMenuItemActivated, args.Pass()); } private: diff --git a/chrome/browser/extensions/api/managed_mode/managed_mode_api.cc b/chrome/browser/extensions/api/managed_mode/managed_mode_api.cc index 54f5847..5224430 100644 --- a/chrome/browser/extensions/api/managed_mode/managed_mode_api.cc +++ b/chrome/browser/extensions/api/managed_mode/managed_mode_api.cc @@ -61,9 +61,9 @@ void ManagedModeEventRouter::OnInManagedModeChanged() { extensions::EventRouter* event_router = extensions::ExtensionSystem::Get(profile_)->event_router(); - event_router->DispatchEventToRenderers(kChangeEventName, args.Pass(), NULL, - GURL(), - extensions::EventFilteringInfo()); + scoped_ptr<extensions::Event> event(new extensions::Event( + kChangeEventName, args.Pass())); + event_router->BroadcastEvent(event.Pass()); } GetManagedModeFunction::~GetManagedModeFunction() { } diff --git a/chrome/browser/extensions/api/management/management_api.cc b/chrome/browser/extensions/api/management/management_api.cc index 8cbe2d6..16584f1 100644 --- a/chrome/browser/extensions/api/management/management_api.cc +++ b/chrome/browser/extensions/api/management/management_api.cc @@ -649,9 +649,10 @@ void ExtensionManagementEventRouter::Observe( args->Append(info->ToValue().release()); } + scoped_ptr<extensions::Event> event(new extensions::Event( + event_name, args.Pass())); extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToRenderers(event_name, args.Pass(), NULL, GURL(), - extensions::EventFilteringInfo()); + BroadcastEvent(event.Pass()); } ExtensionManagementAPI::ExtensionManagementAPI(Profile* profile) diff --git a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_event_router.cc b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_event_router.cc index fc1ba8c..9c84dda 100644 --- a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_event_router.cc +++ b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_event_router.cc @@ -149,8 +149,10 @@ void MediaGalleriesPrivateEventRouter::DispatchEvent( extensions::ExtensionSystem::Get(profile_)->event_router(); if (!router) return; - router->DispatchEventToRenderers(event_name, event_args.Pass(), profile_, - GURL()); + scoped_ptr<extensions::Event> event(new extensions::Event( + event_name, event_args.Pass())); + event->restrict_to_profile = profile_; + router->BroadcastEvent(event.Pass()); } } // namespace extensions diff --git a/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc b/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc index 51be6b2..0b0756f 100644 --- a/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc +++ b/chrome/browser/extensions/api/offscreen_tabs/offscreen_tabs_api.cc @@ -265,10 +265,11 @@ void OffscreenTab::Observe(int type, // event. Profile* profile = Profile::FromBrowserContext( parent_tab_->web_contents()->GetBrowserContext()); + scoped_ptr<extensions::Event> event(new extensions::Event( + events::kOnOffscreenTabUpdated, args.Pass())); + event->restrict_to_profile = profile; extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToRenderers( - events::kOnOffscreenTabUpdated, args.Pass(), profile, GURL(), - extensions::EventFilteringInfo()); + BroadcastEvent(event.Pass()); } ParentTab::ParentTab() : web_contents_(NULL) {} diff --git a/chrome/browser/extensions/api/omnibox/omnibox_api.cc b/chrome/browser/extensions/api/omnibox/omnibox_api.cc index 153fc27..1b4b2e0 100644 --- a/chrome/browser/extensions/api/omnibox/omnibox_api.cc +++ b/chrome/browser/extensions/api/omnibox/omnibox_api.cc @@ -45,10 +45,11 @@ const char kDescriptionStylesLength[] = "length"; // static void ExtensionOmniboxEventRouter::OnInputStarted( Profile* profile, const std::string& extension_id) { - scoped_ptr<ListValue> event_args(new ListValue()); - extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToExtension(extension_id, events::kOnInputStarted, - event_args.Pass(), profile, GURL()); + scoped_ptr<Event> event(new Event( + events::kOnInputStarted, make_scoped_ptr(new ListValue()))); + event->restrict_to_profile = profile; + ExtensionSystem::Get(profile)->event_router()-> + DispatchEventToExtension(extension_id, event.Pass()); } // static @@ -63,9 +64,10 @@ bool ExtensionOmniboxEventRouter::OnInputChanged( args->Set(0, Value::CreateStringValue(input)); args->Set(1, Value::CreateIntegerValue(suggest_id)); - extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToExtension(extension_id, events::kOnInputChanged, - args.Pass(), profile, GURL()); + scoped_ptr<Event> event(new Event(events::kOnInputChanged, args.Pass())); + event->restrict_to_profile = profile; + ExtensionSystem::Get(profile)->event_router()-> + DispatchEventToExtension(extension_id, event.Pass()); return true; } @@ -87,9 +89,10 @@ void ExtensionOmniboxEventRouter::OnInputEntered( scoped_ptr<ListValue> args(new ListValue()); args->Set(0, Value::CreateStringValue(input)); - extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToExtension(extension_id, events::kOnInputEntered, - args.Pass(), profile, GURL()); + scoped_ptr<Event> event(new Event(events::kOnInputEntered, args.Pass())); + event->restrict_to_profile = profile; + ExtensionSystem::Get(profile)->event_router()-> + DispatchEventToExtension(extension_id, event.Pass()); content::NotificationService::current()->Notify( chrome::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED, @@ -100,10 +103,11 @@ void ExtensionOmniboxEventRouter::OnInputEntered( // static void ExtensionOmniboxEventRouter::OnInputCancelled( Profile* profile, const std::string& extension_id) { - scoped_ptr<ListValue> args(new ListValue()); - extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToExtension(extension_id, events::kOnInputCancelled, - args.Pass(), profile, GURL()); + scoped_ptr<Event> event(new Event( + events::kOnInputCancelled, make_scoped_ptr(new ListValue()))); + event->restrict_to_profile = profile; + ExtensionSystem::Get(profile)->event_router()-> + DispatchEventToExtension(extension_id, event.Pass()); } bool OmniboxSendSuggestionsFunction::RunImpl() { diff --git a/chrome/browser/extensions/api/preference/preference_helpers.cc b/chrome/browser/extensions/api/preference/preference_helpers.cc index e9f95b0..7a7af96 100644 --- a/chrome/browser/extensions/api/preference/preference_helpers.cc +++ b/chrome/browser/extensions/api/preference/preference_helpers.cc @@ -128,9 +128,9 @@ void DispatchEventToExtensions( } scoped_ptr<ListValue> args_copy(args->DeepCopy()); - router->DispatchEventToExtension( - extension_id, event_name, args_copy.Pass(), restrict_to_profile, - GURL()); + scoped_ptr<Event> event(new Event(event_name, args_copy.Pass())); + event->restrict_to_profile = restrict_to_profile; + router->DispatchEventToExtension(extension_id, event.Pass()); } } } diff --git a/chrome/browser/extensions/api/processes/processes_api.cc b/chrome/browser/extensions/api/processes/processes_api.cc index ffabf93..50ee12f 100644 --- a/chrome/browser/extensions/api/processes/processes_api.cc +++ b/chrome/browser/extensions/api/processes/processes_api.cc @@ -470,9 +470,10 @@ void ProcessesEventRouter::ProcessClosedEvent( void ProcessesEventRouter::DispatchEvent(const char* event_name, scoped_ptr<ListValue> event_args) { if (extensions::ExtensionSystem::Get(profile_)->event_router()) { + scoped_ptr<extensions::Event> event(new extensions::Event( + event_name, event_args.Pass())); extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToRenderers(event_name, event_args.Pass(), NULL, GURL(), - extensions::EventFilteringInfo()); + BroadcastEvent(event.Pass()); } } diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc b/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc index d92305a..d4405be 100644 --- a/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc +++ b/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc @@ -104,12 +104,11 @@ void PushMessagingEventRouter::OnMessage(const std::string& extension_id, message.payload = payload; scoped_ptr<base::ListValue> args(glue::OnMessage::Create(message)); + scoped_ptr<extensions::Event> event(new extensions::Event( + event_names::kOnPushMessage, args.Pass())); + event->restrict_to_profile = profile_; ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( - extension_id, - event_names::kOnPushMessage, - args.Pass(), - profile_, - GURL()); + extension_id, event.Pass()); } void PushMessagingEventRouter::Observe( diff --git a/chrome/browser/extensions/api/rtc_private/rtc_private_api.cc b/chrome/browser/extensions/api/rtc_private/rtc_private_api.cc index ea9c31d..04afc5a 100644 --- a/chrome/browser/extensions/api/rtc_private/rtc_private_api.cc +++ b/chrome/browser/extensions/api/rtc_private/rtc_private_api.cc @@ -91,12 +91,10 @@ void GetContactIntentData(const Contact& contact, void RtcPrivateEventRouter::DispatchLaunchEvent( Profile* profile, LaunchAction action, const Contact* contact) { if (action == RtcPrivateEventRouter::LAUNCH_ACTIVATE) { - extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToRenderers( - kOnLaunchEvent, - scoped_ptr<ListValue>(new ListValue()), - profile, - GURL()); + scoped_ptr<Event> event(new Event( + kOnLaunchEvent, make_scoped_ptr(new ListValue()))); + event->restrict_to_profile = profile; + ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); } else { DCHECK(contact); extensions::api::rtc_private::LaunchData launch_data; @@ -104,12 +102,10 @@ void RtcPrivateEventRouter::DispatchLaunchEvent( GetContactIntentData(*contact, &launch_data.intent.data.additional_properties); launch_data.intent.type = kMimeTypeJson; - extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToRenderers( - kOnLaunchEvent, - extensions::api::rtc_private::OnLaunch::Create(launch_data), - profile, - GURL()); + scoped_ptr<Event> event(new Event( + kOnLaunchEvent, api::rtc_private::OnLaunch::Create(launch_data))); + event->restrict_to_profile = profile; + ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); } } diff --git a/chrome/browser/extensions/api/runtime/runtime_api.cc b/chrome/browser/extensions/api/runtime/runtime_api.cc index 538e8d9..2d97e3a 100644 --- a/chrome/browser/extensions/api/runtime/runtime_api.cc +++ b/chrome/browser/extensions/api/runtime/runtime_api.cc @@ -69,8 +69,8 @@ static void DispatchOnStartupEventImpl( } scoped_ptr<base::ListValue> event_args(new ListValue()); - system->event_router()->DispatchEventToExtension( - extension_id, kOnStartupEvent, event_args.Pass(), NULL, GURL()); + scoped_ptr<Event> event(new Event(kOnStartupEvent, event_args.Pass())); + system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); } } // namespace @@ -109,8 +109,8 @@ void RuntimeEventRouter::DispatchOnInstalledEvent( } DCHECK(system->event_router()); system->event_router()->AddLazyEventListener(kOnInstalledEvent, extension_id); - system->event_router()->DispatchEventToExtension( - extension_id, kOnInstalledEvent, event_args.Pass(), NULL, GURL()); + scoped_ptr<Event> event(new Event(kOnInstalledEvent, event_args.Pass())); + system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); system->event_router()->RemoveLazyEventListener(kOnInstalledEvent, extension_id); } @@ -127,8 +127,8 @@ void RuntimeEventRouter::DispatchOnUpdateAvailableEvent( scoped_ptr<ListValue> args(new ListValue); args->Append(manifest->DeepCopy()); DCHECK(system->event_router()); - system->event_router()->DispatchEventToExtension( - extension_id, kOnUpdateAvailableEvent, args.Pass(), NULL, GURL()); + scoped_ptr<Event> event(new Event(kOnUpdateAvailableEvent, args.Pass())); + system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); } bool RuntimeGetBackgroundPageFunction::RunImpl() { diff --git a/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.cc b/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.cc index 97e59a3..29309e3 100644 --- a/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.cc +++ b/chrome/browser/extensions/api/sync_file_system/extension_sync_event_observer.cc @@ -139,17 +139,18 @@ void ExtensionSyncEventObserver::BroadcastOrDispatchEvent( EventRouter* event_router = ExtensionSystem::Get(profile_)->event_router(); DCHECK(event_router); + scoped_ptr<Event> event(new Event(event_name, values.Pass())); + event->restrict_to_profile = profile_; + // No app_origin, broadcast to all listening extensions for this event name. if (broadcast_mode) { - event_router->DispatchEventToRenderers(event_name, values.Pass(), profile_, - GURL()); + event_router->BroadcastEvent(event.Pass()); return; } // Dispatch to single extension ID. const std::string extension_id = GetExtensionId(app_origin); - event_router->DispatchEventToExtension(extension_id, event_name, - values.Pass(), profile_, GURL()); + event_router->DispatchEventToExtension(extension_id, event.Pass()); } } // namespace extensions diff --git a/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc b/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc index acc1cdf..df2655c 100644 --- a/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc +++ b/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc @@ -81,8 +81,10 @@ void TabCaptureRegistry::HandleRequestUpdateOnUIThread( scoped_ptr<base::ListValue> args(new ListValue()); args->Append(info->ToValue().release()); - router->DispatchEventToExtension(request_info.extension_id, - events::kOnTabCaptureStatusChanged, args.Pass(), profile_, GURL()); + scoped_ptr<Event> event(new Event( + events::kOnTabCaptureStatusChanged, args.Pass())); + event->restrict_to_profile = profile_; + router->DispatchEventToExtension(request_info.extension_id, event.Pass()); } const TabCaptureRegistry::CaptureRequestList diff --git a/chrome/browser/extensions/api/terminal/terminal_private_api.cc b/chrome/browser/extensions/api/terminal/terminal_private_api.cc index 094ff29..621ddb8 100644 --- a/chrome/browser/extensions/api/terminal/terminal_private_api.cc +++ b/chrome/browser/extensions/api/terminal/terminal_private_api.cc @@ -58,10 +58,10 @@ void NotifyProcessOutput(Profile* profile, if (profile && extensions::ExtensionSystem::Get(profile)->event_router()) { + scoped_ptr<extensions::Event> event(new extensions::Event( + extensions::event_names::kOnTerminalProcessOutput, args.Pass())); extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToExtension(extension_id, - extensions::event_names::kOnTerminalProcessOutput, args.Pass(), - NULL, GURL()); + DispatchEventToExtension(extension_id, event.Pass()); } } diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_api_helpers.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_api_helpers.cc index 590a2b1..58bf3c6 100644 --- a/chrome/browser/extensions/api/web_navigation/web_navigation_api_helpers.cc +++ b/chrome/browser/extensions/api/web_navigation/web_navigation_api_helpers.cc @@ -44,9 +44,10 @@ void DispatchEvent(content::BrowserContext* browser_context, Profile* profile = Profile::FromBrowserContext(browser_context); if (profile && extensions::ExtensionSystem::Get(profile)->event_router()) { - extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToRenderers(event_name, args.Pass(), profile, GURL(), - info); + scoped_ptr<Event> event(new Event(event_name, args.Pass())); + event->restrict_to_profile = profile; + event->filter_info = info; + ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); } } diff --git a/chrome/browser/extensions/browser_event_router.cc b/chrome/browser/extensions/browser_event_router.cc index 9783e7f..0b372d7 100644 --- a/chrome/browser/extensions/browser_event_router.cc +++ b/chrome/browser/extensions/browser_event_router.cc @@ -362,9 +362,10 @@ void BrowserEventRouter::DispatchEvent( !extensions::ExtensionSystem::Get(profile)->event_router()) return; - extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToRenderers(event_name, args.Pass(), profile, GURL(), - user_gesture); + scoped_ptr<Event> event(new Event(event_name, args.Pass())); + event->restrict_to_profile = profile; + event->user_gesture = user_gesture; + ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); } void BrowserEventRouter::DispatchEventToExtension( @@ -377,9 +378,11 @@ void BrowserEventRouter::DispatchEventToExtension( !extensions::ExtensionSystem::Get(profile)->event_router()) return; - extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToExtension(extension_id, event_name, event_args.Pass(), - profile, GURL(), user_gesture); + scoped_ptr<Event> event(new Event(event_name, event_args.Pass())); + event->restrict_to_profile = profile; + event->user_gesture = user_gesture; + ExtensionSystem::Get(profile)->event_router()-> + DispatchEventToExtension(extension_id, event.Pass()); } void BrowserEventRouter::DispatchSimpleBrowserEvent( diff --git a/chrome/browser/extensions/event_router.cc b/chrome/browser/extensions/event_router.cc index fbfa823..58b4937 100644 --- a/chrome/browser/extensions/event_router.cc +++ b/chrome/browser/extensions/event_router.cc @@ -334,68 +334,6 @@ bool EventRouter::HasEventListenerImpl(const ListenerMap& listener_map, return false; } -void EventRouter::DispatchEventToRenderers(const std::string& event_name, - scoped_ptr<ListValue> event_args, - Profile* restrict_to_profile, - const GURL& event_url, - EventFilteringInfo info) { - linked_ptr<Event> event(new Event(event_name, event_args.Pass(), - scoped_ptr<ListValue>(), - restrict_to_profile, event_url, - USER_GESTURE_UNKNOWN, info)); - DispatchEventImpl("", event); -} - -void EventRouter::DispatchEventToRenderers(const std::string& event_name, - scoped_ptr<ListValue> event_args, - Profile* restrict_to_profile, - const GURL& event_url) { - DispatchEventToRenderers(event_name, event_args.Pass(), restrict_to_profile, - event_url, EventFilteringInfo()); -} - -void EventRouter::DispatchEventToRenderers(const std::string& event_name, - scoped_ptr<ListValue> event_args, - Profile* restrict_to_profile, - const GURL& event_url, - UserGestureState user_gesture) { - EventFilteringInfo info; - linked_ptr<Event> event(new Event(event_name, event_args.Pass(), - scoped_ptr<ListValue>(), - restrict_to_profile, event_url, - user_gesture, info)); - DispatchEventImpl("", event); -} - -void EventRouter::DispatchEventToExtension(const std::string& extension_id, - const std::string& event_name, - scoped_ptr<ListValue> event_args, - Profile* restrict_to_profile, - const GURL& event_url) { - DCHECK(!extension_id.empty()); - linked_ptr<Event> event(new Event(event_name, event_args.Pass(), - scoped_ptr<ListValue>(), - restrict_to_profile, event_url, - USER_GESTURE_UNKNOWN, - EventFilteringInfo())); - DispatchEventImpl(extension_id, event); -} - -void EventRouter::DispatchEventToExtension(const std::string& extension_id, - const std::string& event_name, - scoped_ptr<ListValue> event_args, - Profile* restrict_to_profile, - const GURL& event_url, - UserGestureState user_gesture) { - DCHECK(!extension_id.empty()); - linked_ptr<Event> event(new Event(event_name, event_args.Pass(), - scoped_ptr<ListValue>(), - restrict_to_profile, event_url, - user_gesture, - EventFilteringInfo())); - DispatchEventImpl(extension_id, event); -} - void EventRouter::BroadcastEvent(scoped_ptr<Event> event) { DispatchEventImpl("", linked_ptr<Event>(event.release())); } diff --git a/chrome/browser/extensions/event_router.h b/chrome/browser/extensions/event_router.h index a3c6061..eb30f78 100644 --- a/chrome/browser/extensions/event_router.h +++ b/chrome/browser/extensions/event_router.h @@ -131,52 +131,6 @@ class EventRouter : public content::NotificationObserver, virtual void DispatchEventToExtension(const std::string& extension_id, scoped_ptr<Event> event); - // TODO(mpcomplete): DEPRECATED. Remove this. http://crbug.com/163246 - // Send an event to every registered extension renderer. If - // |restrict_to_profile| is non-NULL, then the event will not be sent to other - // profiles unless the extension has permission (e.g. incognito tab update -> - // normal profile only works if extension is allowed incognito access). If - // |event_url| is not empty, the event is only sent to extension with host - // permissions for this url. - void DispatchEventToRenderers(const std::string& event_name, - scoped_ptr<base::ListValue> event_args, - Profile* restrict_to_profile, - const GURL& event_url, - EventFilteringInfo info); - - // TODO(mpcomplete): DEPRECATED. Remove this. http://crbug.com/163246 - // As above, but defaults |info| to EventFilteringInfo(). - void DispatchEventToRenderers(const std::string& event_name, - scoped_ptr<base::ListValue> event_args, - Profile* restrict_to_profile, - const GURL& event_url); - - // TODO(mpcomplete): DEPRECATED. Remove this. http://crbug.com/163246 - // As above, but enables sending an explicit user gesture indicator. - void DispatchEventToRenderers(const std::string& event_name, - scoped_ptr<ListValue> event_args, - Profile* restrict_to_profile, - const GURL& event_url, - UserGestureState user_gesture); - - // TODO(mpcomplete): DEPRECATED. Remove this. http://crbug.com/163246 - // Same as above, except only send the event to the given extension. - virtual void DispatchEventToExtension(const std::string& extension_id, - const std::string& event_name, - scoped_ptr<base::ListValue> event_args, - Profile* restrict_to_profile, - const GURL& event_url); - - // TODO(mpcomplete): DEPRECATED. Remove this. http://crbug.com/163246 - // Dispatch an event to particular extension. Also include an - // explicit user gesture indicator. - virtual void DispatchEventToExtension(const std::string& extension_id, - const std::string& event_name, - scoped_ptr<base::ListValue> event_args, - Profile* restrict_to_profile, - const GURL& event_url, - UserGestureState user_gesture); - // Record the Event Ack from the renderer. (One less event in-flight.) void OnEventAck(Profile* profile, const std::string& extension_id); diff --git a/chrome/browser/extensions/event_router_forwarder.cc b/chrome/browser/extensions/event_router_forwarder.cc index e14471f..7ebe511 100644 --- a/chrome/browser/extensions/event_router_forwarder.cc +++ b/chrome/browser/extensions/event_router_forwarder.cc @@ -112,16 +112,14 @@ void EventRouterForwarder::CallEventRouter(Profile* profile, if (!extensions::ExtensionSystem::Get(profile)->event_router()) return; + scoped_ptr<Event> event(new Event(event_name, event_args.Pass())); + event->restrict_to_profile = restrict_to_profile; + event->event_url = event_url; if (extension_id.empty()) { - extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToRenderers( - event_name, event_args.Pass(), restrict_to_profile, event_url, - EventFilteringInfo()); + ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); } else { - extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToExtension( - extension_id, - event_name, event_args.Pass(), restrict_to_profile, event_url); + ExtensionSystem::Get(profile)->event_router()-> + DispatchEventToExtension(extension_id, event.Pass()); } } diff --git a/chrome/browser/extensions/extension_devtools_bridge.cc b/chrome/browser/extensions/extension_devtools_bridge.cc index 61e8943..86d5bb5 100644 --- a/chrome/browser/extensions/extension_devtools_bridge.cc +++ b/chrome/browser/extensions/extension_devtools_bridge.cc @@ -108,10 +108,11 @@ void ExtensionDevToolsBridge::InspectedContentsClosing() { // event in extensions. scoped_ptr<base::ListValue> arguments(new base::ListValue()); arguments->Set(0, new base::DictionaryValue()); + scoped_ptr<extensions::Event> event(new extensions::Event( + on_tab_close_event_name_, arguments.Pass())); + event->restrict_to_profile = profile_; extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToRenderers( - on_tab_close_event_name_, arguments.Pass(), profile_, GURL(), - extensions::EventFilteringInfo()); + BroadcastEvent(event.Pass()); // This may result in this object being destroyed. extension_devtools_manager_->BridgeClosingForTab(tab_id_); @@ -126,10 +127,11 @@ void ExtensionDevToolsBridge::DispatchOnInspectorFrontend( arguments->Append(base::JSONReader::Read(data)); } + scoped_ptr<extensions::Event> event(new extensions::Event( + on_page_event_name_, arguments.Pass())); + event->restrict_to_profile = profile_; extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToRenderers( - on_page_event_name_, arguments.Pass(), profile_, GURL(), - extensions::EventFilteringInfo()); + BroadcastEvent(event.Pass()); } void ExtensionDevToolsBridge::ContentsReplaced(WebContents* new_contents) { diff --git a/chrome/browser/extensions/extension_messages_apitest.cc b/chrome/browser/extensions/extension_messages_apitest.cc index a4c8b30..af750c2 100644 --- a/chrome/browser/extensions/extension_messages_apitest.cc +++ b/chrome/browser/extensions/extension_messages_apitest.cc @@ -33,6 +33,17 @@ class MessageSender : public content::NotificationObserver { return arguments.Pass(); } + static scoped_ptr<extensions::Event> BuildEvent( + scoped_ptr<ListValue> event_args, + Profile* profile, + GURL event_url) { + scoped_ptr<extensions::Event> event(new extensions::Event( + "test.onMessage", event_args.Pass())); + event->restrict_to_profile = profile; + event->event_url = event_url; + return event.Pass(); + } + virtual void Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) { @@ -42,26 +53,22 @@ class MessageSender : public content::NotificationObserver { // Sends four messages to the extension. All but the third message sent // from the origin http://b.com/ are supposed to arrive. - event_router->DispatchEventToRenderers("test.onMessage", + event_router->BroadcastEvent(BuildEvent( BuildEventArguments(false, "no restriction"), content::Source<Profile>(source).ptr(), - GURL(), - extensions::EventFilteringInfo()); - event_router->DispatchEventToRenderers("test.onMessage", + GURL())); + event_router->BroadcastEvent(BuildEvent( BuildEventArguments(false, "http://a.com/"), content::Source<Profile>(source).ptr(), - GURL("http://a.com/"), - extensions::EventFilteringInfo()); - event_router->DispatchEventToRenderers("test.onMessage", + GURL("http://a.com/"))); + event_router->BroadcastEvent(BuildEvent( BuildEventArguments(false, "http://b.com/"), content::Source<Profile>(source).ptr(), - GURL("http://b.com/"), - extensions::EventFilteringInfo()); - event_router->DispatchEventToRenderers("test.onMessage", + GURL("http://b.com/"))); + event_router->BroadcastEvent(BuildEvent( BuildEventArguments(true, "last message"), content::Source<Profile>(source).ptr(), - GURL(), - extensions::EventFilteringInfo()); + GURL())); } content::NotificationRegistrar registrar_; diff --git a/chrome/browser/extensions/menu_manager.cc b/chrome/browser/extensions/menu_manager.cc index 3aa4915..769d7a3 100644 --- a/chrome/browser/extensions/menu_manager.cc +++ b/chrome/browser/extensions/menu_manager.cc @@ -675,14 +675,20 @@ void MenuManager::ExecuteCommand(Profile* profile, active_tab_permission_granter()->GrantIfRequested(extension); } - event_router->DispatchEventToExtension( - item->extension_id(), event_names::kOnContextMenus, - scoped_ptr<ListValue>(args->DeepCopy()), profile, GURL(), - EventRouter::USER_GESTURE_ENABLED); - event_router->DispatchEventToExtension( - item->extension_id(), event_names::kOnContextMenuClicked, - args.Pass(), profile, GURL(), - EventRouter::USER_GESTURE_ENABLED); + { + scoped_ptr<Event> event(new Event(event_names::kOnContextMenus, + scoped_ptr<ListValue>(args->DeepCopy()))); + event->restrict_to_profile = profile; + event->user_gesture = EventRouter::USER_GESTURE_ENABLED; + event_router->DispatchEventToExtension(item->extension_id(), event.Pass()); + } + { + scoped_ptr<Event> event(new Event(event_names::kOnContextMenuClicked, + args.Pass())); + event->restrict_to_profile = profile; + event->user_gesture = EventRouter::USER_GESTURE_ENABLED; + event_router->DispatchEventToExtension(item->extension_id(), event.Pass()); + } } void MenuManager::SanitizeRadioList(const MenuItem::List& item_list) { diff --git a/chrome/browser/extensions/menu_manager_unittest.cc b/chrome/browser/extensions/menu_manager_unittest.cc index c707144..b8a368d 100644 --- a/chrome/browser/extensions/menu_manager_unittest.cc +++ b/chrome/browser/extensions/menu_manager_unittest.cc @@ -457,13 +457,13 @@ class MockEventRouter : public EventRouter { EventRouter::UserGestureState state)); virtual void DispatchEventToExtension(const std::string& extension_id, - const std::string& event_name, - scoped_ptr<base::ListValue> event_args, - Profile* source_profile, - const GURL& event_url, - EventRouter::UserGestureState state) { - DispatchEventToExtensionMock(extension_id, event_name, event_args.release(), - source_profile, event_url, state); + scoped_ptr<Event> event) { + DispatchEventToExtensionMock(extension_id, + event->event_name, + event->event_args.release(), + event->restrict_to_profile, + event->event_url, + event->user_gesture); } private: diff --git a/chrome/browser/extensions/permissions_updater.cc b/chrome/browser/extensions/permissions_updater.cc index 57c5085..31b4653 100644 --- a/chrome/browser/extensions/permissions_updater.cc +++ b/chrome/browser/extensions/permissions_updater.cc @@ -173,11 +173,12 @@ void PermissionsUpdater::DispatchEvent( scoped_ptr<ListValue> value(new ListValue()); scoped_ptr<api::permissions::Permissions> permissions = - PackPermissionSet(changed_permissions); + PackPermissionSet(changed_permissions); value->Append(permissions->ToValue().release()); - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToExtension(extension_id, event_name, value.Pass(), - profile_, GURL()); + scoped_ptr<Event> event(new Event(event_name, value.Pass())); + event->restrict_to_profile = profile_; + ExtensionSystem::Get(profile_)->event_router()-> + DispatchEventToExtension(extension_id, event.Pass()); } void PermissionsUpdater::NotifyPermissionsUpdated( diff --git a/chrome/browser/extensions/settings/settings_frontend.cc b/chrome/browser/extensions/settings/settings_frontend.cc index 1d26b26..8b39905 100644 --- a/chrome/browser/extensions/settings/settings_frontend.cc +++ b/chrome/browser/extensions/settings/settings_frontend.cc @@ -48,9 +48,10 @@ class DefaultObserver : public SettingsObserver { args->Append(base::JSONReader::Read(change_json)); args->Append(Value::CreateStringValue(settings_namespace::ToString( settings_namespace))); - extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToExtension(extension_id, event_names::kOnSettingsChanged, - args.Pass(), NULL, GURL()); + scoped_ptr<Event> event(new Event( + event_names::kOnSettingsChanged, args.Pass())); + ExtensionSystem::Get(profile_)->event_router()-> + DispatchEventToExtension(extension_id, event.Pass()); } private: diff --git a/chrome/browser/extensions/window_event_router.cc b/chrome/browser/extensions/window_event_router.cc index 70c8c5d..5080694 100644 --- a/chrome/browser/extensions/window_event_router.cc +++ b/chrome/browser/extensions/window_event_router.cc @@ -149,8 +149,9 @@ void WindowEventRouter::OnActiveWindowChanged( void WindowEventRouter::DispatchEvent(const char* event_name, Profile* profile, scoped_ptr<base::ListValue> args) { - ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToRenderers(event_name, args.Pass(), profile, GURL()); + scoped_ptr<Event> event(new Event(event_name, args.Pass())); + event->restrict_to_profile = profile; + ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); } } // namespace extensions diff --git a/chrome/browser/history/history_extension_api.cc b/chrome/browser/history/history_extension_api.cc index 1397e31..a3a129c 100644 --- a/chrome/browser/history/history_extension_api.cc +++ b/chrome/browser/history/history_extension_api.cc @@ -190,9 +190,11 @@ void HistoryExtensionEventRouter::DispatchEvent( const char* event_name, scoped_ptr<ListValue> event_args) { if (profile && extensions::ExtensionSystem::Get(profile)->event_router()) { + scoped_ptr<extensions::Event> event(new extensions::Event( + event_name, event_args.Pass())); + event->restrict_to_profile = profile; extensions::ExtensionSystem::Get(profile)->event_router()-> - DispatchEventToRenderers(event_name, event_args.Pass(), profile, GURL(), - extensions::EventFilteringInfo()); + BroadcastEvent(event.Pass()); } } diff --git a/chrome/browser/speech/extension_api/tts_engine_extension_api.cc b/chrome/browser/speech/extension_api/tts_engine_extension_api.cc index 333646b..4d791a6 100644 --- a/chrome/browser/speech/extension_api/tts_engine_extension_api.cc +++ b/chrome/browser/speech/extension_api/tts_engine_extension_api.cc @@ -218,24 +218,20 @@ void ExtensionTtsEngineSpeak(Utterance* utterance, args->Set(1, options); args->Set(2, Value::CreateIntegerValue(utterance->id())); + scoped_ptr<extensions::Event> event(new extensions::Event( + tts_engine_events::kOnSpeak, args.Pass())); + event->restrict_to_profile = utterance->profile(); extensions::ExtensionSystem::Get(utterance->profile())->event_router()-> - DispatchEventToExtension( - extension->id(), - tts_engine_events::kOnSpeak, - args.Pass(), - utterance->profile(), - GURL()); + DispatchEventToExtension(utterance->extension_id(), event.Pass()); } void ExtensionTtsEngineStop(Utterance* utterance) { scoped_ptr<ListValue> args(new ListValue()); + scoped_ptr<extensions::Event> event(new extensions::Event( + tts_engine_events::kOnStop, args.Pass())); + event->restrict_to_profile = utterance->profile(); extensions::ExtensionSystem::Get(utterance->profile())->event_router()-> - DispatchEventToExtension( - utterance->extension_id(), - tts_engine_events::kOnStop, - args.Pass(), - utterance->profile(), - GURL()); + DispatchEventToExtension(utterance->extension_id(), event.Pass()); } bool ExtensionTtsEngineSendTtsEventFunction::RunImpl() { diff --git a/chrome/browser/speech/extension_api/tts_extension_api_controller.cc b/chrome/browser/speech/extension_api/tts_extension_api_controller.cc index 10ab0aa..7799790 100644 --- a/chrome/browser/speech/extension_api/tts_extension_api_controller.cc +++ b/chrome/browser/speech/extension_api/tts_extension_api_controller.cc @@ -109,22 +109,25 @@ void Utterance::OnTtsEvent(TtsEventType event_type, if (src_id_ < 0) return; - DictionaryValue* event = new DictionaryValue(); + DictionaryValue* details = new DictionaryValue(); if (char_index != kInvalidCharIndex) - event->SetInteger(constants::kCharIndexKey, char_index); - event->SetString(constants::kEventTypeKey, event_type_string); + details->SetInteger(constants::kCharIndexKey, char_index); + details->SetString(constants::kEventTypeKey, event_type_string); if (event_type == TTS_EVENT_ERROR) { - event->SetString(constants::kErrorMessageKey, error_message); + details->SetString(constants::kErrorMessageKey, error_message); } - event->SetInteger(constants::kSrcIdKey, src_id_); - event->SetBoolean(constants::kIsFinalEventKey, finished_); + details->SetInteger(constants::kSrcIdKey, src_id_); + details->SetBoolean(constants::kIsFinalEventKey, finished_); scoped_ptr<ListValue> arguments(new ListValue()); - arguments->Set(0, event); + arguments->Set(0, details); + scoped_ptr<extensions::Event> event(new extensions::Event( + events::kOnEvent, arguments.Pass())); + event->restrict_to_profile = profile_; + event->event_url = src_url_; extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToExtension(src_extension_id_, events::kOnEvent, - arguments.Pass(), profile_, src_url_); + DispatchEventToExtension(src_extension_id_, event.Pass()); } void Utterance::Finish() { diff --git a/chrome/browser/speech/speech_input_extension_manager.cc b/chrome/browser/speech/speech_input_extension_manager.cc index 2820937..a5cbd05 100644 --- a/chrome/browser/speech/speech_input_extension_manager.cc +++ b/chrome/browser/speech/speech_input_extension_manager.cc @@ -453,7 +453,7 @@ void SpeechInputExtensionManager::OnSoundEnd(int session_id) { } void SpeechInputExtensionManager::DispatchEventToExtension( - const std::string& extension_id, const std::string& event, + const std::string& extension_id, const std::string& event_name, scoped_ptr<ListValue> event_args) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); @@ -462,9 +462,11 @@ void SpeechInputExtensionManager::DispatchEventToExtension( return; if (profile_ && extensions::ExtensionSystem::Get(profile_)->event_router()) { + scoped_ptr<extensions::Event> event(new extensions::Event( + event_name, event_args.Pass())); + event->restrict_to_profile = profile_; extensions::ExtensionSystem::Get(profile_)->event_router()-> - DispatchEventToExtension(extension_id, event, event_args.Pass(), - profile_, GURL()); + DispatchEventToExtension(extension_id, event.Pass()); } } |