| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/savable_resources.h" | 5 #include "content/renderer/savable_resources.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "third_party/WebKit/public/platform/WebString.h" | 12 #include "third_party/WebKit/public/platform/WebString.h" |
| 13 #include "third_party/WebKit/public/platform/WebVector.h" | 13 #include "third_party/WebKit/public/platform/WebVector.h" |
| 14 #include "third_party/WebKit/public/web/WebDocument.h" | 14 #include "third_party/WebKit/public/web/WebDocument.h" |
| 15 #include "third_party/WebKit/public/web/WebElement.h" | 15 #include "third_party/WebKit/public/web/WebElement.h" |
| 16 #include "third_party/WebKit/public/web/WebElementCollection.h" |
| 16 #include "third_party/WebKit/public/web/WebFrame.h" | 17 #include "third_party/WebKit/public/web/WebFrame.h" |
| 17 #include "third_party/WebKit/public/web/WebInputElement.h" | 18 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 18 #include "third_party/WebKit/public/web/WebNode.h" | 19 #include "third_party/WebKit/public/web/WebNode.h" |
| 19 #include "third_party/WebKit/public/web/WebNodeCollection.h" | |
| 20 #include "third_party/WebKit/public/web/WebNodeList.h" | 20 #include "third_party/WebKit/public/web/WebNodeList.h" |
| 21 #include "third_party/WebKit/public/web/WebView.h" | 21 #include "third_party/WebKit/public/web/WebView.h" |
| 22 | 22 |
| 23 using blink::WebDocument; | 23 using blink::WebDocument; |
| 24 using blink::WebElement; | 24 using blink::WebElement; |
| 25 using blink::WebElementCollection; |
| 25 using blink::WebFrame; | 26 using blink::WebFrame; |
| 26 using blink::WebInputElement; | 27 using blink::WebInputElement; |
| 27 using blink::WebNode; | 28 using blink::WebNode; |
| 28 using blink::WebNodeCollection; | |
| 29 using blink::WebNodeList; | 29 using blink::WebNodeList; |
| 30 using blink::WebString; | 30 using blink::WebString; |
| 31 using blink::WebVector; | 31 using blink::WebVector; |
| 32 using blink::WebView; | 32 using blink::WebView; |
| 33 | 33 |
| 34 namespace content { | 34 namespace content { |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 // Structure for storage the unique set of all savable resource links for | 37 // Structure for storage the unique set of all savable resource links for |
| 38 // making sure that no duplicated resource link in final result. The consumer | 38 // making sure that no duplicated resource link in final result. The consumer |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 if (!is_valid_protocol) | 123 if (!is_valid_protocol) |
| 124 return; | 124 return; |
| 125 | 125 |
| 126 // If find same frame we have recorded, ignore it. | 126 // If find same frame we have recorded, ignore it. |
| 127 if (!unique_check->frames_set->insert(current_frame_url).second) | 127 if (!unique_check->frames_set->insert(current_frame_url).second) |
| 128 return; | 128 return; |
| 129 | 129 |
| 130 // Get current using document. | 130 // Get current using document. |
| 131 WebDocument current_doc = current_frame->document(); | 131 WebDocument current_doc = current_frame->document(); |
| 132 // Go through all descent nodes. | 132 // Go through all descent nodes. |
| 133 WebNodeCollection all = current_doc.all(); | 133 WebElementCollection all = current_doc.all(); |
| 134 // Go through all node in this frame. | 134 // Go through all elements in this frame. |
| 135 for (WebNode node = all.firstItem(); !node.isNull(); | 135 for (WebElement element = all.firstItem(); !element.isNull(); |
| 136 node = all.nextItem()) { | 136 element = all.nextItem()) { |
| 137 // We only save HTML resources. | |
| 138 if (!node.isElementNode()) | |
| 139 continue; | |
| 140 WebElement element = node.to<WebElement>(); | |
| 141 GetSavableResourceLinkForElement(element, | 137 GetSavableResourceLinkForElement(element, |
| 142 current_doc, | 138 current_doc, |
| 143 unique_check, | 139 unique_check, |
| 144 result); | 140 result); |
| 145 } | 141 } |
| 146 } | 142 } |
| 147 | 143 |
| 148 } // namespace | 144 } // namespace |
| 149 | 145 |
| 150 WebString GetSubResourceLinkFromElement(const WebElement& element) { | 146 WebString GetSubResourceLinkFromElement(const WebElement& element) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 it != frames_set.end(); ++it) { | 225 it != frames_set.end(); ++it) { |
| 230 // Append unique frame source to savable frame list. | 226 // Append unique frame source to savable frame list. |
| 231 if (resources_set.find(*it) == resources_set.end()) | 227 if (resources_set.find(*it) == resources_set.end()) |
| 232 result->frames_list->push_back(*it); | 228 result->frames_list->push_back(*it); |
| 233 } | 229 } |
| 234 | 230 |
| 235 return true; | 231 return true; |
| 236 } | 232 } |
| 237 | 233 |
| 238 } // namespace content | 234 } // namespace content |
| OLD | NEW |