Index: Source/core/html/HTMLMediaElement.cpp |
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp |
index 91b9d3084f173b8da8c61e0dde318a5957380d9d..a45e756e455e7cd8693deeacc9fbbb479319d35c 100644 |
--- a/Source/core/html/HTMLMediaElement.cpp |
+++ b/Source/core/html/HTMLMediaElement.cpp |
@@ -2488,6 +2488,10 @@ void HTMLMediaElement::honorUserPreferencesForAutomaticTextTrackSelection() |
if (m_closedCaptionsVisible) |
configuration.forceEnableSubtitleOrCaptionTrack = true; |
+ Settings* settings = document().settings(); |
+ if (settings) |
+ configuration.textTrackKindUserPreference = settings->textTrackKindUserPreference(); |
+ |
AutomaticTrackSelection trackSelection(configuration); |
trackSelection.perform(*m_textTracks); |
@@ -3258,6 +3262,32 @@ void HTMLMediaElement::setClosedCaptionsVisible(bool closedCaptionVisible) |
updateTextTrackDisplay(); |
} |
+void HTMLMediaElement::setTextTrackKindUserPreferenceForAllMediaElements(Document* document) |
+{ |
+ WeakMediaElementSet elements = documentToElementSetMap().get(document); |
+ for (const auto& element: elements) |
+ element->automaticTrackSelectionForUpdatedUserPreference(); |
+} |
+ |
+void HTMLMediaElement::automaticTrackSelectionForUpdatedUserPreference() |
+{ |
+ markCaptionAndSubtitleTracksAsUnconfigured(); |
+ m_processingPreferenceChange = true; |
+ m_closedCaptionsVisible = false; |
+ honorUserPreferencesForAutomaticTextTrackSelection(); |
+ m_processingPreferenceChange = false; |
+ |
+ // If a track is set to showing post performing automatic track selection, |
+ // set closed captions state to visible to update the CC button and display the track. |
+ for (unsigned i = 0; i < m_textTracks->length(); ++i) { |
+ RefPtrWillBeRawPtr<TextTrack> textTrack = m_textTracks->item(i); |
+ if (textTrack->mode() == TextTrack::showingKeyword()) |
+ m_closedCaptionsVisible = true; |
+ } |
+ |
+ updateTextTrackDisplay(); |
+} |
+ |
void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured() |
{ |
if (!m_textTracks) |