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

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

Issue 13145003: Rewrite std::string("") to std::string(), Linux edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ugh Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 return false; 248 return false;
249 } 249 }
250 250
251 return true; 251 return true;
252 } 252 }
253 253
254 std::string ReadBrowserConfigProp(const base::FilePath& app_path, 254 std::string ReadBrowserConfigProp(const base::FilePath& app_path,
255 const std::string& pref_key) { 255 const std::string& pref_key) {
256 std::string content; 256 std::string content;
257 if (!ReadPrefFile(app_path.AppendASCII("browserconfig.properties"), &content)) 257 if (!ReadPrefFile(app_path.AppendASCII("browserconfig.properties"), &content))
258 return ""; 258 return std::string();
259 259
260 // This file has the syntax: key=value. 260 // This file has the syntax: key=value.
261 size_t prop_index = content.find(pref_key + "="); 261 size_t prop_index = content.find(pref_key + "=");
262 if (prop_index == std::string::npos) 262 if (prop_index == std::string::npos)
263 return ""; 263 return std::string();
264 264
265 size_t start = prop_index + pref_key.length(); 265 size_t start = prop_index + pref_key.length();
266 size_t stop = std::string::npos; 266 size_t stop = std::string::npos;
267 if (start != std::string::npos) 267 if (start != std::string::npos)
268 stop = content.find("\n", start + 1); 268 stop = content.find("\n", start + 1);
269 269
270 if (start == std::string::npos || 270 if (start == std::string::npos ||
271 stop == std::string::npos || (start == stop)) { 271 stop == std::string::npos || (start == stop)) {
272 LOG(WARNING) << "Firefox property " << pref_key << " could not be parsed."; 272 LOG(WARNING) << "Firefox property " << pref_key << " could not be parsed.";
273 return ""; 273 return std::string();
274 } 274 }
275 275
276 return content.substr(start + 1, stop - start - 1); 276 return content.substr(start + 1, stop - start - 1);
277 } 277 }
278 278
279 std::string ReadPrefsJsValue(const base::FilePath& profile_path, 279 std::string ReadPrefsJsValue(const base::FilePath& profile_path,
280 const std::string& pref_key) { 280 const std::string& pref_key) {
281 std::string content; 281 std::string content;
282 if (!ReadPrefFile(profile_path.AppendASCII("prefs.js"), &content)) 282 if (!ReadPrefFile(profile_path.AppendASCII("prefs.js"), &content))
283 return ""; 283 return std::string();
284 284
285 return GetPrefsJsValue(content, pref_key); 285 return GetPrefsJsValue(content, pref_key);
286 } 286 }
287 287
288 GURL GetHomepage(const base::FilePath& profile_path) { 288 GURL GetHomepage(const base::FilePath& profile_path) {
289 std::string home_page_list = 289 std::string home_page_list =
290 ReadPrefsJsValue(profile_path, "browser.startup.homepage"); 290 ReadPrefsJsValue(profile_path, "browser.startup.homepage");
291 291
292 size_t seperator = home_page_list.find_first_of('|'); 292 size_t seperator = home_page_list.find_first_of('|');
293 if (seperator == std::string::npos) 293 if (seperator == std::string::npos)
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 size_t stop = std::string::npos; 404 size_t stop = std::string::npos;
405 if (start != std::string::npos) { 405 if (start != std::string::npos) {
406 // Stop at the last ')' on this line. 406 // Stop at the last ')' on this line.
407 stop = content.find("\n", start + 1); 407 stop = content.find("\n", start + 1);
408 stop = content.rfind(")", stop); 408 stop = content.rfind(")", stop);
409 } 409 }
410 410
411 if (start == std::string::npos || stop == std::string::npos || 411 if (start == std::string::npos || stop == std::string::npos ||
412 stop < start) { 412 stop < start) {
413 LOG(WARNING) << "Firefox property " << pref_key << " could not be parsed."; 413 LOG(WARNING) << "Firefox property " << pref_key << " could not be parsed.";
414 return ""; 414 return std::string();
415 } 415 }
416 416
417 // String values have double quotes we don't need to return to the caller. 417 // String values have double quotes we don't need to return to the caller.
418 if (content[start] == '\"' && content[stop - 1] == '\"') { 418 if (content[start] == '\"' && content[stop - 1] == '\"') {
419 ++start; 419 ++start;
420 --stop; 420 --stop;
421 } 421 }
422 422
423 return content.substr(start, stop - start); 423 return content.substr(start, stop - start);
424 } 424 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 } 459 }
460 } 460 }
461 } 461 }
462 } 462 }
463 463
464 StringToLowerASCII(&branding_name); 464 StringToLowerASCII(&branding_name);
465 if (branding_name.find("iceweasel") != std::string::npos) 465 if (branding_name.find("iceweasel") != std::string::npos)
466 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_ICEWEASEL); 466 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_ICEWEASEL);
467 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_FIREFOX); 467 return l10n_util::GetStringUTF16(IDS_IMPORT_FROM_FIREFOX);
468 } 468 }
OLDNEW
« no previous file with comments | « chrome/browser/history/thumbnail_database_unittest.cc ('k') | chrome/browser/internal_auth_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698