Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1191)

Unified Diff: Source/core/html/HTMLMediaElement.cpp

Issue 1118613002: Hook up Android closed captions 'enabled' setting to Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated automatic track selection logic Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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)

Powered by Google App Engine
This is Rietveld 408576698