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