Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: chrome/browser/chromeos/extensions/media_player_event_router.cc

Issue 11638024: Make MediaPlayerEventRouter a PKS to decouple it from ExtensionService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: patch rebased Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/event_router.h" 8 #include "chrome/browser/extensions/event_router.h"
9 #include "chrome/browser/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 11
12 namespace extensions {
13
12 static void BroadcastEvent(Profile* profile, const std::string& event_name) { 14 static void BroadcastEvent(Profile* profile, const std::string& event_name) {
13 if (profile && extensions::ExtensionSystem::Get(profile)->event_router()) { 15 if (profile && extensions::ExtensionSystem::Get(profile)->event_router()) {
14 scoped_ptr<ListValue> args(new ListValue()); 16 scoped_ptr<ListValue> args(new ListValue());
15 scoped_ptr<extensions::Event> event(new extensions::Event( 17 scoped_ptr<extensions::Event> event(new extensions::Event(
16 event_name, args.Pass())); 18 event_name, args.Pass()));
17 extensions::ExtensionSystem::Get(profile)->event_router()-> 19 extensions::ExtensionSystem::Get(profile)->event_router()->
18 BroadcastEvent(event.Pass()); 20 BroadcastEvent(event.Pass());
19 } 21 }
20 } 22 }
21 23
22 ExtensionMediaPlayerEventRouter::ExtensionMediaPlayerEventRouter() 24 MediaPlayerEventRouter::MediaPlayerEventRouter(Profile* profile)
23 : profile_(NULL) { 25 : profile_(profile) {
24 } 26 }
25 27
26 ExtensionMediaPlayerEventRouter* 28 MediaPlayerEventRouter::~MediaPlayerEventRouter() {
27 ExtensionMediaPlayerEventRouter::GetInstance() {
28 return Singleton<ExtensionMediaPlayerEventRouter>::get();
29 } 29 }
30 30
31 void ExtensionMediaPlayerEventRouter::Init(Profile* profile) { 31 void MediaPlayerEventRouter::NotifyNextTrack() {
32 profile_ = profile;
33 }
34
35 void ExtensionMediaPlayerEventRouter::NotifyNextTrack() {
36 BroadcastEvent(profile_, "mediaPlayerPrivate.onNextTrack"); 32 BroadcastEvent(profile_, "mediaPlayerPrivate.onNextTrack");
37 } 33 }
38 34
39 void ExtensionMediaPlayerEventRouter::NotifyPlaylistChanged() { 35 void MediaPlayerEventRouter::NotifyPlaylistChanged() {
40 BroadcastEvent(profile_, "mediaPlayerPrivate.onPlaylistChanged"); 36 BroadcastEvent(profile_, "mediaPlayerPrivate.onPlaylistChanged");
41 } 37 }
42 38
43 void ExtensionMediaPlayerEventRouter::NotifyPrevTrack() { 39 void MediaPlayerEventRouter::NotifyPrevTrack() {
44 BroadcastEvent(profile_, "mediaPlayerPrivate.onPrevTrack"); 40 BroadcastEvent(profile_, "mediaPlayerPrivate.onPrevTrack");
45 } 41 }
46 42
47 void ExtensionMediaPlayerEventRouter::NotifyTogglePlayState() { 43 void MediaPlayerEventRouter::NotifyTogglePlayState() {
48 BroadcastEvent(profile_, "mediaPlayerPrivate.onTogglePlayState"); 44 BroadcastEvent(profile_, "mediaPlayerPrivate.onTogglePlayState");
49 } 45 }
46
47 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/media_player_event_router.h ('k') | chrome/browser/chromeos/media/media_player.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698