| 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 <utility> |
| 8 |
| 7 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 8 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
| 9 #include "extensions/browser/event_router.h" | 11 #include "extensions/browser/event_router.h" |
| 10 #include "extensions/browser/extension_system.h" | 12 #include "extensions/browser/extension_system.h" |
| 11 | 13 |
| 12 namespace extensions { | 14 namespace extensions { |
| 13 | 15 |
| 14 namespace { | 16 namespace { |
| 15 | 17 |
| 16 void BroadcastEvent(content::BrowserContext* context, | 18 void BroadcastEvent(content::BrowserContext* context, |
| 17 events::HistogramValue histogram_value, | 19 events::HistogramValue histogram_value, |
| 18 const std::string& event_name) { | 20 const std::string& event_name) { |
| 19 if (context && EventRouter::Get(context)) { | 21 if (context && EventRouter::Get(context)) { |
| 20 scoped_ptr<base::ListValue> args(new base::ListValue()); | 22 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 21 scoped_ptr<Event> event( | 23 scoped_ptr<Event> event( |
| 22 new Event(histogram_value, event_name, args.Pass())); | 24 new Event(histogram_value, event_name, std::move(args))); |
| 23 EventRouter::Get(context)->BroadcastEvent(event.Pass()); | 25 EventRouter::Get(context)->BroadcastEvent(std::move(event)); |
| 24 } | 26 } |
| 25 } | 27 } |
| 26 | 28 |
| 27 } // namespace | 29 } // namespace |
| 28 | 30 |
| 29 MediaPlayerEventRouter::MediaPlayerEventRouter(content::BrowserContext* context) | 31 MediaPlayerEventRouter::MediaPlayerEventRouter(content::BrowserContext* context) |
| 30 : browser_context_(context) {} | 32 : browser_context_(context) {} |
| 31 | 33 |
| 32 MediaPlayerEventRouter::~MediaPlayerEventRouter() { | 34 MediaPlayerEventRouter::~MediaPlayerEventRouter() { |
| 33 } | 35 } |
| 34 | 36 |
| 35 void MediaPlayerEventRouter::NotifyNextTrack() { | 37 void MediaPlayerEventRouter::NotifyNextTrack() { |
| 36 BroadcastEvent(browser_context_, events::MEDIA_PLAYER_PRIVATE_ON_NEXT_TRACK, | 38 BroadcastEvent(browser_context_, events::MEDIA_PLAYER_PRIVATE_ON_NEXT_TRACK, |
| 37 "mediaPlayerPrivate.onNextTrack"); | 39 "mediaPlayerPrivate.onNextTrack"); |
| 38 } | 40 } |
| 39 | 41 |
| 40 void MediaPlayerEventRouter::NotifyPrevTrack() { | 42 void MediaPlayerEventRouter::NotifyPrevTrack() { |
| 41 BroadcastEvent(browser_context_, events::MEDIA_PLAYER_PRIVATE_ON_PREV_TRACK, | 43 BroadcastEvent(browser_context_, events::MEDIA_PLAYER_PRIVATE_ON_PREV_TRACK, |
| 42 "mediaPlayerPrivate.onPrevTrack"); | 44 "mediaPlayerPrivate.onPrevTrack"); |
| 43 } | 45 } |
| 44 | 46 |
| 45 void MediaPlayerEventRouter::NotifyTogglePlayState() { | 47 void MediaPlayerEventRouter::NotifyTogglePlayState() { |
| 46 BroadcastEvent(browser_context_, | 48 BroadcastEvent(browser_context_, |
| 47 events::MEDIA_PLAYER_PRIVATE_ON_TOGGLE_PLAY_STATE, | 49 events::MEDIA_PLAYER_PRIVATE_ON_TOGGLE_PLAY_STATE, |
| 48 "mediaPlayerPrivate.onTogglePlayState"); | 50 "mediaPlayerPrivate.onTogglePlayState"); |
| 49 } | 51 } |
| 50 | 52 |
| 51 } // namespace extensions | 53 } // namespace extensions |
| OLD | NEW |