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

Side by Side Diff: chrome/utility/importer/firefox_importer.cc

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/utility/importer/firefox_importer.h" 5 #include "chrome/utility/importer/firefox_importer.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 if (base::PathExists(file)) { 349 if (base::PathExists(file)) {
350 // Since Firefox 3.1, passwords are in signons.sqlite db. 350 // Since Firefox 3.1, passwords are in signons.sqlite db.
351 decryptor.ReadAndParseSignons(file, &forms); 351 decryptor.ReadAndParseSignons(file, &forms);
352 } else { 352 } else {
353 // Firefox 3.0 uses signons3.txt to store the passwords. 353 // Firefox 3.0 uses signons3.txt to store the passwords.
354 file = source_path.AppendASCII("signons3.txt"); 354 file = source_path.AppendASCII("signons3.txt");
355 if (!base::PathExists(file)) 355 if (!base::PathExists(file))
356 file = source_path.AppendASCII("signons2.txt"); 356 file = source_path.AppendASCII("signons2.txt");
357 357
358 std::string content; 358 std::string content;
359 file_util::ReadFileToString(file, &content); 359 base::ReadFileToString(file, &content);
360 decryptor.ParseSignons(content, &forms); 360 decryptor.ParseSignons(content, &forms);
361 } 361 }
362 362
363 if (!cancelled()) { 363 if (!cancelled()) {
364 for (size_t i = 0; i < forms.size(); ++i) { 364 for (size_t i = 0; i < forms.size(); ++i) {
365 bridge_->SetPasswordForm(forms[i]); 365 bridge_->SetPasswordForm(forms[i]);
366 } 366 }
367 } 367 }
368 } 368 }
369 369
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 file = app_path.AppendASCII(engine.substr(index + kAppPrefix.length())); 423 file = app_path.AppendASCII(engine.substr(index + kAppPrefix.length()));
424 } else if ((index = engine.find(kProfilePrefix)) != std::string::npos) { 424 } else if ((index = engine.find(kProfilePrefix)) != std::string::npos) {
425 // Remove '[profile]/'. 425 // Remove '[profile]/'.
426 file = profile_path.AppendASCII( 426 file = profile_path.AppendASCII(
427 engine.substr(index + kProfilePrefix.length())); 427 engine.substr(index + kProfilePrefix.length()));
428 } else { 428 } else {
429 // Looks like absolute path to the file. 429 // Looks like absolute path to the file.
430 file = base::FilePath::FromUTF8Unsafe(engine); 430 file = base::FilePath::FromUTF8Unsafe(engine);
431 } 431 }
432 std::string file_data; 432 std::string file_data;
433 file_util::ReadFileToString(file, &file_data); 433 base::ReadFileToString(file, &file_data);
434 search_engine_data->push_back(file_data); 434 search_engine_data->push_back(file_data);
435 } while (s.Step() && !cancelled()); 435 } while (s.Step() && !cancelled());
436 } 436 }
437 437
438 #if defined(OS_POSIX) 438 #if defined(OS_POSIX)
439 // Ubuntu-flavored Firefox supports locale-specific search engines via 439 // Ubuntu-flavored Firefox supports locale-specific search engines via
440 // locale-named subdirectories. They fall back to en-US. 440 // locale-named subdirectories. They fall back to en-US.
441 // See http://crbug.com/53899 441 // See http://crbug.com/53899
442 // TODO(jshin): we need to make sure our locale code matches that of 442 // TODO(jshin): we need to make sure our locale code matches that of
443 // Firefox. 443 // Firefox.
444 DCHECK(!locale_.empty()); 444 DCHECK(!locale_.empty());
445 base::FilePath locale_app_path = app_path.AppendASCII(locale_); 445 base::FilePath locale_app_path = app_path.AppendASCII(locale_);
446 base::FilePath default_locale_app_path = app_path.AppendASCII("en-US"); 446 base::FilePath default_locale_app_path = app_path.AppendASCII("en-US");
447 if (base::DirectoryExists(locale_app_path)) 447 if (base::DirectoryExists(locale_app_path))
448 app_path = locale_app_path; 448 app_path = locale_app_path;
449 else if (base::DirectoryExists(default_locale_app_path)) 449 else if (base::DirectoryExists(default_locale_app_path))
450 app_path = default_locale_app_path; 450 app_path = default_locale_app_path;
451 #endif 451 #endif
452 452
453 // Get search engine definition from file system. 453 // Get search engine definition from file system.
454 base::FileEnumerator engines(app_path, false, base::FileEnumerator::FILES); 454 base::FileEnumerator engines(app_path, false, base::FileEnumerator::FILES);
455 for (base::FilePath engine_path = engines.Next(); 455 for (base::FilePath engine_path = engines.Next();
456 !engine_path.value().empty(); engine_path = engines.Next()) { 456 !engine_path.value().empty(); engine_path = engines.Next()) {
457 std::string file_data; 457 std::string file_data;
458 file_util::ReadFileToString(file, &file_data); 458 base::ReadFileToString(file, &file_data);
459 search_engine_data->push_back(file_data); 459 search_engine_data->push_back(file_data);
460 } 460 }
461 } 461 }
462 462
463 void FirefoxImporter::LoadRootNodeID(sql::Connection* db, 463 void FirefoxImporter::LoadRootNodeID(sql::Connection* db,
464 int* toolbar_folder_id, 464 int* toolbar_folder_id,
465 int* menu_folder_id, 465 int* menu_folder_id,
466 int* unsorted_folder_id) { 466 int* unsorted_folder_id) {
467 static const char* kToolbarFolderName = "toolbar"; 467 static const char* kToolbarFolderName = "toolbar";
468 static const char* kMenuFolderName = "menu"; 468 static const char* kMenuFolderName = "menu";
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 595
596 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) 596 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data))
597 continue; // Unable to decode. 597 continue; // Unable to decode.
598 598
599 usage.urls = i->second; 599 usage.urls = i->second;
600 favicons->push_back(usage); 600 favicons->push_back(usage);
601 } 601 }
602 s.Reset(true); 602 s.Reset(true);
603 } 603 }
604 } 604 }
OLDNEW
« no previous file with comments | « chrome/utility/importer/bookmark_html_reader.cc ('k') | chrome/utility/importer/ie_importer_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698