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..8d894b5bf81d49abb83a062d03559d16457ae676 100644 |
--- a/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h |
+++ b/third_party/WebKit/Source/core/html/parser/TextResourceDecoder.h |
@@ -46,9 +46,18 @@ public: |
EncodingFromParentFrame |
}; |
- static PassOwnPtr<TextResourceDecoder> create(const String& mimeType, const WTF::TextEncoding& defaultEncoding = WTF::TextEncoding(), bool usesEncodingDetector = false) |
+ enum BOMCheckOptions { |
+ CheckForAllBOM, |
+ // create("text/plain", UTF8Encoding(), false, CheckForOnlyUTF8BOM) |
+ // always uses UTF8Encoding() and omits utf-8 BOM, and thus |
+ // corresponds to utf-8 decode in Encoding spec: |
+ // https://encoding.spec.whatwg.org/#utf-8-decode |
+ CheckForOnlyUTF8BOM |
+ }; |
+ |
+ static PassOwnPtr<TextResourceDecoder> create(const String& mimeType, const WTF::TextEncoding& defaultEncoding = WTF::TextEncoding(), bool usesEncodingDetector = false, BOMCheckOptions bomCheckOptions = CheckForAllBOM) |
{ |
- return adoptPtr(new TextResourceDecoder(mimeType, defaultEncoding, usesEncodingDetector)); |
+ return adoptPtr(new TextResourceDecoder(mimeType, defaultEncoding, usesEncodingDetector, bomCheckOptions)); |
} |
~TextResourceDecoder(); |
@@ -73,7 +82,7 @@ public: |
size_t checkForBOM(const char*, size_t); |
private: |
- TextResourceDecoder(const String& mimeType, const WTF::TextEncoding& defaultEncoding, bool usesEncodingDetector); |
+ TextResourceDecoder(const String& mimeType, const WTF::TextEncoding& defaultEncoding, bool usesEncodingDetector, BOMCheckOptions); |
enum ContentType { PlainTextContent, HTMLContent, XMLContent, CSSContent }; // PlainText only checks for BOM. |
static ContentType determineContentType(const String& mimeType); |
@@ -97,6 +106,7 @@ private: |
bool m_useLenientXMLDecoding; // Don't stop on XML decoding errors. |
bool m_sawError; |
bool m_usesEncodingDetector; |
+ BOMCheckOptions m_bomCheckOptions; |
OwnPtr<HTMLMetaCharsetParser> m_charsetParser; |
}; |