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

Side by Side Diff: chrome/browser/autocomplete_history_manager.cc

Issue 8921006: Standardize StringToInt{,64} interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix call syntax of StringToInt() in Chrome OS code. Created 9 years 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 | « base/sys_info_chromeos.cc ('k') | chrome/browser/chromeos/login/default_user_images.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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser/autocomplete_history_manager.h" 5 #include "chrome/browser/autocomplete_history_manager.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/autofill/autofill_external_delegate.h" 12 #include "chrome/browser/autofill/autofill_external_delegate.h"
13 #include "chrome/browser/autofill/credit_card.h" 13 #include "chrome/browser/autofill/credit_card.h"
14 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/autofill_messages.h" 16 #include "chrome/common/autofill_messages.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "content/browser/renderer_host/render_view_host.h" 18 #include "content/browser/renderer_host/render_view_host.h"
19 #include "content/browser/tab_contents/tab_contents.h" 19 #include "content/browser/tab_contents/tab_contents.h"
20 #include "webkit/forms/form_data.h" 20 #include "webkit/forms/form_data.h"
21 21
22 using base::StringPiece16;
22 using webkit::forms::FormData; 23 using webkit::forms::FormData;
23 using webkit::forms::FormField; 24 using webkit::forms::FormField;
24 25
25 namespace { 26 namespace {
26 27
27 // Limit on the number of suggestions to appear in the pop-up menu under an 28 // Limit on the number of suggestions to appear in the pop-up menu under an
28 // text input element in a form. 29 // text input element in a form.
29 const int kMaxAutocompleteMenuItems = 6; 30 const int kMaxAutocompleteMenuItems = 6;
30 31
31 // The separator characters for SSNs. 32 // The separator characters for SSNs.
(...skipping 24 matching lines...) Expand all
56 // 57 //
57 // References for historic practices: 58 // References for historic practices:
58 // http://www.socialsecurity.gov/history/ssn/geocard.html 59 // http://www.socialsecurity.gov/history/ssn/geocard.html
59 // http://www.socialsecurity.gov/employer/stateweb.htm 60 // http://www.socialsecurity.gov/employer/stateweb.htm
60 // http://www.socialsecurity.gov/employer/ssnvhighgroup.htm 61 // http://www.socialsecurity.gov/employer/ssnvhighgroup.htm
61 62
62 if (number_string.length() != 9 || !IsStringASCII(number_string)) 63 if (number_string.length() != 9 || !IsStringASCII(number_string))
63 return false; 64 return false;
64 65
65 int area; 66 int area;
66 if (!base::StringToInt(number_string.begin(), 67 if (!base::StringToInt(StringPiece16(number_string.begin(),
67 number_string.begin() + 3, 68 number_string.begin() + 3),
68 &area)) 69 &area)) {
69 return false; 70 return false;
71 }
70 if (area < 1 || 72 if (area < 1 ||
71 area == 666 || 73 area == 666 ||
72 area >= 900) 74 area >= 900) {
73 return false; 75 return false;
76 }
74 77
75 int group; 78 int group;
76 if (!base::StringToInt(number_string.begin() + 3, 79 if (!base::StringToInt(StringPiece16(number_string.begin() + 3,
77 number_string.begin() + 5, 80 number_string.begin() + 5),
78 &group) || group == 0) 81 &group)
82 || group == 0) {
79 return false; 83 return false;
84 }
80 85
81 int serial; 86 int serial;
82 if (!base::StringToInt(number_string.begin() + 5, 87 if (!base::StringToInt(StringPiece16(number_string.begin() + 5,
83 number_string.begin() + 9, 88 number_string.begin() + 9),
84 &serial) || serial == 0) 89 &serial)
90 || serial == 0) {
85 return false; 91 return false;
92 }
86 93
87 return true; 94 return true;
88 } 95 }
89 96
90 bool IsTextField(const FormField& field) { 97 bool IsTextField(const FormField& field) {
91 return 98 return
92 field.form_control_type == ASCIIToUTF16("text") || 99 field.form_control_type == ASCIIToUTF16("text") ||
93 field.form_control_type == ASCIIToUTF16("search") || 100 field.form_control_type == ASCIIToUTF16("search") ||
94 field.form_control_type == ASCIIToUTF16("tel") || 101 field.form_control_type == ASCIIToUTF16("tel") ||
95 field.form_control_type == ASCIIToUTF16("url") || 102 field.form_control_type == ASCIIToUTF16("url") ||
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 autofill_icons_, 291 autofill_icons_,
285 autofill_unique_ids_)); 292 autofill_unique_ids_));
286 } 293 }
287 294
288 query_id_ = 0; 295 query_id_ = 0;
289 autofill_values_.clear(); 296 autofill_values_.clear();
290 autofill_labels_.clear(); 297 autofill_labels_.clear();
291 autofill_icons_.clear(); 298 autofill_icons_.clear();
292 autofill_unique_ids_.clear(); 299 autofill_unique_ids_.clear();
293 } 300 }
OLDNEW
« no previous file with comments | « base/sys_info_chromeos.cc ('k') | chrome/browser/chromeos/login/default_user_images.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698