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

Side by Side Diff: Source/core/xml/XMLHttpRequest.cpp

Issue 151653004: Implemented Document.contentType (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: review comments Created 6 years, 10 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 { 235 {
236 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo nseTypeDocument) { 236 if (m_responseTypeCode != ResponseTypeDefault && m_responseTypeCode != Respo nseTypeDocument) {
237 exceptionState.throwDOMException(InvalidStateError, "The value is only a ccessible if the object's 'responseType' is '' or 'document' (was '" + responseT ype() + "')."); 237 exceptionState.throwDOMException(InvalidStateError, "The value is only a ccessible if the object's 'responseType' is '' or 'document' (was '" + responseT ype() + "').");
238 return 0; 238 return 0;
239 } 239 }
240 240
241 if (m_error || m_state != DONE) 241 if (m_error || m_state != DONE)
242 return 0; 242 return 0;
243 243
244 if (!m_createdDocument) { 244 if (!m_createdDocument) {
245 bool isHTML = equalIgnoringCase(responseMIMEType(), "text/html"); 245 AtomicString mimeType = responseMIMEType();
246 bool isHTML = equalIgnoringCase(mimeType, "text/html");
246 247
247 // The W3C spec requires the final MIME type to be some valid XML type, or text/html. 248 // The W3C spec requires the final MIME type to be some valid XML type, or text/html.
248 // If it is text/html, then the responseType of "document" must have bee n supplied explicitly. 249 // If it is text/html, then the responseType of "document" must have bee n supplied explicitly.
249 if ((m_response.isHTTP() && !responseIsXML() && !isHTML) 250 if ((m_response.isHTTP() && !responseIsXML() && !isHTML)
250 || (isHTML && m_responseTypeCode == ResponseTypeDefault) 251 || (isHTML && m_responseTypeCode == ResponseTypeDefault)
251 || executionContext()->isWorkerGlobalScope()) { 252 || executionContext()->isWorkerGlobalScope()) {
252 m_responseDocument = 0; 253 m_responseDocument = 0;
253 } else { 254 } else {
254 DocumentInit init = DocumentInit::fromContext(document()->contextDoc ument(), m_url); 255 DocumentInit init = DocumentInit::fromContext(document()->contextDoc ument(), m_url);
255 if (isHTML) 256 if (isHTML)
256 m_responseDocument = HTMLDocument::create(init); 257 m_responseDocument = HTMLDocument::create(init);
257 else 258 else
258 m_responseDocument = Document::create(init); 259 m_responseDocument = Document::create(init);
259 // FIXME: Set Last-Modified. 260 // FIXME: Set Last-Modified.
260 m_responseDocument->setContent(m_responseText.flattenToString()); 261 m_responseDocument->setContent(m_responseText.flattenToString());
261 m_responseDocument->setSecurityOrigin(securityOrigin()); 262 m_responseDocument->setSecurityOrigin(securityOrigin());
262 m_responseDocument->setContextFeatures(document()->contextFeatures() ); 263 m_responseDocument->setContextFeatures(document()->contextFeatures() );
264 m_responseDocument->setMimeType(mimeType);
263 if (!m_responseDocument->wellFormed()) 265 if (!m_responseDocument->wellFormed())
264 m_responseDocument = 0; 266 m_responseDocument = 0;
265 } 267 }
266 m_createdDocument = true; 268 m_createdDocument = true;
267 } 269 }
268 270
269 return m_responseDocument.get(); 271 return m_responseDocument.get();
270 } 272 }
271 273
272 Blob* XMLHttpRequest::responseBlob() 274 Blob* XMLHttpRequest::responseBlob()
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 { 1423 {
1422 return EventTargetNames::XMLHttpRequest; 1424 return EventTargetNames::XMLHttpRequest;
1423 } 1425 }
1424 1426
1425 ExecutionContext* XMLHttpRequest::executionContext() const 1427 ExecutionContext* XMLHttpRequest::executionContext() const
1426 { 1428 {
1427 return ActiveDOMObject::executionContext(); 1429 return ActiveDOMObject::executionContext();
1428 } 1430 }
1429 1431
1430 } // namespace WebCore 1432 } // namespace WebCore
OLDNEW
« LayoutTests/http/tests/dom/document-contentType-xhr.html ('K') | « Source/core/dom/Document.idl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698