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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/extensions/media_player_event_router.h"
7 #include "base/memory/singleton.h"
8 #include "content/public/browser/browser_context.h"
9 #include "extensions/browser/event_router.h"
10 #include "extensions/browser/extension_system.h"
12 namespace extensions
{
14 static void BroadcastEvent(content::BrowserContext
* context
,
15 const std::string
& event_name
) {
16 if (context
&& EventRouter::Get(context
)) {
17 scoped_ptr
<base::ListValue
> args(new base::ListValue());
18 scoped_ptr
<extensions::Event
> event(new extensions::Event(
19 event_name
, args
.Pass()));
20 EventRouter::Get(context
)->BroadcastEvent(event
.Pass());
24 MediaPlayerEventRouter::MediaPlayerEventRouter(content::BrowserContext
* context
)
25 : browser_context_(context
) {}
27 MediaPlayerEventRouter::~MediaPlayerEventRouter() {
30 void MediaPlayerEventRouter::NotifyNextTrack() {
31 BroadcastEvent(browser_context_
, "mediaPlayerPrivate.onNextTrack");
34 void MediaPlayerEventRouter::NotifyPrevTrack() {
35 BroadcastEvent(browser_context_
, "mediaPlayerPrivate.onPrevTrack");
38 void MediaPlayerEventRouter::NotifyTogglePlayState() {
39 BroadcastEvent(browser_context_
, "mediaPlayerPrivate.onTogglePlayState");
42 } // namespace extensions