| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "modules/audio_output_devices/AudioOutputDeviceClient.h" | 5 #include "modules/audio_output_devices/AudioOutputDeviceClient.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
| 9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 10 | 10 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 const char* AudioOutputDeviceClient::supplementName() { | 13 const char* AudioOutputDeviceClient::supplementName() { |
| 14 return "AudioOutputDeviceClient"; | 14 return "AudioOutputDeviceClient"; |
| 15 } | 15 } |
| 16 | 16 |
| 17 AudioOutputDeviceClient* AudioOutputDeviceClient::from( | 17 AudioOutputDeviceClient* AudioOutputDeviceClient::from( |
| 18 ExecutionContext* context) { | 18 ExecutionContext* context) { |
| 19 if (!context->isDocument()) | 19 if (!context || !context->isDocument()) |
| 20 return nullptr; | 20 return nullptr; |
| 21 | 21 |
| 22 const Document* document = toDocument(context); | 22 const Document* document = toDocument(context); |
| 23 if (!document->frame()) | 23 if (!document->frame()) |
| 24 return nullptr; | 24 return nullptr; |
| 25 | 25 |
| 26 return static_cast<AudioOutputDeviceClient*>( | 26 return static_cast<AudioOutputDeviceClient*>( |
| 27 Supplement<LocalFrame>::from(document->frame(), supplementName())); | 27 Supplement<LocalFrame>::from(document->frame(), supplementName())); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void provideAudioOutputDeviceClientTo(LocalFrame& frame, | 30 void provideAudioOutputDeviceClientTo(LocalFrame& frame, |
| 31 AudioOutputDeviceClient* client) { | 31 AudioOutputDeviceClient* client) { |
| 32 frame.provideSupplement(AudioOutputDeviceClient::supplementName(), client); | 32 frame.provideSupplement(AudioOutputDeviceClient::supplementName(), client); |
| 33 } | 33 } |
| 34 | 34 |
| 35 DEFINE_TRACE(AudioOutputDeviceClient) { | 35 DEFINE_TRACE(AudioOutputDeviceClient) { |
| 36 Supplement<LocalFrame>::trace(visitor); | 36 Supplement<LocalFrame>::trace(visitor); |
| 37 } | 37 } |
| 38 | 38 |
| 39 } // namespace blink | 39 } // namespace blink |
| OLD | NEW |