| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #include "public/platform/WebVector.h" | 52 #include "public/platform/WebVector.h" |
| 53 #include "public/web/WebFrame.h" | 53 #include "public/web/WebFrame.h" |
| 54 #include "public/web/WebPageSerializerClient.h" | 54 #include "public/web/WebPageSerializerClient.h" |
| 55 #include "public/web/WebView.h" | 55 #include "public/web/WebView.h" |
| 56 #include "web/WebLocalFrameImpl.h" | 56 #include "web/WebLocalFrameImpl.h" |
| 57 #include "web/WebPageSerializerImpl.h" | 57 #include "web/WebPageSerializerImpl.h" |
| 58 #include "web/WebViewImpl.h" | 58 #include "web/WebViewImpl.h" |
| 59 #include "wtf/Vector.h" | 59 #include "wtf/Vector.h" |
| 60 #include "wtf/text/StringConcatenate.h" | 60 #include "wtf/text/StringConcatenate.h" |
| 61 | 61 |
| 62 using namespace blink; | 62 namespace blink { |
| 63 | 63 |
| 64 namespace { | 64 namespace { |
| 65 | 65 |
| 66 KURL getSubResourceURLFromElement(Element* element) | 66 KURL getSubResourceURLFromElement(Element* element) |
| 67 { | 67 { |
| 68 ASSERT(element); | 68 ASSERT(element); |
| 69 const QualifiedName& attributeName = element->subResourceAttributeName(); | 69 const QualifiedName& attributeName = element->subResourceAttributeName(); |
| 70 if (attributeName == QualifiedName::null()) | 70 if (attributeName == QualifiedName::null()) |
| 71 return KURL(); | 71 return KURL(); |
| 72 | 72 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 102 // Ignore URLs that have a non-standard protocols. Since the FTP protocol | 102 // Ignore URLs that have a non-standard protocols. Since the FTP protocol |
| 103 // does no have a cache mechanism, we skip it as well. | 103 // does no have a cache mechanism, we skip it as well. |
| 104 if (!url.protocolIsInHTTPFamily() && !url.isLocalFile()) | 104 if (!url.protocolIsInHTTPFamily() && !url.isLocalFile()) |
| 105 return; | 105 return; |
| 106 | 106 |
| 107 if (!resourceURLs->contains(url)) | 107 if (!resourceURLs->contains(url)) |
| 108 resourceURLs->append(url); | 108 resourceURLs->append(url); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void retrieveResourcesForFrame(LocalFrame* frame, | 111 void retrieveResourcesForFrame(LocalFrame* frame, |
| 112 const blink::WebVector<blink::WebCString>& suppor
tedSchemes, | 112 const WebVector<WebCString>& supportedSchemes, |
| 113 Vector<LocalFrame*>* visitedFrames, | 113 Vector<LocalFrame*>* visitedFrames, |
| 114 Vector<LocalFrame*>* framesToVisit, | 114 Vector<LocalFrame*>* framesToVisit, |
| 115 Vector<KURL>* frameURLs, | 115 Vector<KURL>* frameURLs, |
| 116 Vector<KURL>* resourceURLs) | 116 Vector<KURL>* resourceURLs) |
| 117 { | 117 { |
| 118 KURL frameURL = frame->loader().documentLoader()->request().url(); | 118 KURL frameURL = frame->loader().documentLoader()->request().url(); |
| 119 | 119 |
| 120 // If the frame's URL is invalid, ignore it, it is not retrievable. | 120 // If the frame's URL is invalid, ignore it, it is not retrievable. |
| 121 if (!frameURL.isValid()) | 121 if (!frameURL.isValid()) |
| 122 return; | 122 return; |
| 123 | 123 |
| 124 // Ignore frames from unsupported schemes. | 124 // Ignore frames from unsupported schemes. |
| 125 bool isValidScheme = false; | 125 bool isValidScheme = false; |
| 126 for (size_t i = 0; i < supportedSchemes.size(); ++i) { | 126 for (size_t i = 0; i < supportedSchemes.size(); ++i) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 144 for (unsigned i = 0; i < allElements->length(); ++i) { | 144 for (unsigned i = 0; i < allElements->length(); ++i) { |
| 145 Element* element = allElements->item(i); | 145 Element* element = allElements->item(i); |
| 146 retrieveResourcesForElement(element, | 146 retrieveResourcesForElement(element, |
| 147 visitedFrames, framesToVisit, | 147 visitedFrames, framesToVisit, |
| 148 frameURLs, resourceURLs); | 148 frameURLs, resourceURLs); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace | 152 } // namespace |
| 153 | 153 |
| 154 namespace blink { | |
| 155 | |
| 156 void WebPageSerializer::serialize(WebView* view, WebVector<WebPageSerializer::Re
source>* resourcesParam) | 154 void WebPageSerializer::serialize(WebView* view, WebVector<WebPageSerializer::Re
source>* resourcesParam) |
| 157 { | 155 { |
| 158 Vector<SerializedResource> resources; | 156 Vector<SerializedResource> resources; |
| 159 PageSerializer serializer(&resources); | 157 PageSerializer serializer(&resources); |
| 160 serializer.serialize(toWebViewImpl(view)->page()); | 158 serializer.serialize(toWebViewImpl(view)->page()); |
| 161 | 159 |
| 162 Vector<Resource> result; | 160 Vector<Resource> result; |
| 163 for (Vector<SerializedResource>::const_iterator iter = resources.begin(); it
er != resources.end(); ++iter) { | 161 for (Vector<SerializedResource>::const_iterator iter = resources.begin(); it
er != resources.end(); ++iter) { |
| 164 Resource resource; | 162 Resource resource; |
| 165 resource.url = iter->url; | 163 resource.url = iter->url; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 262 |
| 265 WebString WebPageSerializer::generateBaseTagDeclaration(const WebString& baseTar
get) | 263 WebString WebPageSerializer::generateBaseTagDeclaration(const WebString& baseTar
get) |
| 266 { | 264 { |
| 267 if (baseTarget.isEmpty()) | 265 if (baseTarget.isEmpty()) |
| 268 return String("<base href=\".\">"); | 266 return String("<base href=\".\">"); |
| 269 String baseString = "<base href=\".\" target=\"" + static_cast<const String&
>(baseTarget) + "\">"; | 267 String baseString = "<base href=\".\" target=\"" + static_cast<const String&
>(baseTarget) + "\">"; |
| 270 return baseString; | 268 return baseString; |
| 271 } | 269 } |
| 272 | 270 |
| 273 } // namespace blink | 271 } // namespace blink |
| OLD | NEW |