| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" | 5 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "chrome/browser/extensions/extension_system.h" | 8 #include "chrome/browser/extensions/extension_system.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "extensions/browser/event_router.h" | 10 #include "extensions/browser/event_router.h" |
| 11 | 11 |
| 12 namespace extensions { | 12 namespace extensions { |
| 13 | 13 |
| 14 static void BroadcastEvent(Profile* profile, const std::string& event_name) { | 14 static void BroadcastEvent(Profile* profile, const std::string& event_name) { |
| 15 if (profile && extensions::ExtensionSystem::Get(profile)->event_router()) { | 15 if (profile && extensions::ExtensionSystem::Get(profile)->event_router()) { |
| 16 scoped_ptr<ListValue> args(new ListValue()); | 16 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 17 scoped_ptr<extensions::Event> event(new extensions::Event( | 17 scoped_ptr<extensions::Event> event(new extensions::Event( |
| 18 event_name, args.Pass())); | 18 event_name, args.Pass())); |
| 19 extensions::ExtensionSystem::Get(profile)->event_router()-> | 19 extensions::ExtensionSystem::Get(profile)->event_router()-> |
| 20 BroadcastEvent(event.Pass()); | 20 BroadcastEvent(event.Pass()); |
| 21 } | 21 } |
| 22 } | 22 } |
| 23 | 23 |
| 24 MediaPlayerEventRouter::MediaPlayerEventRouter(Profile* profile) | 24 MediaPlayerEventRouter::MediaPlayerEventRouter(Profile* profile) |
| 25 : profile_(profile) { | 25 : profile_(profile) { |
| 26 } | 26 } |
| 27 | 27 |
| 28 MediaPlayerEventRouter::~MediaPlayerEventRouter() { | 28 MediaPlayerEventRouter::~MediaPlayerEventRouter() { |
| 29 } | 29 } |
| 30 | 30 |
| 31 void MediaPlayerEventRouter::NotifyNextTrack() { | 31 void MediaPlayerEventRouter::NotifyNextTrack() { |
| 32 BroadcastEvent(profile_, "mediaPlayerPrivate.onNextTrack"); | 32 BroadcastEvent(profile_, "mediaPlayerPrivate.onNextTrack"); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void MediaPlayerEventRouter::NotifyPrevTrack() { | 35 void MediaPlayerEventRouter::NotifyPrevTrack() { |
| 36 BroadcastEvent(profile_, "mediaPlayerPrivate.onPrevTrack"); | 36 BroadcastEvent(profile_, "mediaPlayerPrivate.onPrevTrack"); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void MediaPlayerEventRouter::NotifyTogglePlayState() { | 39 void MediaPlayerEventRouter::NotifyTogglePlayState() { |
| 40 BroadcastEvent(profile_, "mediaPlayerPrivate.onTogglePlayState"); | 40 BroadcastEvent(profile_, "mediaPlayerPrivate.onTogglePlayState"); |
| 41 } | 41 } |
| 42 | 42 |
| 43 } // namespace extensions | 43 } // namespace extensions |
| OLD | NEW |