OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 return 0; | 253 return 0; |
254 } | 254 } |
255 addResourceToArchive(resource.get(), archive.get()); | 255 addResourceToArchive(resource.get(), archive.get()); |
256 } | 256 } |
257 | 257 |
258 return archive.release(); | 258 return archive.release(); |
259 } | 259 } |
260 | 260 |
261 void MHTMLParser::addResourceToArchive(ArchiveResource* resource, MHTMLArchive*
archive) | 261 void MHTMLParser::addResourceToArchive(ArchiveResource* resource, MHTMLArchive*
archive) |
262 { | 262 { |
263 const String& mimeType = resource->mimeType(); | 263 const AtomicString& mimeType = resource->mimeType(); |
264 if (!MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType) || MIMETypeRegi
stry::isSupportedJavaScriptMIMEType(mimeType) || mimeType == "text/css") { | 264 if (!MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType) || MIMETypeRegi
stry::isSupportedJavaScriptMIMEType(mimeType) || mimeType == "text/css") { |
265 m_resources.append(resource); | 265 m_resources.append(resource); |
266 return; | 266 return; |
267 } | 267 } |
268 | 268 |
269 // The first document suitable resource is the main frame. | 269 // The first document suitable resource is the main frame. |
270 if (!archive->mainResource()) { | 270 if (!archive->mainResource()) { |
271 archive->setMainResource(resource); | 271 archive->setMainResource(resource); |
272 m_frames.append(archive); | 272 m_frames.append(archive); |
273 return; | 273 return; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 break; | 357 break; |
358 default: | 358 default: |
359 WTF_LOG_ERROR("Invalid encoding for MHTML part."); | 359 WTF_LOG_ERROR("Invalid encoding for MHTML part."); |
360 return 0; | 360 return 0; |
361 } | 361 } |
362 RefPtr<SharedBuffer> contentBuffer = SharedBuffer::adoptVector(data); | 362 RefPtr<SharedBuffer> contentBuffer = SharedBuffer::adoptVector(data); |
363 // FIXME: the URL in the MIME header could be relative, we should resolve it
if it is. | 363 // FIXME: the URL in the MIME header could be relative, we should resolve it
if it is. |
364 // The specs mentions 5 ways to resolve a URL: http://tools.ietf.org/html/rf
c2557#section-5 | 364 // The specs mentions 5 ways to resolve a URL: http://tools.ietf.org/html/rf
c2557#section-5 |
365 // IE and Firefox (UNMht) seem to generate only absolute URLs. | 365 // IE and Firefox (UNMht) seem to generate only absolute URLs. |
366 KURL location = KURL(KURL(), mimeHeader.contentLocation()); | 366 KURL location = KURL(KURL(), mimeHeader.contentLocation()); |
367 return ArchiveResource::create(contentBuffer, location, mimeHeader.contentTy
pe(), mimeHeader.charset(), String()); | 367 return ArchiveResource::create(contentBuffer, location, AtomicString(mimeHea
der.contentType()), AtomicString(mimeHeader.charset()), String()); |
368 } | 368 } |
369 | 369 |
370 size_t MHTMLParser::frameCount() const | 370 size_t MHTMLParser::frameCount() const |
371 { | 371 { |
372 return m_frames.size(); | 372 return m_frames.size(); |
373 } | 373 } |
374 | 374 |
375 MHTMLArchive* MHTMLParser::frameAt(size_t index) const | 375 MHTMLArchive* MHTMLParser::frameAt(size_t index) const |
376 { | 376 { |
377 return m_frames[index].get(); | 377 return m_frames[index].get(); |
378 } | 378 } |
379 | 379 |
380 size_t MHTMLParser::subResourceCount() const | 380 size_t MHTMLParser::subResourceCount() const |
381 { | 381 { |
382 return m_resources.size(); | 382 return m_resources.size(); |
383 } | 383 } |
384 | 384 |
385 ArchiveResource* MHTMLParser::subResourceAt(size_t index) const | 385 ArchiveResource* MHTMLParser::subResourceAt(size_t index) const |
386 { | 386 { |
387 return m_resources[index].get(); | 387 return m_resources[index].get(); |
388 } | 388 } |
389 | 389 |
390 } | 390 } |
OLD | NEW |