| 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 "content/renderer/web_frame_utils.h" |
| 12 #include "third_party/WebKit/public/platform/WebString.h" | 13 #include "third_party/WebKit/public/platform/WebString.h" |
| 13 #include "third_party/WebKit/public/platform/WebVector.h" | 14 #include "third_party/WebKit/public/platform/WebVector.h" |
| 14 #include "third_party/WebKit/public/web/WebDocument.h" | 15 #include "third_party/WebKit/public/web/WebDocument.h" |
| 15 #include "third_party/WebKit/public/web/WebElement.h" | 16 #include "third_party/WebKit/public/web/WebElement.h" |
| 16 #include "third_party/WebKit/public/web/WebElementCollection.h" | 17 #include "third_party/WebKit/public/web/WebElementCollection.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/WebLocalFrame.h" | 19 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 19 #include "third_party/WebKit/public/web/WebNode.h" | 20 #include "third_party/WebKit/public/web/WebNode.h" |
| 20 #include "third_party/WebKit/public/web/WebNodeList.h" | 21 #include "third_party/WebKit/public/web/WebNodeList.h" |
| 21 #include "third_party/WebKit/public/web/WebView.h" | 22 #include "third_party/WebKit/public/web/WebView.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 36 namespace { | 37 namespace { |
| 37 | 38 |
| 38 // Get all savable resource links from current element. One element might | 39 // Get all savable resource links from current element. One element might |
| 39 // have more than one resource link. It is possible to have some links | 40 // have more than one resource link. It is possible to have some links |
| 40 // in one CSS stylesheet. | 41 // in one CSS stylesheet. |
| 41 void GetSavableResourceLinkForElement( | 42 void GetSavableResourceLinkForElement( |
| 42 const WebElement& element, | 43 const WebElement& element, |
| 43 const WebDocument& current_doc, | 44 const WebDocument& current_doc, |
| 44 SavableResourcesResult* result) { | 45 SavableResourcesResult* result) { |
| 45 if (element.hasHTMLTagName("iframe") || element.hasHTMLTagName("frame")) { | 46 if (element.hasHTMLTagName("iframe") || element.hasHTMLTagName("frame")) { |
| 46 GURL original_url = current_doc.completeURL(element.getAttribute("src")); | 47 GURL complete_url = current_doc.completeURL(element.getAttribute("src")); |
| 47 WebFrame* subframe = WebFrame::fromFrameOwnerElement(element); | 48 WebFrame* web_frame = WebFrame::fromFrameOwnerElement(element); |
| 49 |
| 50 SavableSubframe subframe; |
| 51 subframe.original_url = complete_url; |
| 52 subframe.routing_id = GetRoutingIdForFrameOrProxy(web_frame); |
| 53 |
| 48 result->subframes->push_back(subframe); | 54 result->subframes->push_back(subframe); |
| 49 result->subframe_original_urls->push_back(original_url); | |
| 50 return; | 55 return; |
| 51 } | 56 } |
| 52 | 57 |
| 53 // Check whether the node has sub resource URL or not. | 58 // Check whether the node has sub resource URL or not. |
| 54 WebString value = GetSubResourceLinkFromElement(element); | 59 WebString value = GetSubResourceLinkFromElement(element); |
| 55 if (value.isNull()) | 60 if (value.isNull()) |
| 56 return; | 61 return; |
| 57 // Get absolute URL. | 62 // Get absolute URL. |
| 58 GURL u = current_doc.completeURL(value); | 63 GURL u = current_doc.completeURL(value); |
| 59 // ignore invalid URL | 64 // ignore invalid URL |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // otherwise return NULL. | 150 // otherwise return NULL. |
| 146 if (!value.isNull() && !value.isEmpty() && | 151 if (!value.isNull() && !value.isEmpty() && |
| 147 !base::StartsWith(value.utf8(), "javascript:", | 152 !base::StartsWith(value.utf8(), "javascript:", |
| 148 base::CompareCase::INSENSITIVE_ASCII)) | 153 base::CompareCase::INSENSITIVE_ASCII)) |
| 149 return value; | 154 return value; |
| 150 | 155 |
| 151 return WebString(); | 156 return WebString(); |
| 152 } | 157 } |
| 153 | 158 |
| 154 } // namespace content | 159 } // namespace content |
| OLD | NEW |