| 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 "core/html/track/AutomaticTrackSelection.h" | 5 #include "core/html/track/AutomaticTrackSelection.h" |
| 6 | 6 |
| 7 #include "core/html/track/TextTrack.h" | 7 #include "core/html/track/TextTrack.h" |
| 8 #include "core/html/track/TextTrackList.h" | 8 #include "core/html/track/TextTrackList.h" |
| 9 #include "platform/Language.h" | 9 #include "platform/Language.h" |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 Vector<AtomicString> languages = userPreferredLanguages(); | 43 Vector<AtomicString> languages = userPreferredLanguages(); |
| 44 size_t languageMatchIndex = indexOfBestMatchingLanguageInList(track.language
(), languages); | 44 size_t languageMatchIndex = indexOfBestMatchingLanguageInList(track.language
(), languages); |
| 45 if (languageMatchIndex >= languages.size()) | 45 if (languageMatchIndex >= languages.size()) |
| 46 return 0; | 46 return 0; |
| 47 | 47 |
| 48 return languages.size() - languageMatchIndex; | 48 return languages.size() - languageMatchIndex; |
| 49 } | 49 } |
| 50 | 50 |
| 51 static int textTrackSelectionScore(const TextTrack& track) | 51 static int textTrackSelectionScore(const TextTrack& track) |
| 52 { | 52 { |
| 53 if (track.kind() != TextTrack::captionsKeyword() && track.kind() != TextTrac
k::subtitlesKeyword()) | 53 if (!track.isVisualKind()) |
| 54 return 0; | 54 return 0; |
| 55 | 55 |
| 56 return textTrackLanguageSelectionScore(track); | 56 return textTrackLanguageSelectionScore(track); |
| 57 } | 57 } |
| 58 | 58 |
| 59 AutomaticTrackSelection::AutomaticTrackSelection(const Configuration& configurat
ion) | 59 AutomaticTrackSelection::AutomaticTrackSelection(const Configuration& configurat
ion) |
| 60 : m_configuration(configuration) | 60 : m_configuration(configuration) |
| 61 { | 61 { |
| 62 } | 62 } |
| 63 | 63 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 performAutomaticTextTrackSelection(captionAndSubtitleTracks); | 207 performAutomaticTextTrackSelection(captionAndSubtitleTracks); |
| 208 if (descriptionTracks.tracks.size()) | 208 if (descriptionTracks.tracks.size()) |
| 209 performAutomaticTextTrackSelection(descriptionTracks); | 209 performAutomaticTextTrackSelection(descriptionTracks); |
| 210 if (chapterTracks.tracks.size()) | 210 if (chapterTracks.tracks.size()) |
| 211 performAutomaticTextTrackSelection(chapterTracks); | 211 performAutomaticTextTrackSelection(chapterTracks); |
| 212 if (metadataTracks.tracks.size()) | 212 if (metadataTracks.tracks.size()) |
| 213 enableDefaultMetadataTextTracks(metadataTracks); | 213 enableDefaultMetadataTextTracks(metadataTracks); |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace blink | 216 } // namespace blink |
| OLD | NEW |