Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: components/plugins/renderer/plugin_placeholder.cc

Issue 1233043003: Remove some legacy versions of StartsWith and EndsWith. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/plugins/renderer/mobile_youtube_plugin.cc ('k') | components/search/search.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 (base::EndsWith(width_str, "px", false)) { 81 if (base::EndsWith(width_str, "px", base::CompareCase::INSENSITIVE_ASCII)) {
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 (base::EndsWith(height_str, "px", false)) { 88 if (base::EndsWith(height_str, "px",
89 base::CompareCase::INSENSITIVE_ASCII)) {
89 height_str = height_str.substr(0, height_str.length() - 2); 90 height_str = height_str.substr(0, height_str.length() - 2);
90 } 91 }
91 base::TrimWhitespace(height_str, base::TRIM_TRAILING, &height_str); 92 base::TrimWhitespace(height_str, base::TRIM_TRAILING, &height_str);
92 height_str += "[\\s]*px"; 93 height_str += "[\\s]*px";
93 blink::WebNode parent = element; 94 blink::WebNode parent = element;
94 while (!parent.parentNode().isNull()) { 95 while (!parent.parentNode().isNull()) {
95 parent = parent.parentNode(); 96 parent = parent.parentNode();
96 if (!parent.isElementNode()) 97 if (!parent.isElementNode())
97 continue; 98 continue;
98 element = parent.toConst<blink::WebElement>(); 99 element = parent.toConst<blink::WebElement>();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 139 }
139 140
140 gin::ObjectTemplateBuilder PluginPlaceholder::GetObjectTemplateBuilder( 141 gin::ObjectTemplateBuilder PluginPlaceholder::GetObjectTemplateBuilder(
141 v8::Isolate* isolate) { 142 v8::Isolate* isolate) {
142 return gin::Wrappable<PluginPlaceholder>::GetObjectTemplateBuilder(isolate) 143 return gin::Wrappable<PluginPlaceholder>::GetObjectTemplateBuilder(isolate)
143 .SetMethod<void (plugins::PluginPlaceholder::*)()>( 144 .SetMethod<void (plugins::PluginPlaceholder::*)()>(
144 "hide", &PluginPlaceholder::HideCallback); 145 "hide", &PluginPlaceholder::HideCallback);
145 } 146 }
146 147
147 } // namespace plugins 148 } // namespace plugins
OLDNEW
« no previous file with comments | « components/plugins/renderer/mobile_youtube_plugin.cc ('k') | components/search/search.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698