| 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/mediasession/MediaMetadata.h" | 5 #include "modules/mediasession/MediaMetadata.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "bindings/core/v8/ToV8.h" | 9 #include "bindings/core/v8/ToV8.h" |
| 10 #include "core/dom/ExecutionContext.h" |
| 10 #include "core/dom/TaskRunnerHelper.h" | 11 #include "core/dom/TaskRunnerHelper.h" |
| 11 #include "modules/mediasession/MediaImage.h" | 12 #include "modules/mediasession/MediaImage.h" |
| 12 #include "modules/mediasession/MediaMetadataInit.h" | 13 #include "modules/mediasession/MediaMetadataInit.h" |
| 13 #include "modules/mediasession/MediaSession.h" | 14 #include "modules/mediasession/MediaSession.h" |
| 14 | 15 |
| 15 namespace blink { | 16 namespace blink { |
| 16 | 17 |
| 17 // static | 18 // static |
| 18 MediaMetadata* MediaMetadata::Create(ScriptState* script_state, | 19 MediaMetadata* MediaMetadata::Create(ScriptState* script_state, |
| 19 const MediaMetadataInit& metadata, | 20 const MediaMetadataInit& metadata, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 return; | 100 return; |
| 100 session_->OnMetadataChanged(); | 101 session_->OnMetadataChanged(); |
| 101 } | 102 } |
| 102 | 103 |
| 103 void MediaMetadata::SetArtworkInternal(ScriptState* script_state, | 104 void MediaMetadata::SetArtworkInternal(ScriptState* script_state, |
| 104 const HeapVector<MediaImage>& artwork, | 105 const HeapVector<MediaImage>& artwork, |
| 105 ExceptionState& exception_state) { | 106 ExceptionState& exception_state) { |
| 106 HeapVector<MediaImage> processed_artwork(artwork); | 107 HeapVector<MediaImage> processed_artwork(artwork); |
| 107 | 108 |
| 108 for (MediaImage& image : processed_artwork) { | 109 for (MediaImage& image : processed_artwork) { |
| 109 KURL url = script_state->GetExecutionContext()->CompleteURL(image.src()); | 110 KURL url = ExecutionContext::From(script_state)->CompleteURL(image.src()); |
| 110 if (!url.IsValid()) { | 111 if (!url.IsValid()) { |
| 111 exception_state.ThrowTypeError("'" + image.src() + | 112 exception_state.ThrowTypeError("'" + image.src() + |
| 112 "' can't be resolved to a valid URL."); | 113 "' can't be resolved to a valid URL."); |
| 113 return; | 114 return; |
| 114 } | 115 } |
| 115 image.setSrc(url); | 116 image.setSrc(url); |
| 116 } | 117 } |
| 117 | 118 |
| 118 DCHECK(!exception_state.HadException()); | 119 DCHECK(!exception_state.HadException()); |
| 119 artwork_.Swap(processed_artwork); | 120 artwork_.Swap(processed_artwork); |
| 120 } | 121 } |
| 121 | 122 |
| 122 DEFINE_TRACE(MediaMetadata) { | 123 DEFINE_TRACE(MediaMetadata) { |
| 123 visitor->Trace(artwork_); | 124 visitor->Trace(artwork_); |
| 124 visitor->Trace(session_); | 125 visitor->Trace(session_); |
| 125 } | 126 } |
| 126 | 127 |
| 127 } // namespace blink | 128 } // namespace blink |
| OLD | NEW |