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

Unified Diff: third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp

Issue 2803563004: Avoid using language hint in encoding detection (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp
diff --git a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp
index 0e20dbebc89de3228330e72fc4d3512658779694..0a4d454814eaa56b8ce4d66dc3e6a932a5e6671f 100644
--- a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp
+++ b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.cpp
@@ -159,9 +159,13 @@ TextResourceDecoder::TextResourceDecoder(
if (m_encodingDetectionOption == AlwaysUseUTF8ForText) {
DCHECK(m_contentType == PlainTextContent && m_encoding == UTF8Encoding());
} else if (m_encodingDetectionOption == UseAllAutoDetection) {
- // Checking empty URL helps unit testing. Providing defaultLanguage() is
+ // Obtain language hint from system locale:
+ // 1) In general, do not use language hint. This helps get more
+ // deterministic encoding detection results across devices. Note that local
+ // file resources can still benefit from the hint.
+ // 2) Checking empty URL helps unit testing. Providing defaultLanguage() is
// sometimes difficult in tests.
- if (!hintUrl.isEmpty()) {
+ if (hintUrl.protocol() == "file" || !hintUrl.isEmpty()) {
tkent 2017/04/06 07:29:13 The code is incorrect. http:// URLs are not isEmp
Jinsuk Kim 2017/04/06 08:10:25 My bad. Moved to TextEncodingDetector and updated
// This object is created in the main thread, but used in another thread.
// We should not share an AtomicString.
AtomicString locale = defaultLanguage();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698