| 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/strings/string_util.h" | 7 #include "base/strings/string_util.h" | 
| 8 #include "content/public/common/web_preferences.h" | 8 #include "content/public/common/web_preferences.h" | 
| 9 #include "content/public/renderer/render_frame.h" | 9 #include "content/public/renderer/render_frame.h" | 
| 10 #include "content/public/renderer/render_thread.h" | 10 #include "content/public/renderer/render_thread.h" | 
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 71   // as opposed to merely visible. | 71   // as opposed to merely visible. | 
| 72   // TODO(cevans) -- it's a foul heuristic but we're going to tolerate it for | 72   // TODO(cevans) -- it's a foul heuristic but we're going to tolerate it for | 
| 73   // now for these reasons: | 73   // now for these reasons: | 
| 74   // 1) Makes the user experience better. | 74   // 1) Makes the user experience better. | 
| 75   // 2) Foulness is encapsulated within this single function. | 75   // 2) Foulness is encapsulated within this single function. | 
| 76   // 3) Confidence in no fasle positives. | 76   // 3) Confidence in no fasle positives. | 
| 77   // 4) Seems to have a good / low false negative rate at this time. | 77   // 4) Seems to have a good / low false negative rate at this time. | 
| 78   if (element.hasAttribute("width") && element.hasAttribute("height")) { | 78   if (element.hasAttribute("width") && element.hasAttribute("height")) { | 
| 79     std::string width_str("width:[\\s]*"); | 79     std::string width_str("width:[\\s]*"); | 
| 80     width_str += element.getAttribute("width").utf8().data(); | 80     width_str += element.getAttribute("width").utf8().data(); | 
| 81     if (EndsWith(width_str, "px", false)) { | 81     if (base::EndsWith(width_str, "px", false)) { | 
| 82       width_str = width_str.substr(0, width_str.length() - 2); | 82       width_str = width_str.substr(0, width_str.length() - 2); | 
| 83     } | 83     } | 
| 84     base::TrimWhitespace(width_str, base::TRIM_TRAILING, &width_str); | 84     base::TrimWhitespace(width_str, base::TRIM_TRAILING, &width_str); | 
| 85     width_str += "[\\s]*px"; | 85     width_str += "[\\s]*px"; | 
| 86     std::string height_str("height:[\\s]*"); | 86     std::string height_str("height:[\\s]*"); | 
| 87     height_str += element.getAttribute("height").utf8().data(); | 87     height_str += element.getAttribute("height").utf8().data(); | 
| 88     if (EndsWith(height_str, "px", false)) { | 88     if (base::EndsWith(height_str, "px", false)) { | 
| 89       height_str = height_str.substr(0, height_str.length() - 2); | 89       height_str = height_str.substr(0, height_str.length() - 2); | 
| 90     } | 90     } | 
| 91     base::TrimWhitespace(height_str, base::TRIM_TRAILING, &height_str); | 91     base::TrimWhitespace(height_str, base::TRIM_TRAILING, &height_str); | 
| 92     height_str += "[\\s]*px"; | 92     height_str += "[\\s]*px"; | 
| 93     blink::WebNode parent = element; | 93     blink::WebNode parent = element; | 
| 94     while (!parent.parentNode().isNull()) { | 94     while (!parent.parentNode().isNull()) { | 
| 95       parent = parent.parentNode(); | 95       parent = parent.parentNode(); | 
| 96       if (!parent.isElementNode()) | 96       if (!parent.isElementNode()) | 
| 97         continue; | 97         continue; | 
| 98       element = parent.toConst<blink::WebElement>(); | 98       element = parent.toConst<blink::WebElement>(); | 
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 142   return gin::Wrappable<PluginPlaceholder>::GetObjectTemplateBuilder(isolate) | 142   return gin::Wrappable<PluginPlaceholder>::GetObjectTemplateBuilder(isolate) | 
| 143       .SetMethod<void (plugins::PluginPlaceholder::*)()>( | 143       .SetMethod<void (plugins::PluginPlaceholder::*)()>( | 
| 144           "hide", &PluginPlaceholder::HideCallback); | 144           "hide", &PluginPlaceholder::HideCallback); | 
| 145 } | 145 } | 
| 146 | 146 | 
| 147 void PluginPlaceholder::HideCallback() { | 147 void PluginPlaceholder::HideCallback() { | 
| 148   PluginPlaceholderBase::HideCallback(); | 148   PluginPlaceholderBase::HideCallback(); | 
| 149 } | 149 } | 
| 150 | 150 | 
| 151 }  // namespace plugins | 151 }  // namespace plugins | 
| OLD | NEW | 
|---|