This source file includes following definitions.
- BroadcastEvent
- NotifyNextTrack
- NotifyPrevTrack
- NotifyTogglePlayState
#include "chrome/browser/chromeos/extensions/media_player_event_router.h"
#include "base/memory/singleton.h"
#include "content/public/browser/browser_context.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_system.h"
namespace extensions {
static void BroadcastEvent(content::BrowserContext* context,
const std::string& event_name) {
if (context && extensions::ExtensionSystem::Get(context)->event_router()) {
scoped_ptr<base::ListValue> args(new base::ListValue());
scoped_ptr<extensions::Event> event(new extensions::Event(
event_name, args.Pass()));
extensions::ExtensionSystem::Get(context)->event_router()->BroadcastEvent(
event.Pass());
}
}
MediaPlayerEventRouter::MediaPlayerEventRouter(content::BrowserContext* context)
: browser_context_(context) {}
MediaPlayerEventRouter::~MediaPlayerEventRouter() {
}
void MediaPlayerEventRouter::NotifyNextTrack() {
BroadcastEvent(browser_context_, "mediaPlayerPrivate.onNextTrack");
}
void MediaPlayerEventRouter::NotifyPrevTrack() {
BroadcastEvent(browser_context_, "mediaPlayerPrivate.onPrevTrack");
}
void MediaPlayerEventRouter::NotifyTogglePlayState() {
BroadcastEvent(browser_context_, "mediaPlayerPrivate.onTogglePlayState");
}
}