OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 "modules/mediasession/NavigatorMediaSession.h" |
| 6 |
| 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 8 #include "modules/mediasession/MediaSession.h" |
| 9 #include "platform/Supplementable.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 NavigatorMediaSession::NavigatorMediaSession(Navigator& navigator) |
| 14 { |
| 15 } |
| 16 |
| 17 DEFINE_TRACE(NavigatorMediaSession) |
| 18 { |
| 19 visitor->trace(m_session); |
| 20 Supplement<Navigator>::trace(visitor); |
| 21 } |
| 22 |
| 23 const char* NavigatorMediaSession::supplementName() |
| 24 { |
| 25 return "NavigatorMediaSession"; |
| 26 } |
| 27 |
| 28 NavigatorMediaSession& NavigatorMediaSession::from(Navigator& navigator) |
| 29 { |
| 30 NavigatorMediaSession* supplement = static_cast<NavigatorMediaSession*>(Supp
lement<Navigator>::from(navigator, supplementName())); |
| 31 if (!supplement) { |
| 32 supplement = new NavigatorMediaSession(navigator); |
| 33 provideTo(navigator, supplementName(), supplement); |
| 34 } |
| 35 return *supplement; |
| 36 } |
| 37 |
| 38 MediaSession* NavigatorMediaSession::mediaSession(Navigator& navigator) |
| 39 { |
| 40 NavigatorMediaSession& self = NavigatorMediaSession::from(navigator); |
| 41 if (!self.m_session) |
| 42 self.m_session = MediaSession::create(navigator.frame(), IGNORE_EXCEPTIO
N); |
| 43 return self.m_session.get(); |
| 44 } |
| 45 } |
OLD | NEW |