OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/plugins/renderer/plugin_placeholder.h" | 5 #include "components/plugins/renderer/plugin_placeholder.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/json/string_escape.h" | 9 #include "base/json/string_escape.h" |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 // 1) Makes the user experience better. | 119 // 1) Makes the user experience better. |
120 // 2) Foulness is encapsulated within this single function. | 120 // 2) Foulness is encapsulated within this single function. |
121 // 3) Confidence in no fasle positives. | 121 // 3) Confidence in no fasle positives. |
122 // 4) Seems to have a good / low false negative rate at this time. | 122 // 4) Seems to have a good / low false negative rate at this time. |
123 if (element.hasAttribute("width") && element.hasAttribute("height")) { | 123 if (element.hasAttribute("width") && element.hasAttribute("height")) { |
124 std::string width_str("width:[\\s]*"); | 124 std::string width_str("width:[\\s]*"); |
125 width_str += element.getAttribute("width").utf8().data(); | 125 width_str += element.getAttribute("width").utf8().data(); |
126 if (EndsWith(width_str, "px", false)) { | 126 if (EndsWith(width_str, "px", false)) { |
127 width_str = width_str.substr(0, width_str.length() - 2); | 127 width_str = width_str.substr(0, width_str.length() - 2); |
128 } | 128 } |
129 TrimWhitespace(width_str, TRIM_TRAILING, &width_str); | 129 base::TrimWhitespace(width_str, base::TRIM_TRAILING, &width_str); |
130 width_str += "[\\s]*px"; | 130 width_str += "[\\s]*px"; |
131 std::string height_str("height:[\\s]*"); | 131 std::string height_str("height:[\\s]*"); |
132 height_str += element.getAttribute("height").utf8().data(); | 132 height_str += element.getAttribute("height").utf8().data(); |
133 if (EndsWith(height_str, "px", false)) { | 133 if (EndsWith(height_str, "px", false)) { |
134 height_str = height_str.substr(0, height_str.length() - 2); | 134 height_str = height_str.substr(0, height_str.length() - 2); |
135 } | 135 } |
136 TrimWhitespace(height_str, TRIM_TRAILING, &height_str); | 136 base::TrimWhitespace(height_str, base::TRIM_TRAILING, &height_str); |
137 height_str += "[\\s]*px"; | 137 height_str += "[\\s]*px"; |
138 WebNode parent = element; | 138 WebNode parent = element; |
139 while (!parent.parentNode().isNull()) { | 139 while (!parent.parentNode().isNull()) { |
140 parent = parent.parentNode(); | 140 parent = parent.parentNode(); |
141 if (!parent.isElementNode()) | 141 if (!parent.isElementNode()) |
142 continue; | 142 continue; |
143 element = parent.toConst<WebElement>(); | 143 element = parent.toConst<WebElement>(); |
144 if (element.hasAttribute("style")) { | 144 if (element.hasAttribute("style")) { |
145 std::string style_str = element.getAttribute("style").utf8(); | 145 std::string style_str = element.getAttribute("style").utf8(); |
146 if (RE2::PartialMatch(style_str, width_str) && | 146 if (RE2::PartialMatch(style_str, width_str) && |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 identifier_ = identifier; | 245 identifier_ = identifier; |
246 } | 246 } |
247 | 247 |
248 blink::WebFrame* PluginPlaceholder::GetFrame() { return frame_; } | 248 blink::WebFrame* PluginPlaceholder::GetFrame() { return frame_; } |
249 | 249 |
250 const blink::WebPluginParams& PluginPlaceholder::GetPluginParams() const { | 250 const blink::WebPluginParams& PluginPlaceholder::GetPluginParams() const { |
251 return plugin_params_; | 251 return plugin_params_; |
252 } | 252 } |
253 | 253 |
254 } // namespace plugins | 254 } // namespace plugins |
OLD | NEW |