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
{
16 void BroadcastEvent(content::BrowserContext
* context
,
17 events::HistogramValue histogram_value
,
18 const std::string
& event_name
) {
19 if (context
&& EventRouter::Get(context
)) {
20 scoped_ptr
<base::ListValue
> args(new base::ListValue());
21 scoped_ptr
<Event
> event(
22 new Event(histogram_value
, event_name
, args
.Pass()));
23 EventRouter::Get(context
)->BroadcastEvent(event
.Pass());
29 MediaPlayerEventRouter::MediaPlayerEventRouter(content::BrowserContext
* context
)
30 : browser_context_(context
) {}
32 MediaPlayerEventRouter::~MediaPlayerEventRouter() {
35 void MediaPlayerEventRouter::NotifyNextTrack() {
36 BroadcastEvent(browser_context_
, events::MEDIA_PLAYER_PRIVATE_ON_NEXT_TRACK
,
37 "mediaPlayerPrivate.onNextTrack");
40 void MediaPlayerEventRouter::NotifyPrevTrack() {
41 BroadcastEvent(browser_context_
, events::MEDIA_PLAYER_PRIVATE_ON_PREV_TRACK
,
42 "mediaPlayerPrivate.onPrevTrack");
45 void MediaPlayerEventRouter::NotifyTogglePlayState() {
46 BroadcastEvent(browser_context_
,
47 events::MEDIA_PLAYER_PRIVATE_ON_TOGGLE_PLAY_STATE
,
48 "mediaPlayerPrivate.onTogglePlayState");
51 } // namespace extensions