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

Side by Side Diff: components/autofill/content/renderer/form_autofill_util.cc

Issue 2972333002: autofill : Use ContainsValue() instead of std::find() in components/autofill (Closed)
Patch Set: add base/stl_util.h Created 3 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 | « no previous file | components/autofill/content/renderer/password_generation_agent.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/autofill/content/renderer/form_autofill_util.h" 5 #include "components/autofill/content/renderer/form_autofill_util.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 return node.IsElementNode() && node.ToConst<WebElement>().HasHTMLTagName(tag); 102 return node.IsElementNode() && node.ToConst<WebElement>().HasHTMLTagName(tag);
103 } 103 }
104 104
105 bool IsElementInControlElementSet( 105 bool IsElementInControlElementSet(
106 const WebElement& element, 106 const WebElement& element,
107 const std::vector<WebFormControlElement>& control_elements) { 107 const std::vector<WebFormControlElement>& control_elements) {
108 if (!element.IsFormControlElement()) 108 if (!element.IsFormControlElement())
109 return false; 109 return false;
110 const WebFormControlElement form_control_element = 110 const WebFormControlElement form_control_element =
111 element.ToConst<WebFormControlElement>(); 111 element.ToConst<WebFormControlElement>();
112 return std::find(control_elements.begin(), 112 return base::ContainsValue(control_elements, form_control_element);
113 control_elements.end(),
114 form_control_element) != control_elements.end();
115 } 113 }
116 114
117 bool IsElementInsideFormOrFieldSet(const WebElement& element) { 115 bool IsElementInsideFormOrFieldSet(const WebElement& element) {
118 for (WebNode parent_node = element.ParentNode(); !parent_node.IsNull(); 116 for (WebNode parent_node = element.ParentNode(); !parent_node.IsNull();
119 parent_node = parent_node.ParentNode()) { 117 parent_node = parent_node.ParentNode()) {
120 if (!parent_node.IsElementNode()) 118 if (!parent_node.IsElementNode())
121 continue; 119 continue;
122 120
123 WebElement cur_element = parent_node.To<WebElement>(); 121 WebElement cur_element = parent_node.To<WebElement>();
124 if (cur_element.HasHTMLTagName("form") || 122 if (cur_element.HasHTMLTagName("form") ||
(...skipping 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 // Zero selection start is for password manager, which can show usernames 1801 // Zero selection start is for password manager, which can show usernames
1804 // that do not begin with the user input value. 1802 // that do not begin with the user input value.
1805 selection_start = (offset == base::string16::npos) ? 0 : offset; 1803 selection_start = (offset == base::string16::npos) ? 0 : offset;
1806 } 1804 }
1807 1805
1808 input_element->SetSelectionRange(selection_start, suggestion.length()); 1806 input_element->SetSelectionRange(selection_start, suggestion.length());
1809 } 1807 }
1810 1808
1811 } // namespace form_util 1809 } // namespace form_util
1812 } // namespace autofill 1810 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/content/renderer/password_generation_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698