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

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

Issue 1456843002: Finch experiment: auto-detect text encoding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 5 years 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: third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h
diff --git a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h
index 2539cc8a68577c5e20da2b757637e3e510931e27..ad167e2a128fbd956a7d430de0629e8af4251dd2 100644
--- a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h
+++ b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h
@@ -37,6 +37,7 @@ class CORE_EXPORT TextResourceDecoder {
public:
enum EncodingSource {
DefaultEncoding,
+ DefaultEncodingAttemptedSniffing,
AutoDetectedEncoding,
EncodingFromContentSniffing,
EncodingFromXMLHeader,
@@ -57,6 +58,18 @@ public:
bool encodingWasDetectedHeuristically() const
{
return m_source == AutoDetectedEncoding
+ || m_source == EncodingFromContentSniffing
+ || m_source == DefaultEncodingAttemptedSniffing;
+ }
+
+ bool encodingWasDetectedFromContentSniffing() const
+ {
+ return m_source == EncodingFromContentSniffing;
+ }
+
+ bool attemptedToDetermineEncodingFromContentSniffing() const
+ {
+ return m_source == DefaultEncodingAttemptedSniffing
|| m_source == EncodingFromContentSniffing;
}
@@ -83,6 +96,7 @@ private:
bool checkForXMLCharset(const char*, size_t, bool& movedDataToBuffer);
void checkForMetaCharset(const char*, size_t);
bool shouldAutoDetect() const;
+ void detectTextEncoding(const char*, size_t);
ContentType m_contentType;
WTF::TextEncoding m_encoding;

Powered by Google App Engine
This is Rietveld 408576698