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

Side by Side Diff: chrome/renderer/form_manager.cc

Issue 1801002: AutoFill: Notify the renderer when the page has finished translating. Extract (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: Update comment. Created 10 years, 8 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/renderer/form_manager.h" 5 #include "chrome/renderer/form_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/scoped_vector.h" 8 #include "base/scoped_vector.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 27 matching lines...) Expand all
38 using WebKit::WebVector; 38 using WebKit::WebVector;
39 39
40 namespace { 40 namespace {
41 41
42 // The number of fields required by AutoFill. Ideally we could send the forms 42 // The number of fields required by AutoFill. Ideally we could send the forms
43 // to AutoFill no matter how many fields are in the forms; however, finding the 43 // to AutoFill no matter how many fields are in the forms; however, finding the
44 // label for each field is a costly operation and we can't spare the cycles if 44 // label for each field is a costly operation and we can't spare the cycles if
45 // it's not necessary. 45 // it's not necessary.
46 const size_t kRequiredAutoFillFields = 3; 46 const size_t kRequiredAutoFillFields = 3;
47 47
48 // Returns the node value of the first child of |element| if the first child 48 // Returns the node value of the first offspring of |element| that is a text
49 // is text. This is faster alternative to |innerText()| for performance 49 // node. This is a faster alternative to |innerText()| for performance
50 // critical operations when the child structure of element is known. 50 // critical operations when the child structure of |element| is known.
51 string16 GetChildText(const WebElement& element) { 51 string16 GetChildText(const WebElement& element) {
52 string16 element_text; 52 string16 element_text;
53 WebNode child = element.firstChild(); 53 WebNode child = element.firstChild();
54 if (!child.isNull() && child.isTextNode()) { 54 // Find the text node.
55 while (!child.isNull() && !child.isTextNode())
56 child = child.firstChild();
57 if (!child.isNull()) {
55 element_text = child.nodeValue(); 58 element_text = child.nodeValue();
56 TrimWhitespace(element_text, TRIM_ALL, &element_text); 59 TrimWhitespace(element_text, TRIM_ALL, &element_text);
57 } 60 }
58 return element_text; 61 return element_text;
59 } 62 }
60 63
61 } // namespace 64 } // namespace
62 65
63 FormManager::FormManager() { 66 FormManager::FormManager() {
64 } 67 }
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 inferred_label = GetChildText(element); 579 inferred_label = GetChildText(element);
577 TrimWhitespace(inferred_label, TRIM_ALL, &inferred_label); 580 TrimWhitespace(inferred_label, TRIM_ALL, &inferred_label);
578 } 581 }
579 } 582 }
580 } 583 }
581 } 584 }
582 } 585 }
583 586
584 return inferred_label; 587 return inferred_label;
585 } 588 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/name_field_unittest.cc ('k') | chrome/renderer/form_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698