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

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: Addressed lgtm comment and rebased Created 5 years, 5 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
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/track/AutomaticTrackSelection.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLMediaElement.cpp
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index d54063bc82c74555f0549169bf7833739a6ab926..e905c8905d3cdb9f0a85e36d437d9eaacd134618 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -2490,6 +2490,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);
@@ -3266,6 +3270,27 @@ 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.
+ m_closedCaptionsVisible = m_textTracks->hasShowingTracks();
+ updateTextTrackDisplay();
+}
+
void HTMLMediaElement::markCaptionAndSubtitleTracksAsUnconfigured()
{
if (!m_textTracks)
@@ -3385,13 +3410,7 @@ void HTMLMediaElement::configureTextTrackDisplay(VisibilityChangeAssumption assu
if (m_processingPreferenceChange)
return;
- bool haveVisibleTextTrack = false;
- for (unsigned i = 0; i < m_textTracks->length(); ++i) {
- if (m_textTracks->item(i)->mode() == TextTrack::showingKeyword()) {
- haveVisibleTextTrack = true;
- break;
- }
- }
+ bool haveVisibleTextTrack = m_textTracks->hasShowingTracks();
if (assumption == AssumeNoVisibleChange
&& m_haveVisibleTextTrack == haveVisibleTextTrack) {
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/track/AutomaticTrackSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698