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