summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorerikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-22 16:05:47 +0000
committererikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-22 16:05:47 +0000
commitc2750c67ca3a672018bac2dfb07628d079aafc8d (patch)
tree8bbff1c4c3aeb363e06734e91e172653e34737cc /chrome
parent213b99ad9d66e3c039bbb90c19d78603975c1be9 (diff)
downloadchromium_src-c2750c67ca3a672018bac2dfb07628d079aafc8d.zip
chromium_src-c2750c67ca3a672018bac2dfb07628d079aafc8d.tar.gz
chromium_src-c2750c67ca3a672018bac2dfb07628d079aafc8d.tar.bz2
Update code that previously constructed strings from string iterators only to use StringToInt. These usages now pass the iterators directly to the new StringToInt overloads.
BUG=None TEST=All Review URL: http://codereview.chromium.org/3968001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@63515 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete_history_manager.cc20
-rw-r--r--chrome/browser/chromeos/customization_document.cc4
-rw-r--r--chrome/browser/history/text_database.cc4
-rw-r--r--chrome/browser/safe_browsing/filter_false_positive_perftest.cc2
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page.cc5
-rw-r--r--chrome/common/extensions/extension.cc2
-rw-r--r--chrome/renderer/webplugin_delegate_pepper.cc3
-rw-r--r--chrome/test/page_cycler/page_cycler_test.cc5
8 files changed, 26 insertions, 19 deletions
diff --git a/chrome/browser/autocomplete_history_manager.cc b/chrome/browser/autocomplete_history_manager.cc
index b2c4d3c..2243bcb 100644
--- a/chrome/browser/autocomplete_history_manager.cc
+++ b/chrome/browser/autocomplete_history_manager.cc
@@ -31,8 +31,6 @@ const string16 kSSNSeparators = ASCIIToUTF16(" -");
bool IsSSN(const string16& text) {
string16 number_string;
RemoveChars(text, kSSNSeparators.c_str(), &number_string);
- if (number_string.length() != 9 || !IsStringASCII(number_string))
- return false;
// A SSN is of the form AAA-GG-SSSS (A = area number, G = group number, S =
// serial number). The validation we do here is simply checking if the area,
@@ -42,13 +40,13 @@ bool IsSSN(const string16& text) {
// See: http://www.socialsecurity.gov/history/ssn/geocard.html
// http://www.socialsecurity.gov/employer/stateweb.htm
// http://www.socialsecurity.gov/employer/ssnvhighgroup.htm
-
- string16 area_string = number_string.substr(0, 3);
- string16 group_string = number_string.substr(3, 2);
- string16 serial_string = number_string.substr(5, 4);
+ if (number_string.length() != 9 || !IsStringASCII(number_string))
+ return false;
int area;
- if (!base::StringToInt(area_string, &area))
+ if (!base::StringToInt(number_string.begin(),
+ number_string.begin() + 3,
+ &area))
return false;
if (area < 1 ||
area == 666 ||
@@ -57,11 +55,15 @@ bool IsSSN(const string16& text) {
return false;
int group;
- if (!base::StringToInt(group_string, &group) || group == 0)
+ if (!base::StringToInt(number_string.begin() + 3,
+ number_string.begin() + 5,
+ &group) || group == 0)
return false;
int serial;
- if (!base::StringToInt(serial_string, &serial) || serial == 0)
+ if (!base::StringToInt(number_string.begin() + 5,
+ number_string.begin() + 9,
+ &serial) || serial == 0)
return false;
return true;
diff --git a/chrome/browser/chromeos/customization_document.cc b/chrome/browser/chromeos/customization_document.cc
index b9a4f34..a9d438a 100644
--- a/chrome/browser/chromeos/customization_document.cc
+++ b/chrome/browser/chromeos/customization_document.cc
@@ -103,7 +103,9 @@ bool StartupCustomizationDocument::ParseFromJsonValue(
if (!background_color_string.empty()) {
if (background_color_string[0] == '#') {
int background_int;
- base::HexStringToInt(background_color_string.substr(1), &background_int);
+ base::HexStringToInt(background_color_string.begin() + 1,
+ background_color_string.end(),
+ &background_int);
background_color_ = static_cast<SkColor>(0xff000000 | background_int);
} else {
// Literal color constants are not supported yet.
diff --git a/chrome/browser/history/text_database.cc b/chrome/browser/history/text_database.cc
index 84367d3..60aa7fd 100644
--- a/chrome/browser/history/text_database.cc
+++ b/chrome/browser/history/text_database.cc
@@ -112,8 +112,8 @@ TextDatabase::DBIdent TextDatabase::FileNameToID(const FilePath& file_path) {
}
int year, month;
- base::StringToInt(suffix.substr(0, 4), &year);
- base::StringToInt(suffix.substr(5, 2), &month);
+ base::StringToInt(suffix.begin(), suffix.begin() + 4, &year);
+ base::StringToInt(suffix.begin() + 5, suffix.begin() + 7, &month);
return year * 100 + month;
}
diff --git a/chrome/browser/safe_browsing/filter_false_positive_perftest.cc b/chrome/browser/safe_browsing/filter_false_positive_perftest.cc
index f763b51c..eec1c2e 100644
--- a/chrome/browser/safe_browsing/filter_false_positive_perftest.cc
+++ b/chrome/browser/safe_browsing/filter_false_positive_perftest.cc
@@ -261,7 +261,7 @@ void CalculateBloomFilterFalsePositives(
if (use_weights) {
std::string::size_type pos = url.find_last_of(",");
if (pos != std::string::npos) {
- base::StringToInt(std::string(url, pos + 1), &weight);
+ base::StringToInt(url.begin() + pos + 1, url.end(), &weight);
url = url.substr(0, pos);
}
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
index ace8abb..fc36bf5 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
@@ -331,9 +331,10 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) {
size_t colon_index = command.find(':');
if (colon_index != std::string::npos) {
DCHECK(colon_index < command.size() - 1);
- std::string index_str = command.substr(colon_index + 1);
command = command.substr(0, colon_index);
- bool result = base::StringToInt(index_str, &element_index);
+ bool result = base::StringToInt(command.begin() + colon_index + 1,
+ command.end(),
+ &element_index);
DCHECK(result);
}
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index fbb262f..e3254d8 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -64,7 +64,7 @@ const int kRSAKeySize = 1024;
static void ConvertHexadecimalToIDAlphabet(std::string* id) {
for (size_t i = 0; i < id->size(); ++i) {
int val;
- if (base::HexStringToInt(id->substr(i, 1), &val))
+ if (base::HexStringToInt(id->begin() + i, id->begin() + i + 1, &val))
(*id)[i] = val + 'a';
else
(*id)[i] = 'a';
diff --git a/chrome/renderer/webplugin_delegate_pepper.cc b/chrome/renderer/webplugin_delegate_pepper.cc
index 7d0a5a2..082fc82 100644
--- a/chrome/renderer/webplugin_delegate_pepper.cc
+++ b/chrome/renderer/webplugin_delegate_pepper.cc
@@ -614,7 +614,8 @@ NPError WebPluginDelegatePepper::Device2DGetStateContext(
// Return the least significant 8 characters (i.e. 4 bytes)
// of the 32 character hexadecimal result as an int.
int int_val;
- base::HexStringToInt(hex_md5.substr(24), &int_val);
+ DCHECK_EQ(hex_md5.length(), 32u);
+ base::HexStringToInt(hex_md5.begin() + 24, hex_md5.end(), &int_val);
*value = int_val;
return NPERR_NO_ERROR;
}
diff --git a/chrome/test/page_cycler/page_cycler_test.cc b/chrome/test/page_cycler/page_cycler_test.cc
index 1674869..7346489 100644
--- a/chrome/test/page_cycler/page_cycler_test.cc
+++ b/chrome/test/page_cycler/page_cycler_test.cc
@@ -366,8 +366,9 @@ static bool HasDatabaseErrors(const std::string timings) {
new_pos = timings.find(',', pos);
if (new_pos == std::string::npos)
new_pos = timings.length();
- time_str = timings.substr(pos, new_pos - pos);
- if (!base::StringToInt(time_str, &time)) {
+ if (!base::StringToInt(timings.begin() + pos,
+ timings.begin() + new_pos,
+ &time)) {
LOG(ERROR) << "Invalid time reported: " << time_str;
return true;
}