| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 : m_mimeType(mimeType), m_encoding(encoding) {} | 94 : m_mimeType(mimeType), m_encoding(encoding) {} |
| 95 | 95 |
| 96 TextResourceDecoderBuilder::~TextResourceDecoderBuilder() {} | 96 TextResourceDecoderBuilder::~TextResourceDecoderBuilder() {} |
| 97 | 97 |
| 98 inline std::unique_ptr<TextResourceDecoder> | 98 inline std::unique_ptr<TextResourceDecoder> |
| 99 TextResourceDecoderBuilder::createDecoderInstance(Document* document) { | 99 TextResourceDecoderBuilder::createDecoderInstance(Document* document) { |
| 100 const WTF::TextEncoding encodingFromDomain = | 100 const WTF::TextEncoding encodingFromDomain = |
| 101 getEncodingFromDomain(document->url()); | 101 getEncodingFromDomain(document->url()); |
| 102 if (LocalFrame* frame = document->frame()) { | 102 if (LocalFrame* frame = document->frame()) { |
| 103 if (Settings* settings = frame->settings()) { | 103 if (Settings* settings = frame->settings()) { |
| 104 const WTF::TextEncoding hintEncoding = |
| 105 encodingFromDomain.isValid() ? encodingFromDomain |
| 106 : settings->getDefaultTextEncodingName(); |
| 104 // Disable autodetection for XML to honor the default encoding (UTF-8) for | 107 // Disable autodetection for XML to honor the default encoding (UTF-8) for |
| 105 // unlabelled documents. | 108 // unlabelled documents. |
| 106 return TextResourceDecoder::create( | 109 if (DOMImplementation::isXMLMIMEType(m_mimeType)) |
| 107 m_mimeType, | 110 return TextResourceDecoder::create(m_mimeType, hintEncoding); |
| 108 encodingFromDomain.isValid() ? encodingFromDomain | 111 return TextResourceDecoder::createWithAutoDetection( |
| 109 : settings->getDefaultTextEncodingName(), | 112 m_mimeType, hintEncoding, document->url()); |
| 110 !DOMImplementation::isXMLMIMEType(m_mimeType)); | |
| 111 } | 113 } |
| 112 } | 114 } |
| 113 | 115 |
| 114 return TextResourceDecoder::create(m_mimeType, encodingFromDomain); | 116 return TextResourceDecoder::create(m_mimeType, encodingFromDomain); |
| 115 } | 117 } |
| 116 | 118 |
| 117 inline void TextResourceDecoderBuilder::setupEncoding( | 119 inline void TextResourceDecoderBuilder::setupEncoding( |
| 118 TextResourceDecoder* decoder, | 120 TextResourceDecoder* decoder, |
| 119 Document* document) { | 121 Document* document) { |
| 120 LocalFrame* frame = document->frame(); | 122 LocalFrame* frame = document->frame(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 createDecoderInstance(document); | 154 createDecoderInstance(document); |
| 153 setupEncoding(decoder.get(), document); | 155 setupEncoding(decoder.get(), document); |
| 154 return decoder; | 156 return decoder; |
| 155 } | 157 } |
| 156 | 158 |
| 157 void TextResourceDecoderBuilder::clear() { | 159 void TextResourceDecoderBuilder::clear() { |
| 158 m_encoding = nullAtom; | 160 m_encoding = nullAtom; |
| 159 } | 161 } |
| 160 | 162 |
| 161 } // namespace blink | 163 } // namespace blink |
| OLD | NEW |