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

Side by Side Diff: chrome/browser/importer/firefox_importer_utils.cc

Issue 3750001: base: Move SplitString functions into the base namespace and update the callers. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: brett review, reverted changes in o3d due to it's using an old base revision Created 10 years, 2 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
« no previous file with comments | « chrome/browser/importer/firefox2_importer.cc ('k') | chrome/browser/importer/ie_importer.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) 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/browser/importer/firefox_importer_utils.h" 5 #include "chrome/browser/importer/firefox_importer_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 bool GetFirefoxVersionAndPathFromProfile(const FilePath& profile_path, 93 bool GetFirefoxVersionAndPathFromProfile(const FilePath& profile_path,
94 int* version, 94 int* version,
95 FilePath* app_path) { 95 FilePath* app_path) {
96 bool ret = false; 96 bool ret = false;
97 FilePath compatibility_file = profile_path.AppendASCII("compatibility.ini"); 97 FilePath compatibility_file = profile_path.AppendASCII("compatibility.ini");
98 std::string content; 98 std::string content;
99 file_util::ReadFileToString(compatibility_file, &content); 99 file_util::ReadFileToString(compatibility_file, &content);
100 ReplaceSubstringsAfterOffset(&content, 0, "\r\n", "\n"); 100 ReplaceSubstringsAfterOffset(&content, 0, "\r\n", "\n");
101 std::vector<std::string> lines; 101 std::vector<std::string> lines;
102 SplitString(content, '\n', &lines); 102 base::SplitString(content, '\n', &lines);
103 103
104 for (size_t i = 0; i < lines.size(); ++i) { 104 for (size_t i = 0; i < lines.size(); ++i) {
105 const std::string& line = lines[i]; 105 const std::string& line = lines[i];
106 if (line.empty() || line[0] == '#' || line[0] == ';') 106 if (line.empty() || line[0] == '#' || line[0] == ';')
107 continue; 107 continue;
108 size_t equal = line.find('='); 108 size_t equal = line.find('=');
109 if (equal != std::string::npos) { 109 if (equal != std::string::npos) {
110 std::string key = line.substr(0, equal); 110 std::string key = line.substr(0, equal);
111 if (key == "LastVersion") { 111 if (key == "LastVersion") {
112 *version = line.substr(equal + 1)[0] - '0'; 112 *version = line.substr(equal + 1)[0] - '0';
(...skipping 10 matching lines...) Expand all
123 } 123 }
124 return ret; 124 return ret;
125 } 125 }
126 126
127 void ParseProfileINI(const FilePath& file, DictionaryValue* root) { 127 void ParseProfileINI(const FilePath& file, DictionaryValue* root) {
128 // Reads the whole INI file. 128 // Reads the whole INI file.
129 std::string content; 129 std::string content;
130 file_util::ReadFileToString(file, &content); 130 file_util::ReadFileToString(file, &content);
131 ReplaceSubstringsAfterOffset(&content, 0, "\r\n", "\n"); 131 ReplaceSubstringsAfterOffset(&content, 0, "\r\n", "\n");
132 std::vector<std::string> lines; 132 std::vector<std::string> lines;
133 SplitString(content, '\n', &lines); 133 base::SplitString(content, '\n', &lines);
134 134
135 // Parses the file. 135 // Parses the file.
136 root->Clear(); 136 root->Clear();
137 std::string current_section; 137 std::string current_section;
138 for (size_t i = 0; i < lines.size(); ++i) { 138 for (size_t i = 0; i < lines.size(); ++i) {
139 std::string line = lines[i]; 139 std::string line = lines[i];
140 if (line.empty()) { 140 if (line.empty()) {
141 // Skips the empty line. 141 // Skips the empty line.
142 continue; 142 continue;
143 } 143 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 338
339 std::string default_homepages = 339 std::string default_homepages =
340 ReadBrowserConfigProp(app_path, "browser.startup.homepage"); 340 ReadBrowserConfigProp(app_path, "browser.startup.homepage");
341 341
342 size_t seperator = default_homepages.find_first_of('|'); 342 size_t seperator = default_homepages.find_first_of('|');
343 if (seperator == std::string::npos) 343 if (seperator == std::string::npos)
344 return homepage.spec() == GURL(default_homepages).spec(); 344 return homepage.spec() == GURL(default_homepages).spec();
345 345
346 // Crack the string into separate homepage urls. 346 // Crack the string into separate homepage urls.
347 std::vector<std::string> urls; 347 std::vector<std::string> urls;
348 SplitString(default_homepages, '|', &urls); 348 base::SplitString(default_homepages, '|', &urls);
349 349
350 for (size_t i = 0; i < urls.size(); ++i) { 350 for (size_t i = 0; i < urls.size(); ++i) {
351 if (homepage.spec() == GURL(urls[i]).spec()) 351 if (homepage.spec() == GURL(urls[i]).spec())
352 return true; 352 return true;
353 } 353 }
354 354
355 return false; 355 return false;
356 } 356 }
357 357
358 bool ParsePrefFile(const FilePath& pref_file, DictionaryValue* prefs) { 358 bool ParsePrefFile(const FilePath& pref_file, DictionaryValue* prefs) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } 451 }
452 452
453 // String values have double quotes we don't need to return to the caller. 453 // String values have double quotes we don't need to return to the caller.
454 if (content[start] == '\"' && content[stop - 1] == '\"') { 454 if (content[start] == '\"' && content[stop - 1] == '\"') {
455 ++start; 455 ++start;
456 --stop; 456 --stop;
457 } 457 }
458 458
459 return content.substr(start, stop - start); 459 return content.substr(start, stop - start);
460 } 460 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/firefox2_importer.cc ('k') | chrome/browser/importer/ie_importer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698