| 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" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 attribute_name = "background"; | 143 attribute_name = "background"; |
| 144 } else if (element.hasHTMLTagName("blockquote") || | 144 } else if (element.hasHTMLTagName("blockquote") || |
| 145 element.hasHTMLTagName("q") || | 145 element.hasHTMLTagName("q") || |
| 146 element.hasHTMLTagName("del") || | 146 element.hasHTMLTagName("del") || |
| 147 element.hasHTMLTagName("ins")) { | 147 element.hasHTMLTagName("ins")) { |
| 148 attribute_name = "cite"; | 148 attribute_name = "cite"; |
| 149 } else if (element.hasHTMLTagName("object")) { | 149 } else if (element.hasHTMLTagName("object")) { |
| 150 attribute_name = "data"; | 150 attribute_name = "data"; |
| 151 } else if (element.hasHTMLTagName("link")) { | 151 } else if (element.hasHTMLTagName("link")) { |
| 152 // If the link element is not linked to css, ignore it. | 152 // If the link element is not linked to css, ignore it. |
| 153 if (base::LowerCaseEqualsASCII( | 153 WebString type = element.getAttribute("type"); |
| 154 base::StringPiece16(element.getAttribute("type")), "text/css") || | 154 WebString rel = element.getAttribute("rel"); |
| 155 base::LowerCaseEqualsASCII( | 155 if ((type.containsOnlyASCII() && |
| 156 base::StringPiece16(element.getAttribute("rel")), "stylesheet")) { | 156 base::LowerCaseEqualsASCII(type.ascii(), "text/css")) || |
| 157 (rel.containsOnlyASCII() && |
| 158 base::LowerCaseEqualsASCII(rel.ascii(), "stylesheet"))) { |
| 157 // TODO(jnd): Add support for extracting links of sub-resources which | 159 // TODO(jnd): Add support for extracting links of sub-resources which |
| 158 // are inside style-sheet such as @import, url(), etc. | 160 // are inside style-sheet such as @import, url(), etc. |
| 159 // See bug: http://b/issue?id=1111667. | 161 // See bug: http://b/issue?id=1111667. |
| 160 attribute_name = "href"; | 162 attribute_name = "href"; |
| 161 } | 163 } |
| 162 } | 164 } |
| 163 if (!attribute_name) | 165 if (!attribute_name) |
| 164 return WebString(); | 166 return WebString(); |
| 165 WebString value = element.getAttribute(WebString::fromUTF8(attribute_name)); | 167 WebString value = element.getAttribute(WebString::fromUTF8(attribute_name)); |
| 166 // If value has content and not start with "javascript:" then return it, | 168 // If value has content and not start with "javascript:" then return it, |
| 167 // otherwise return NULL. | 169 // otherwise return NULL. |
| 168 if (!value.isNull() && !value.isEmpty() && | 170 if (!value.isNull() && !value.isEmpty() && |
| 169 !base::StartsWith(value.utf8(), "javascript:", | 171 !base::StartsWith(value.utf8(), "javascript:", |
| 170 base::CompareCase::INSENSITIVE_ASCII)) | 172 base::CompareCase::INSENSITIVE_ASCII)) |
| 171 return value; | 173 return value; |
| 172 | 174 |
| 173 return WebString(); | 175 return WebString(); |
| 174 } | 176 } |
| 175 | 177 |
| 176 } // namespace content | 178 } // namespace content |
| OLD | NEW |