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. 4 5 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" 6 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" 11 12 namespace extensions { 13 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()); 21 } 22 } 23 24 MediaPlayerEventRouter::MediaPlayerEventRouter(content::BrowserContext* context) 25 : browser_context_(context) {} 26 27 MediaPlayerEventRouter::~MediaPlayerEventRouter() { 28 } 29 30 void MediaPlayerEventRouter::NotifyNextTrack() { 31 BroadcastEvent(browser_context_, "mediaPlayerPrivate.onNextTrack"); 32 } 33 34 void MediaPlayerEventRouter::NotifyPrevTrack() { 35 BroadcastEvent(browser_context_, "mediaPlayerPrivate.onPrevTrack"); 36 } 37 38 void MediaPlayerEventRouter::NotifyTogglePlayState() { 39 BroadcastEvent(browser_context_, "mediaPlayerPrivate.onTogglePlayState"); 40 } 41 42 } // namespace extensions 43