diff options
author | brettw <brettw@chromium.org> | 2015-07-21 14:37:38 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-21 21:38:12 +0000 |
commit | c6f82b158f374c172a46326699f03d97777faa8e (patch) | |
tree | c96472fa185ca20b22fad773cd195689e4097894 /chrome/common/importer/firefox_importer_utils.cc | |
parent | db484c3eff68c46ddf1530dd60441dba4614cb5c (diff) | |
download | chromium_src-c6f82b158f374c172a46326699f03d97777faa8e.zip chromium_src-c6f82b158f374c172a46326699f03d97777faa8e.tar.gz chromium_src-c6f82b158f374c172a46326699f03d97777faa8e.tar.bz2 |
Update SplitString calls in chrome.
In many places that iterated over the results, the code was changed to use a range-based for loop over the result of the SplitStirng call.
Review URL: https://codereview.chromium.org/1240183002
Cr-Commit-Position: refs/heads/master@{#339753}
Diffstat (limited to 'chrome/common/importer/firefox_importer_utils.cc')
-rw-r--r-- | chrome/common/importer/firefox_importer_utils.cc | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/chrome/common/importer/firefox_importer_utils.cc b/chrome/common/importer/firefox_importer_utils.cc index 46e120c..3b74d6f 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; } |