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

Unified Diff: chrome/common/importer/firefox_importer_utils.cc

Issue 1240183002: Update SplitString calls in chrome. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/command.cc ('k') | chrome/common/pepper_flash.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/importer/firefox_importer_utils.cc
diff --git a/chrome/common/importer/firefox_importer_utils.cc b/chrome/common/importer/firefox_importer_utils.cc
index 46e120c304e4cfeace63f1663c7e0a201cfc8dec..3b74d6f585cf27a9ac4dbafdff22caf36d98f9c0 100644
--- a/chrome/common/importer/firefox_importer_utils.cc
+++ b/chrome/common/importer/firefox_importer_utils.cc
@@ -138,11 +138,9 @@ bool GetFirefoxVersionAndPathFromProfile(const base::FilePath& profile_path,
std::string content;
base::ReadFileToString(compatibility_file, &content);
base::ReplaceSubstringsAfterOffset(&content, 0, "\r\n", "\n");
- std::vector<std::string> lines;
- base::SplitString(content, '\n', &lines);
- for (size_t i = 0; i < lines.size(); ++i) {
- const std::string& line = lines[i];
+ for (const std::string& line : base::SplitString(
+ content, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
if (line.empty() || line[0] == '#' || line[0] == ';')
continue;
size_t equal = line.find('=');
@@ -242,11 +240,10 @@ bool IsDefaultHomepage(const GURL& homepage, const base::FilePath& app_path) {
return homepage.spec() == GURL(default_homepages).spec();
// Crack the string into separate homepage urls.
- std::vector<std::string> urls;
- base::SplitString(default_homepages, '|', &urls);
-
- for (size_t i = 0; i < urls.size(); ++i) {
- if (homepage.spec() == GURL(urls[i]).spec())
+ for (const std::string& url : base::SplitString(
+ default_homepages, "|",
+ base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
+ if (homepage.spec() == GURL(url).spec())
return true;
}
@@ -303,19 +300,18 @@ base::string16 GetFirefoxImporterName(const base::FilePath& app_path) {
if (base::PathExists(app_ini_file)) {
std::string content;
base::ReadFileToString(app_ini_file, &content);
- std::vector<std::string> lines;
- base::SplitString(content, '\n', &lines);
+
const std::string name_attr("Name=");
bool in_app_section = false;
- for (size_t i = 0; i < lines.size(); ++i) {
- base::TrimWhitespace(lines[i], base::TRIM_ALL, &lines[i]);
- if (lines[i] == "[App]") {
+ for (const base::StringPiece& line : base::SplitStringPiece(
+ content, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
+ if (line == "[App]") {
in_app_section = true;
} else if (in_app_section) {
- if (lines[i].find(name_attr) == 0) {
- branding_name = lines[i].substr(name_attr.size());
+ if (line.find(name_attr) == 0) {
+ line.substr(name_attr.size()).CopyToString(&branding_name);
break;
- } else if (lines[i].length() > 0 && lines[i][0] == '[') {
+ } else if (line.length() > 0 && line[0] == '[') {
// No longer in the [App] section.
break;
}
« no previous file with comments | « chrome/common/extensions/command.cc ('k') | chrome/common/pepper_flash.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698