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

Side by Side Diff: third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp

Issue 1890103002: Reland "UTF-8 detector for pages missing encoding info" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org>
4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org>
5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved.
6 * Copyright (C) 2012 Intel Corporation 6 * Copyright (C) 2012 Intel Corporation
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 m_responseDocumentParser->setDecoder(createDecoder()); 1532 m_responseDocumentParser->setDecoder(createDecoder());
1533 1533
1534 m_responseDocumentParser->appendBytes(data, len); 1534 m_responseDocumentParser->appendBytes(data, len);
1535 } 1535 }
1536 1536
1537 PassOwnPtr<TextResourceDecoder> XMLHttpRequest::createDecoder() const 1537 PassOwnPtr<TextResourceDecoder> XMLHttpRequest::createDecoder() const
1538 { 1538 {
1539 if (m_responseTypeCode == ResponseTypeJSON) 1539 if (m_responseTypeCode == ResponseTypeJSON)
1540 return TextResourceDecoder::create("application/json", "UTF-8"); 1540 return TextResourceDecoder::create("application/json", "UTF-8");
1541 1541
1542 if (!m_finalResponseCharset.isEmpty()) 1542 if (!m_finalResponseCharset.isEmpty()) {
1543 return TextResourceDecoder::create("text/plain", m_finalResponseCharset) ; 1543 OwnPtr<TextResourceDecoder> decoder(TextResourceDecoder::create("text/pl ain"));
1544 decoder->setEncoding(WTF::TextEncoding(m_finalResponseCharset), TextReso urceDecoder::EncodingFromHTTPHeader);
1545 return decoder.release();
1546 }
1544 1547
1545 // allow TextResourceDecoder to look inside the m_response if it's XML or HT ML 1548 // allow TextResourceDecoder to look inside the m_response if it's XML or HT ML
1546 if (responseIsXML()) { 1549 if (responseIsXML()) {
1547 OwnPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("appli cation/xml"); 1550 OwnPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("appli cation/xml");
1548 // Don't stop on encoding errors, unlike it is done for other kinds 1551 // Don't stop on encoding errors, unlike it is done for other kinds
1549 // of XML resources. This matches the behavior of previous WebKit 1552 // of XML resources. This matches the behavior of previous WebKit
1550 // versions, Firefox and Opera. 1553 // versions, Firefox and Opera.
1551 decoder->useLenientXMLDecoding(); 1554 decoder->useLenientXMLDecoding();
1552 1555
1553 return decoder.release(); 1556 return decoder.release();
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 visitor->trace(m_responseArrayBuffer); 1702 visitor->trace(m_responseArrayBuffer);
1700 visitor->trace(m_progressEventThrottle); 1703 visitor->trace(m_progressEventThrottle);
1701 visitor->trace(m_upload); 1704 visitor->trace(m_upload);
1702 visitor->trace(m_blobLoader); 1705 visitor->trace(m_blobLoader);
1703 XMLHttpRequestEventTarget::trace(visitor); 1706 XMLHttpRequestEventTarget::trace(visitor);
1704 DocumentParserClient::trace(visitor); 1707 DocumentParserClient::trace(visitor);
1705 ActiveDOMObject::trace(visitor); 1708 ActiveDOMObject::trace(visitor);
1706 } 1709 }
1707 1710
1708 } // namespace blink 1711 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698