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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 break; | 379 break; |
380 | 380 |
381 default: | 381 default: |
382 ASSERT_NOT_REACHED(); | 382 ASSERT_NOT_REACHED(); |
383 } | 383 } |
384 } | 384 } |
385 | 385 |
386 bool FrameSerializer::shouldAddURL(const KURL& url) | 386 bool FrameSerializer::shouldAddURL(const KURL& url) |
387 { | 387 { |
388 return url.isValid() && !m_resourceURLs.contains(url) && !url.protocolIsData
() | 388 return url.isValid() && !m_resourceURLs.contains(url) && !url.protocolIsData
() |
389 && !m_delegate.shouldSkipResource(url); | 389 && !m_delegate.shouldSkipResourceWithURL(url); |
390 } | 390 } |
391 | 391 |
392 void FrameSerializer::addToResources(Resource* resource, PassRefPtr<SharedBuffer
> data, const KURL& url) | 392 void FrameSerializer::addToResources(const Resource& resource, PassRefPtr<Shared
Buffer> data, const KURL& url) |
393 { | 393 { |
| 394 if (m_delegate.shouldSkipResource(resource)) |
| 395 return; |
| 396 |
394 if (!data) { | 397 if (!data) { |
395 DLOG(ERROR) << "No data for resource " << url.getString(); | 398 DLOG(ERROR) << "No data for resource " << url.getString(); |
396 return; | 399 return; |
397 } | 400 } |
398 | 401 |
399 String mimeType = resource->response().mimeType(); | 402 String mimeType = resource.response().mimeType(); |
400 m_resources->append(SerializedResource(url, mimeType, data)); | 403 m_resources->append(SerializedResource(url, mimeType, data)); |
401 m_resourceURLs.add(url); | 404 m_resourceURLs.add(url); |
402 } | 405 } |
403 | 406 |
404 void FrameSerializer::addImageToResources(ImageResource* image, const KURL& url) | 407 void FrameSerializer::addImageToResources(ImageResource* image, const KURL& url) |
405 { | 408 { |
406 if (!image || !image->hasImage() || image->errorOccurred() || !shouldAddURL(
url)) | 409 if (!image || !image->hasImage() || image->errorOccurred() || !shouldAddURL(
url)) |
407 return; | 410 return; |
408 | 411 |
409 RefPtr<SharedBuffer> data = image->getImage()->data(); | 412 RefPtr<SharedBuffer> data = image->getImage()->data(); |
410 addToResources(image, data, url); | 413 addToResources(*image, data, url); |
411 } | 414 } |
412 | 415 |
413 void FrameSerializer::addFontToResources(FontResource* font) | 416 void FrameSerializer::addFontToResources(FontResource* font) |
414 { | 417 { |
415 if (!font || !font->isLoaded() || !font->resourceBuffer() || !shouldAddURL(f
ont->url())) | 418 if (!font || !font->isLoaded() || !font->resourceBuffer() || !shouldAddURL(f
ont->url())) |
416 return; | 419 return; |
417 | 420 |
418 RefPtr<SharedBuffer> data(font->resourceBuffer()); | 421 RefPtr<SharedBuffer> data(font->resourceBuffer()); |
419 | 422 |
420 addToResources(font, data, font->url()); | 423 addToResources(*font, data, font->url()); |
421 } | 424 } |
422 | 425 |
423 void FrameSerializer::retrieveResourcesForProperties(const StylePropertySet* sty
leDeclaration, Document& document) | 426 void FrameSerializer::retrieveResourcesForProperties(const StylePropertySet* sty
leDeclaration, Document& document) |
424 { | 427 { |
425 if (!styleDeclaration) | 428 if (!styleDeclaration) |
426 return; | 429 return; |
427 | 430 |
428 // The background-image and list-style-image (for ul or ol) are the CSS prop
erties | 431 // The background-image and list-style-image (for ul or ol) are the CSS prop
erties |
429 // that make use of images. We iterate to make sure we include any other | 432 // that make use of images. We iterate to make sure we include any other |
430 // image properties there might be. | 433 // image properties there might be. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 continue; | 479 continue; |
477 } | 480 } |
478 emitsMinus = ch == '-'; | 481 emitsMinus = ch == '-'; |
479 builder.append(ch); | 482 builder.append(ch); |
480 } | 483 } |
481 CString escapedUrl = builder.toString().ascii(); | 484 CString escapedUrl = builder.toString().ascii(); |
482 return String::format("saved from url=(%04d)%s", static_cast<int>(escapedUrl
.length()), escapedUrl.data()); | 485 return String::format("saved from url=(%04d)%s", static_cast<int>(escapedUrl
.length()), escapedUrl.data()); |
483 } | 486 } |
484 | 487 |
485 } // namespace blink | 488 } // namespace blink |
OLD | NEW |