| 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 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/loader/TextResourceDecoderBuilder.h" | 31 #include "core/loader/TextResourceDecoderBuilder.h" |
| 32 | 32 |
| 33 #include "core/dom/DOMImplementation.h" |
| 33 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
| 34 #include "core/frame/LocalFrame.h" | 35 #include "core/frame/LocalFrame.h" |
| 35 #include "core/frame/Settings.h" | 36 #include "core/frame/Settings.h" |
| 36 #include "platform/weborigin/SecurityOrigin.h" | 37 #include "platform/weborigin/SecurityOrigin.h" |
| 37 #include <memory> | 38 #include <memory> |
| 38 | 39 |
| 39 namespace blink { | 40 namespace blink { |
| 40 | 41 |
| 41 static inline bool canReferToParentFrameEncoding(const LocalFrame* frame, const
LocalFrame* parentFrame) | 42 static inline bool canReferToParentFrameEncoding(const LocalFrame* frame, const
LocalFrame* parentFrame) |
| 42 { | 43 { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 127 |
| 127 TextResourceDecoderBuilder::~TextResourceDecoderBuilder() | 128 TextResourceDecoderBuilder::~TextResourceDecoderBuilder() |
| 128 { | 129 { |
| 129 } | 130 } |
| 130 | 131 |
| 131 | 132 |
| 132 inline std::unique_ptr<TextResourceDecoder> TextResourceDecoderBuilder::createDe
coderInstance(Document* document) | 133 inline std::unique_ptr<TextResourceDecoder> TextResourceDecoderBuilder::createDe
coderInstance(Document* document) |
| 133 { | 134 { |
| 134 const WTF::TextEncoding encodingFromDomain = getEncodingFromDomain(document-
>url()); | 135 const WTF::TextEncoding encodingFromDomain = getEncodingFromDomain(document-
>url()); |
| 135 if (LocalFrame* frame = document->frame()) { | 136 if (LocalFrame* frame = document->frame()) { |
| 136 if (Settings* settings = frame->settings()) | 137 if (Settings* settings = frame->settings()) { |
| 137 return TextResourceDecoder::create(m_mimeType, encodingFromDomain.is
Valid() ? encodingFromDomain : settings->defaultTextEncodingName(), true); | 138 // Disable autodetection for XML to honor the default encoding (UTF-
8) for unlabelled documents. |
| 139 return TextResourceDecoder::create(m_mimeType, encodingFromDomain.is
Valid() ? encodingFromDomain : settings->defaultTextEncodingName(), !DOMImplemen
tation::isXMLMIMEType(m_mimeType)); |
| 140 } |
| 138 } | 141 } |
| 139 | 142 |
| 140 return TextResourceDecoder::create(m_mimeType, encodingFromDomain); | 143 return TextResourceDecoder::create(m_mimeType, encodingFromDomain); |
| 141 } | 144 } |
| 142 | 145 |
| 143 inline void TextResourceDecoderBuilder::setupEncoding(TextResourceDecoder* decod
er, Document* document) | 146 inline void TextResourceDecoderBuilder::setupEncoding(TextResourceDecoder* decod
er, Document* document) |
| 144 { | 147 { |
| 145 LocalFrame* frame = document->frame(); | 148 LocalFrame* frame = document->frame(); |
| 146 LocalFrame* parentFrame = 0; | 149 LocalFrame* parentFrame = 0; |
| 147 if (frame && frame->tree().parent() && frame->tree().parent()->isLocalFrame(
)) | 150 if (frame && frame->tree().parent() && frame->tree().parent()->isLocalFrame(
)) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 174 setupEncoding(decoder.get(), document); | 177 setupEncoding(decoder.get(), document); |
| 175 return decoder; | 178 return decoder; |
| 176 } | 179 } |
| 177 | 180 |
| 178 void TextResourceDecoderBuilder::clear() | 181 void TextResourceDecoderBuilder::clear() |
| 179 { | 182 { |
| 180 m_encoding = nullAtom; | 183 m_encoding = nullAtom; |
| 181 } | 184 } |
| 182 | 185 |
| 183 } // namespace blink | 186 } // namespace blink |
| OLD | NEW |