diff options
Diffstat (limited to 'chrome/browser/importer')
30 files changed, 217 insertions, 198 deletions
diff --git a/chrome/browser/importer/firefox2_importer.cc b/chrome/browser/importer/firefox2_importer.cc index d524b64..8e88d23 100644 --- a/chrome/browser/importer/firefox2_importer.cc +++ b/chrome/browser/importer/firefox2_importer.cc @@ -90,9 +90,9 @@ void Firefox2Importer::StartImport( } // static -void Firefox2Importer::LoadDefaultBookmarks(const FilePath& app_path, +void Firefox2Importer::LoadDefaultBookmarks(const base::FilePath& app_path, std::set<GURL> *urls) { - FilePath file = app_path.AppendASCII("defaults") + base::FilePath file = app_path.AppendASCII("defaults") .AppendASCII("profile") .AppendASCII("bookmarks.html"); @@ -145,7 +145,7 @@ TemplateURL* Firefox2Importer::CreateTemplateURL(const string16& title, // static void Firefox2Importer::ImportBookmarksFile( - const FilePath& file_path, + const base::FilePath& file_path, const std::set<GURL>& default_urls, Importer* importer, std::vector<ProfileWriter::BookmarkEntry>* bookmarks, @@ -299,7 +299,7 @@ void Firefox2Importer::ImportBookmarks() { std::vector<ProfileWriter::BookmarkEntry> bookmarks, toolbar_bookmarks; std::vector<TemplateURL*> template_urls; std::vector<history::ImportedFaviconUsage> favicons; - FilePath file = source_path_; + base::FilePath file = source_path_; if (!parsing_bookmarks_html_file_) file = file.AppendASCII("bookmarks.html"); @@ -331,7 +331,7 @@ void Firefox2Importer::ImportPasswords() { // Firefox 2 uses signons2.txt to store the pssswords. If it doesn't // exist, we try to find its older version. - FilePath file = source_path_.AppendASCII("signons2.txt"); + base::FilePath file = source_path_.AppendASCII("signons2.txt"); if (!file_util::PathExists(file)) { file = source_path_.AppendASCII("signons.txt"); } @@ -349,12 +349,12 @@ void Firefox2Importer::ImportPasswords() { } void Firefox2Importer::ImportHistory() { - FilePath file = source_path_.AppendASCII("history.dat"); + base::FilePath file = source_path_.AppendASCII("history.dat"); ImportHistoryFromFirefox2(file, bridge_); } void Firefox2Importer::ImportSearchEngines() { - std::vector<FilePath> files; + std::vector<base::FilePath> files; GetSearchEnginesXMLFiles(&files); std::vector<TemplateURL*> search_engines; @@ -371,15 +371,15 @@ void Firefox2Importer::ImportHomepage() { } void Firefox2Importer::GetSearchEnginesXMLFiles( - std::vector<FilePath>* files) { + std::vector<base::FilePath>* files) { // Search engines are contained in XML files in a searchplugins directory that // can be found in 2 locations: // - Firefox install dir (default search engines) // - the profile dir (user added search engines) - FilePath dir = app_path_.AppendASCII("searchplugins"); + base::FilePath dir = app_path_.AppendASCII("searchplugins"); FindXMLFilesInDir(dir, files); - FilePath profile_dir = source_path_.AppendASCII("searchplugins"); + base::FilePath profile_dir = source_path_.AppendASCII("searchplugins"); FindXMLFilesInDir(profile_dir, files); } @@ -622,12 +622,12 @@ void Firefox2Importer::HTMLUnescape(string16* text) { // static void Firefox2Importer::FindXMLFilesInDir( - const FilePath& dir, - std::vector<FilePath>* xml_files) { + const base::FilePath& dir, + std::vector<base::FilePath>* xml_files) { file_util::FileEnumerator file_enum(dir, false, file_util::FileEnumerator::FILES, FILE_PATH_LITERAL("*.xml")); - FilePath file(file_enum.Next()); + base::FilePath file(file_enum.Next()); while (!file.empty()) { xml_files->push_back(file); file = file_enum.Next(); diff --git a/chrome/browser/importer/firefox2_importer.h b/chrome/browser/importer/firefox2_importer.h index 8a7337a..a8d880e 100644 --- a/chrome/browser/importer/firefox2_importer.h +++ b/chrome/browser/importer/firefox2_importer.h @@ -30,7 +30,7 @@ class Firefox2Importer : public Importer { // Loads the default bookmarks in the Firefox installed at |firefox_app_path|, // and stores their locations in |urls|. - static void LoadDefaultBookmarks(const FilePath& firefox_app_path, + static void LoadDefaultBookmarks(const base::FilePath& firefox_app_path, std::set<GURL>* urls); // Creates a TemplateURL with the |keyword| and |url|. |title| may be empty. @@ -43,7 +43,7 @@ class Firefox2Importer : public Importer { // |favicons| may be null, in which case TemplateURLs and favicons are // not parsed. Any bookmarks in |default_urls| are ignored. static void ImportBookmarksFile( - const FilePath& file_path, + const base::FilePath& file_path, const std::set<GURL>& default_urls, Importer* importer, std::vector<ProfileWriter::BookmarkEntry>* bookmarks, @@ -67,7 +67,7 @@ class Firefox2Importer : public Importer { // Fills |files| with the paths to the files containing the search engine // descriptions. - void GetSearchEnginesXMLFiles(std::vector<FilePath>* files); + void GetSearchEnginesXMLFiles(std::vector<base::FilePath>* files); // Helper methods for parsing bookmark file. // Firefox 2 saves its bookmarks in a html file. We are interested in the @@ -124,8 +124,8 @@ class Firefox2Importer : public Importer { static void HTMLUnescape(string16* text); // Fills |xml_files| with the file with an xml extension found under |dir|. - static void FindXMLFilesInDir(const FilePath& dir, - std::vector<FilePath>* xml_files); + static void FindXMLFilesInDir(const base::FilePath& dir, + std::vector<base::FilePath>* xml_files); // Given the URL of a page and a favicon data URL, adds an appropriate record // to the given favicon usage vector. Will do nothing if the favicon is not @@ -135,8 +135,8 @@ class Firefox2Importer : public Importer { const GURL& favicon_data, std::vector<history::ImportedFaviconUsage>* favicons); - FilePath source_path_; - FilePath app_path_; + base::FilePath source_path_; + base::FilePath app_path_; // If true, we only parse the bookmarks.html file specified as source_path_. bool parsing_bookmarks_html_file_; diff --git a/chrome/browser/importer/firefox3_importer.cc b/chrome/browser/importer/firefox3_importer.cc index 6a38c66..2cab2ca 100644 --- a/chrome/browser/importer/firefox3_importer.cc +++ b/chrome/browser/importer/firefox3_importer.cc @@ -109,7 +109,7 @@ void Firefox3Importer::StartImport( } void Firefox3Importer::ImportHistory() { - FilePath file = source_path_.AppendASCII("places.sqlite"); + base::FilePath file = source_path_.AppendASCII("places.sqlite"); if (!file_util::PathExists(file)) return; @@ -153,7 +153,7 @@ void Firefox3Importer::ImportHistory() { } void Firefox3Importer::ImportBookmarks() { - FilePath file = source_path_.AppendASCII("places.sqlite"); + base::FilePath file = source_path_.AppendASCII("places.sqlite"); if (!file_util::PathExists(file)) return; @@ -308,8 +308,8 @@ void Firefox3Importer::ImportPasswords() { } std::vector<content::PasswordForm> forms; - FilePath source_path = source_path_; - FilePath file = source_path.AppendASCII("signons.sqlite"); + base::FilePath source_path = source_path_; + base::FilePath file = source_path.AppendASCII("signons.sqlite"); if (file_util::PathExists(file)) { // Since Firefox 3.1, passwords are in signons.sqlite db. decryptor.ReadAndParseSignons(file, &forms); @@ -332,7 +332,7 @@ void Firefox3Importer::ImportPasswords() { } void Firefox3Importer::ImportSearchEngines() { - std::vector<FilePath> files; + std::vector<base::FilePath> files; GetSearchEnginesXMLFiles(&files); std::vector<TemplateURL*> search_engines; @@ -349,8 +349,8 @@ void Firefox3Importer::ImportHomepage() { } void Firefox3Importer::GetSearchEnginesXMLFiles( - std::vector<FilePath>* files) { - FilePath file = source_path_.AppendASCII("search.sqlite"); + std::vector<base::FilePath>* files) { + base::FilePath file = source_path_.AppendASCII("search.sqlite"); if (!file_util::PathExists(file)) return; @@ -368,8 +368,8 @@ void Firefox3Importer::GetSearchEnginesXMLFiles( if (!s.is_valid()) return; - FilePath app_path = app_path_.AppendASCII("searchplugins"); - FilePath profile_path = source_path_.AppendASCII("searchplugins"); + base::FilePath app_path = app_path_.AppendASCII("searchplugins"); + base::FilePath profile_path = source_path_.AppendASCII("searchplugins"); // Firefox doesn't store a search engine in its sqlite database unless the // user has added a engine. So we get search engines from sqlite db as well @@ -378,7 +378,7 @@ void Firefox3Importer::GetSearchEnginesXMLFiles( const std::string kAppPrefix("[app]/"); const std::string kProfilePrefix("[profile]/"); do { - FilePath file; + base::FilePath file; std::string engine(s.ColumnString(0)); // The string contains [app]/<name>.xml or [profile]/<name>.xml where @@ -395,9 +395,9 @@ void Firefox3Importer::GetSearchEnginesXMLFiles( } else { // Looks like absolute path to the file. #if defined(OS_WIN) - file = FilePath(UTF8ToWide(engine)); + file = base::FilePath(UTF8ToWide(engine)); #else - file = FilePath(engine); + file = base::FilePath(engine); #endif } files->push_back(file); @@ -410,8 +410,8 @@ void Firefox3Importer::GetSearchEnginesXMLFiles( // See http://crbug.com/53899 // TODO(jshin): we need to make sure our locale code matches that of // Firefox. - FilePath locale_app_path = app_path.AppendASCII(locale_); - FilePath default_locale_app_path = app_path.AppendASCII("en-US"); + base::FilePath locale_app_path = app_path.AppendASCII(locale_); + base::FilePath default_locale_app_path = app_path.AppendASCII("en-US"); if (file_util::DirectoryExists(locale_app_path)) app_path = locale_app_path; else if (file_util::DirectoryExists(default_locale_app_path)) @@ -421,8 +421,8 @@ void Firefox3Importer::GetSearchEnginesXMLFiles( // Get search engine definition from file system. file_util::FileEnumerator engines(app_path, false, file_util::FileEnumerator::FILES); - for (FilePath engine_path = engines.Next(); !engine_path.value().empty(); - engine_path = engines.Next()) { + for (base::FilePath engine_path = engines.Next(); + !engine_path.value().empty(); engine_path = engines.Next()) { files->push_back(engine_path); } } diff --git a/chrome/browser/importer/firefox3_importer.h b/chrome/browser/importer/firefox3_importer.h index 550d0d2..877a0fa 100644 --- a/chrome/browser/importer/firefox3_importer.h +++ b/chrome/browser/importer/firefox3_importer.h @@ -49,7 +49,7 @@ class Firefox3Importer : public Importer { // Import the user's home page, unless it is set to default home page as // defined in browserconfig.properties. void ImportHomepage(); - void GetSearchEnginesXMLFiles(std::vector<FilePath>* files); + void GetSearchEnginesXMLFiles(std::vector<base::FilePath>* files); // The struct stores the information about a bookmark item. struct BookmarkItem; @@ -78,8 +78,8 @@ class Firefox3Importer : public Importer { const FaviconMap& favicon_map, std::vector<history::ImportedFaviconUsage>* favicons); - FilePath source_path_; - FilePath app_path_; + base::FilePath source_path_; + base::FilePath app_path_; #if defined(OS_POSIX) && !defined(OS_MACOSX) // Stored because we can only access it from the UI thread. Not usable diff --git a/chrome/browser/importer/firefox_importer_unittest.cc b/chrome/browser/importer/firefox_importer_unittest.cc index 7ec2f21..6551b35 100644 --- a/chrome/browser/importer/firefox_importer_unittest.cc +++ b/chrome/browser/importer/firefox_importer_unittest.cc @@ -373,7 +373,7 @@ class FirefoxProfileImporterTest : public ImporterTest { virtual void SetUp() OVERRIDE { ImporterTest::SetUp(); // Creates a new profile in a new subdirectory in the temp directory. - FilePath test_path = temp_dir_.path().AppendASCII("ImporterTest"); + base::FilePath test_path = temp_dir_.path().AppendASCII("ImporterTest"); file_util::Delete(test_path, true); file_util::CreateDirectory(test_path); profile_path_ = test_path.AppendASCII("profile"); @@ -385,7 +385,7 @@ class FirefoxProfileImporterTest : public ImporterTest { importer::ImporterProgressObserver* observer, ProfileWriter* writer, bool import_search_plugins) { - FilePath data_path; + base::FilePath data_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); data_path = data_path.AppendASCII(profile_dir); ASSERT_TRUE(file_util::CopyDirectory(data_path, profile_path_, true)); @@ -393,7 +393,7 @@ class FirefoxProfileImporterTest : public ImporterTest { data_path = data_path.AppendASCII("firefox3_nss"); ASSERT_TRUE(file_util::CopyDirectory(data_path, profile_path_, false)); - FilePath search_engine_path = app_path_; + base::FilePath search_engine_path = app_path_; search_engine_path = search_engine_path.AppendASCII("searchplugins"); file_util::CreateDirectory(search_engine_path); if (import_search_plugins) { @@ -424,12 +424,12 @@ class FirefoxProfileImporterTest : public ImporterTest { loop->Run(); } - FilePath profile_path_; - FilePath app_path_; + base::FilePath profile_path_; + base::FilePath app_path_; }; TEST_F(FirefoxProfileImporterTest, MAYBE(Firefox2Importer)) { - FilePath data_path; + base::FilePath data_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); data_path = data_path.AppendASCII("firefox2_profile"); ASSERT_TRUE(file_util::CopyDirectory(data_path, profile_path_, true)); @@ -437,7 +437,7 @@ TEST_F(FirefoxProfileImporterTest, MAYBE(Firefox2Importer)) { data_path = data_path.AppendASCII("firefox2_nss"); ASSERT_TRUE(file_util::CopyDirectory(data_path, profile_path_, false)); - FilePath search_engine_path = app_path_; + base::FilePath search_engine_path = app_path_; search_engine_path = search_engine_path.AppendASCII("searchplugins"); file_util::CreateDirectory(search_engine_path); ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); @@ -488,14 +488,14 @@ TEST_F(FirefoxProfileImporterTest, MAYBE(Firefox35Importer)) { // to run in a separate process, so we use a proxy object so we can share the // same test between platforms. TEST(FirefoxImporterTest, Firefox2NSS3Decryptor) { - FilePath nss_path; + base::FilePath nss_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); #ifdef OS_MACOSX nss_path = nss_path.AppendASCII("firefox2_nss_mac"); #else nss_path = nss_path.AppendASCII("firefox2_nss"); #endif // !OS_MACOSX - FilePath db_path; + base::FilePath db_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); db_path = db_path.AppendASCII("firefox2_profile"); @@ -513,14 +513,14 @@ TEST(FirefoxImporterTest, Firefox2NSS3Decryptor) { } TEST(FirefoxImporterTest, Firefox3NSS3Decryptor) { - FilePath nss_path; + base::FilePath nss_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); #ifdef OS_MACOSX nss_path = nss_path.AppendASCII("firefox3_nss_mac"); #else nss_path = nss_path.AppendASCII("firefox3_nss"); #endif // !OS_MACOSX - FilePath db_path; + base::FilePath db_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &db_path)); db_path = db_path.AppendASCII("firefox3_profile"); @@ -654,12 +654,12 @@ TEST(FirefoxImporterTest, Firefox2BookmarkParse) { } TEST(FirefoxImporterTest, Firefox2BookmarkFileImport) { - FilePath path; + base::FilePath path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); path = path.AppendASCII("firefox2_importer"); // Import all bookmarks from a file which include an empty folder entry. - FilePath empty_folder_path = path.AppendASCII("empty_folder.html"); + base::FilePath empty_folder_path = path.AppendASCII("empty_folder.html"); std::set<GURL> default_urls; Firefox2Importer* importer = new Firefox2Importer(); importer->AddRef(); @@ -726,7 +726,7 @@ TEST(FirefoxImporterTest, Firefox2BookmarkFileImport) { } // Import Epiphany bookmarks from a file - FilePath epiphany_path = path.AppendASCII("epiphany.html"); + base::FilePath epiphany_path = path.AppendASCII("epiphany.html"); bookmarks.clear(); default_urls.clear(); importer->ImportBookmarksFile(epiphany_path, default_urls, diff --git a/chrome/browser/importer/firefox_importer_unittest_messages_internal.h b/chrome/browser/importer/firefox_importer_unittest_messages_internal.h index b0e25c2..ce29947 100644 --- a/chrome/browser/importer/firefox_importer_unittest_messages_internal.h +++ b/chrome/browser/importer/firefox_importer_unittest_messages_internal.h @@ -11,8 +11,8 @@ // Server->Child: Initialize the decrytor with the following paramters. IPC_MESSAGE_CONTROL2(Msg_Decryptor_Init, - FilePath /* dll_path */, - FilePath /* db_path */) + base::FilePath /* dll_path */, + base::FilePath /* db_path */) // Child->Server: Return paramter from init call. IPC_MESSAGE_CONTROL1(Msg_Decryptor_InitReturnCode, bool /* ret */) diff --git a/chrome/browser/importer/firefox_importer_unittest_utils.h b/chrome/browser/importer/firefox_importer_unittest_utils.h index 51d40ac..1d6cc69 100644 --- a/chrome/browser/importer/firefox_importer_unittest_utils.h +++ b/chrome/browser/importer/firefox_importer_unittest_utils.h @@ -34,10 +34,11 @@ class FFUnitTestDecryptorProxy { // Initialize a decryptor, returns true if the object was // constructed successfully. - bool Setup(const FilePath& nss_path); + bool Setup(const base::FilePath& nss_path); // This match the parallel functions in NSSDecryptor. - bool DecryptorInit(const FilePath& dll_path, const FilePath& db_path); + bool DecryptorInit(const base::FilePath& dll_path, + const base::FilePath& db_path); string16 Decrypt(const std::string& crypt); private: @@ -67,12 +68,12 @@ FFUnitTestDecryptorProxy::FFUnitTestDecryptorProxy() { FFUnitTestDecryptorProxy::~FFUnitTestDecryptorProxy() { } -bool FFUnitTestDecryptorProxy::Setup(const FilePath& nss_path) { +bool FFUnitTestDecryptorProxy::Setup(const base::FilePath& nss_path) { return true; } -bool FFUnitTestDecryptorProxy::DecryptorInit(const FilePath& dll_path, - const FilePath& db_path) { +bool FFUnitTestDecryptorProxy::DecryptorInit(const base::FilePath& dll_path, + const base::FilePath& db_path) { return decryptor_.Init(dll_path, db_path); } diff --git a/chrome/browser/importer/firefox_importer_unittest_utils_mac.cc b/chrome/browser/importer/firefox_importer_unittest_utils_mac.cc index 077571a..f9891c5 100644 --- a/chrome/browser/importer/firefox_importer_unittest_utils_mac.cc +++ b/chrome/browser/importer/firefox_importer_unittest_utils_mac.cc @@ -33,7 +33,7 @@ const char kTestChannelID[] = "T1"; // |channel| - IPC Channel to use for communication. // |handle| - On return, the process handle to use to communicate with the // child. -bool LaunchNSSDecrypterChildProcess(const FilePath& nss_path, +bool LaunchNSSDecrypterChildProcess(const base::FilePath& nss_path, IPC::Channel* channel, base::ProcessHandle* handle) { CommandLine cl(*CommandLine::ForCurrentProcess()); cl.AppendSwitchASCII(switches::kTestChildProcess, "NSSDecrypterChildProcess"); @@ -130,7 +130,7 @@ FFUnitTestDecryptorProxy::FFUnitTestDecryptorProxy() : child_process_(0) { } -bool FFUnitTestDecryptorProxy::Setup(const FilePath& nss_path) { +bool FFUnitTestDecryptorProxy::Setup(const base::FilePath& nss_path) { // Create a new message loop and spawn the child process. message_loop_.reset(new MessageLoopForIO()); @@ -196,8 +196,8 @@ bool FFUnitTestDecryptorProxy::WaitForClientResponse() { return ret; } -bool FFUnitTestDecryptorProxy::DecryptorInit(const FilePath& dll_path, - const FilePath& db_path) { +bool FFUnitTestDecryptorProxy::DecryptorInit(const base::FilePath& dll_path, + const base::FilePath& db_path) { channel_->Send(new Msg_Decryptor_Init(dll_path, db_path)); bool ok = WaitForClientResponse(); if (ok && listener_->got_result) { @@ -230,7 +230,7 @@ class FFDecryptorClientChannelListener : public IPC::Listener { sender_ = sender; } - void OnDecryptor_Init(FilePath dll_path, FilePath db_path) { + void OnDecryptor_Init(base::FilePath dll_path, base::FilePath db_path) { bool ret = decryptor_.Init(dll_path, db_path); sender_->Send(new Msg_Decryptor_InitReturnCode(ret)); } diff --git a/chrome/browser/importer/firefox_importer_utils.cc b/chrome/browser/importer/firefox_importer_utils.cc index 071423e..2bbcb39 100644 --- a/chrome/browser/importer/firefox_importer_utils.cc +++ b/chrome/browser/importer/firefox_importer_utils.cc @@ -49,12 +49,12 @@ class FirefoxURLParameterFilter : public TemplateURLParser::ParameterFilter { }; } // namespace -FilePath GetFirefoxProfilePath() { +base::FilePath GetFirefoxProfilePath() { DictionaryValue root; - FilePath ini_file = GetProfilesINI(); + base::FilePath ini_file = GetProfilesINI(); ParseProfileINI(ini_file, &root); - FilePath source_path; + base::FilePath source_path; for (int i = 0; ; ++i) { std::string current_profile = StringPrintf("Profile%d", i); if (!root.HasKey(current_profile)) { @@ -70,7 +70,8 @@ FilePath GetFirefoxProfilePath() { ReplaceSubstringsAfterOffset( &path16, 0, ASCIIToUTF16("/"), ASCIIToUTF16("\\")); #endif - FilePath path = FilePath::FromWStringHack(UTF16ToWide(path16)); + base::FilePath path = + base::FilePath::FromWStringHack(UTF16ToWide(path16)); // IsRelative=1 means the folder path would be relative to the // path of profiles.ini. IsRelative=0 refers to a custom profile @@ -90,15 +91,16 @@ FilePath GetFirefoxProfilePath() { } } } - return FilePath(); + return base::FilePath(); } -bool GetFirefoxVersionAndPathFromProfile(const FilePath& profile_path, +bool GetFirefoxVersionAndPathFromProfile(const base::FilePath& profile_path, int* version, - FilePath* app_path) { + base::FilePath* app_path) { bool ret = false; - FilePath compatibility_file = profile_path.AppendASCII("compatibility.ini"); + base::FilePath compatibility_file = + profile_path.AppendASCII("compatibility.ini"); std::string content; file_util::ReadFileToString(compatibility_file, &content); ReplaceSubstringsAfterOffset(&content, 0, "\r\n", "\n"); @@ -120,7 +122,7 @@ bool GetFirefoxVersionAndPathFromProfile(const FilePath& profile_path, // UTF-8, what does Firefox do? If it puts raw bytes in the // file, we could go straight from bytes -> filepath; // otherwise, we're out of luck here. - *app_path = FilePath::FromWStringHack( + *app_path = base::FilePath::FromWStringHack( UTF8ToWide(line.substr(equal + 1))); } } @@ -128,7 +130,7 @@ bool GetFirefoxVersionAndPathFromProfile(const FilePath& profile_path, return ret; } -void ParseProfileINI(const FilePath& file, DictionaryValue* root) { +void ParseProfileINI(const base::FilePath& file, DictionaryValue* root) { // Reads the whole INI file. std::string content; file_util::ReadFileToString(file, &content); @@ -188,8 +190,9 @@ bool CanImportURL(const GURL& url) { return true; } -void ParseSearchEnginesFromXMLFiles(const std::vector<FilePath>& xml_files, - std::vector<TemplateURL*>* search_engines) { +void ParseSearchEnginesFromXMLFiles( + const std::vector<base::FilePath>& xml_files, + std::vector<TemplateURL*>* search_engines) { DCHECK(search_engines); typedef std::map<std::string, TemplateURL*> SearchEnginesMap; @@ -198,8 +201,8 @@ void ParseSearchEnginesFromXMLFiles(const std::vector<FilePath>& xml_files, // The first XML file represents the default search engine in Firefox 3, so we // need to keep it on top of the list. SearchEnginesMap::const_iterator default_turl = search_engine_for_url.end(); - for (std::vector<FilePath>::const_iterator file_iter = xml_files.begin(); - file_iter != xml_files.end(); ++file_iter) { + for (std::vector<base::FilePath>::const_iterator file_iter = + xml_files.begin(); file_iter != xml_files.end(); ++file_iter) { file_util::ReadFileToString(*file_iter, &content); FirefoxURLParameterFilter param_filter; TemplateURL* template_url = TemplateURLParser::Parse(NULL, true, @@ -234,7 +237,7 @@ void ParseSearchEnginesFromXMLFiles(const std::vector<FilePath>& xml_files, } } -bool ReadPrefFile(const FilePath& path, std::string* content) { +bool ReadPrefFile(const base::FilePath& path, std::string* content) { if (content == NULL) return false; @@ -248,7 +251,7 @@ bool ReadPrefFile(const FilePath& path, std::string* content) { return true; } -std::string ReadBrowserConfigProp(const FilePath& app_path, +std::string ReadBrowserConfigProp(const base::FilePath& app_path, const std::string& pref_key) { std::string content; if (!ReadPrefFile(app_path.AppendASCII("browserconfig.properties"), &content)) @@ -273,7 +276,7 @@ std::string ReadBrowserConfigProp(const FilePath& app_path, return content.substr(start + 1, stop - start - 1); } -std::string ReadPrefsJsValue(const FilePath& profile_path, +std::string ReadPrefsJsValue(const base::FilePath& profile_path, const std::string& pref_key) { std::string content; if (!ReadPrefFile(profile_path.AppendASCII("prefs.js"), &content)) @@ -282,7 +285,7 @@ std::string ReadPrefsJsValue(const FilePath& profile_path, return GetPrefsJsValue(content, pref_key); } -GURL GetHomepage(const FilePath& profile_path) { +GURL GetHomepage(const base::FilePath& profile_path) { std::string home_page_list = ReadPrefsJsValue(profile_path, "browser.startup.homepage"); @@ -293,7 +296,7 @@ GURL GetHomepage(const FilePath& profile_path) { return GURL(home_page_list.substr(0, seperator)); } -bool IsDefaultHomepage(const GURL& homepage, const FilePath& app_path) { +bool IsDefaultHomepage(const GURL& homepage, const base::FilePath& app_path) { if (!homepage.is_valid()) return false; @@ -316,7 +319,7 @@ bool IsDefaultHomepage(const GURL& homepage, const FilePath& app_path) { return false; } -bool ParsePrefFile(const FilePath& pref_file, DictionaryValue* prefs) { +bool ParsePrefFile(const base::FilePath& pref_file, DictionaryValue* prefs) { // The string that is before a pref key. const std::string kUserPrefString = "user_pref(\""; std::string contents; @@ -432,8 +435,8 @@ std::string GetPrefsJsValue(const std::string& content, // ID={ec8030f7-c20a-464f-9b0e-13a3a9e97384} // ......................................... // In this example the function returns "Iceweasel" (or a localized equivalent). -string16 GetFirefoxImporterName(const FilePath& app_path) { - const FilePath app_ini_file = app_path.AppendASCII("application.ini"); +string16 GetFirefoxImporterName(const base::FilePath& app_path) { + const base::FilePath app_ini_file = app_path.AppendASCII("application.ini"); std::string branding_name; if (file_util::PathExists(app_ini_file)) { std::string content; diff --git a/chrome/browser/importer/firefox_importer_utils_linux.cc b/chrome/browser/importer/firefox_importer_utils_linux.cc index eeefd38..98f9c2a4 100644 --- a/chrome/browser/importer/firefox_importer_utils_linux.cc +++ b/chrome/browser/importer/firefox_importer_utils_linux.cc @@ -6,16 +6,16 @@ #include "base/file_util.h" -FilePath GetProfilesINI() { - FilePath ini_file; +base::FilePath GetProfilesINI() { + base::FilePath ini_file; // The default location of the profile folder containing user data is // under user HOME directory in .mozilla/firefox folder on Linux. - FilePath home = file_util::GetHomeDir(); + base::FilePath home = file_util::GetHomeDir(); if (!home.empty()) { ini_file = home.Append(".mozilla/firefox/profiles.ini"); } if (file_util::PathExists(ini_file)) return ini_file; - return FilePath(); + return base::FilePath(); } diff --git a/chrome/browser/importer/firefox_importer_utils_mac.mm b/chrome/browser/importer/firefox_importer_utils_mac.mm index fa82369c..6aa9040 100644 --- a/chrome/browser/importer/firefox_importer_utils_mac.mm +++ b/chrome/browser/importer/firefox_importer_utils_mac.mm @@ -11,26 +11,27 @@ #include "base/mac/foundation_util.h" #include "base/path_service.h" -FilePath GetProfilesINI() { - FilePath app_data_path; +base::FilePath GetProfilesINI() { + base::FilePath app_data_path; if (!PathService::Get(base::DIR_APP_DATA, &app_data_path)) { - return FilePath(); + return base::FilePath(); } - FilePath ini_file = app_data_path.Append("Firefox").Append("profiles.ini"); + base::FilePath ini_file = + app_data_path.Append("Firefox").Append("profiles.ini"); if (!file_util::PathExists(ini_file)) { - return FilePath(); + return base::FilePath(); } return ini_file; } -FilePath GetFirefoxDylibPath() { +base::FilePath GetFirefoxDylibPath() { CFURLRef appURL = nil; if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("org.mozilla.firefox"), NULL, NULL, &appURL) != noErr) { - return FilePath(); + return base::FilePath(); } NSBundle *ff_bundle = [NSBundle bundleWithPath:[base::mac::CFToNSCast(appURL) path]]; @@ -39,6 +40,6 @@ FilePath GetFirefoxDylibPath() { [[ff_bundle executablePath] stringByDeletingLastPathComponent]; char buf[MAXPATHLEN]; if (![ff_library_path getFileSystemRepresentation:buf maxLength:sizeof(buf)]) - return FilePath(); - return FilePath(buf); + return base::FilePath(); + return base::FilePath(buf); } diff --git a/chrome/browser/importer/firefox_importer_utils_unittest.cc b/chrome/browser/importer/firefox_importer_utils_unittest.cc index 914a4b7..b393d71 100644 --- a/chrome/browser/importer/firefox_importer_utils_unittest.cc +++ b/chrome/browser/importer/firefox_importer_utils_unittest.cc @@ -102,7 +102,8 @@ TEST(FirefoxImporterUtilsTest, GetPrefsJsValue) { TEST(FirefoxImporterUtilsTest, GetFirefoxImporterName) { base::ScopedTempDir temp_dir; ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); - const FilePath app_ini_file(temp_dir.path().AppendASCII("application.ini")); + const base::FilePath app_ini_file( + temp_dir.path().AppendASCII("application.ini")); for (size_t i = 0; i < arraysize(GetFirefoxImporterNameCases); ++i) { file_util::WriteFile(app_ini_file, GetFirefoxImporterNameCases[i].app_ini_content.c_str(), @@ -110,6 +111,8 @@ TEST(FirefoxImporterUtilsTest, GetFirefoxImporterName) { EXPECT_EQ(GetFirefoxImporterName(temp_dir.path()), l10n_util::GetStringUTF16(GetFirefoxImporterNameCases[i].resource_id)); } - EXPECT_EQ(l10n_util::GetStringUTF16(IDS_IMPORT_FROM_FIREFOX), - GetFirefoxImporterName(FilePath(FILE_PATH_LITERAL("/invalid/path")))); + EXPECT_EQ(l10n_util::GetStringUTF16( + IDS_IMPORT_FROM_FIREFOX), + GetFirefoxImporterName(base::FilePath( + FILE_PATH_LITERAL("/invalid/path")))); } diff --git a/chrome/browser/importer/firefox_importer_utils_win.cc b/chrome/browser/importer/firefox_importer_utils_win.cc index f289207..dc6e1ad 100644 --- a/chrome/browser/importer/firefox_importer_utils_win.cc +++ b/chrome/browser/importer/firefox_importer_utils_win.cc @@ -45,7 +45,7 @@ int GetCurrentFirefoxMajorVersionFromRegistry() { return highest_version; } -FilePath GetFirefoxInstallPathFromRegistry() { +base::FilePath GetFirefoxInstallPathFromRegistry() { // Detects the path that Firefox is installed in. string16 registry_path = kFirefoxPath; wchar_t buffer[MAX_PATH]; @@ -55,7 +55,7 @@ FilePath GetFirefoxInstallPathFromRegistry() { LONG result = reg_key.ReadValue(kCurrentVersion, buffer, &buffer_length, NULL); if (result != ERROR_SUCCESS) - return FilePath(); + return base::FilePath(); registry_path += L"\\" + string16(buffer) + L"\\Main"; buffer_length = sizeof(buffer); @@ -64,19 +64,19 @@ FilePath GetFirefoxInstallPathFromRegistry() { result = reg_key_directory.ReadValue(L"Install Directory", buffer, &buffer_length, NULL); - return (result != ERROR_SUCCESS) ? FilePath() : FilePath(buffer); + return (result != ERROR_SUCCESS) ? base::FilePath() : base::FilePath(buffer); } -FilePath GetProfilesINI() { - FilePath ini_file; +base::FilePath GetProfilesINI() { + base::FilePath ini_file; // The default location of the profile folder containing user data is // under the "Application Data" folder in Windows XP, Vista, and 7. if (!PathService::Get(base::DIR_APP_DATA, &ini_file)) - return FilePath(); + return base::FilePath(); ini_file = ini_file.AppendASCII("Mozilla"); ini_file = ini_file.AppendASCII("Firefox"); ini_file = ini_file.AppendASCII("profiles.ini"); - return file_util::PathExists(ini_file) ? ini_file : FilePath(); + return file_util::PathExists(ini_file) ? ini_file : base::FilePath(); } diff --git a/chrome/browser/importer/firefox_profile_lock.cc b/chrome/browser/importer/firefox_profile_lock.cc index aa66bff..1232890 100644 --- a/chrome/browser/importer/firefox_profile_lock.cc +++ b/chrome/browser/importer/firefox_profile_lock.cc @@ -54,22 +54,22 @@ // static #if defined(OS_MACOSX) -const FilePath::CharType* FirefoxProfileLock::kLockFileName = +const base::FilePath::CharType* FirefoxProfileLock::kLockFileName = FILE_PATH_LITERAL(".parentlock"); -const FilePath::CharType* FirefoxProfileLock::kOldLockFileName = +const base::FilePath::CharType* FirefoxProfileLock::kOldLockFileName = FILE_PATH_LITERAL("parent.lock"); #elif defined(OS_POSIX) // http://www.google.com/codesearch/p?hl=en#e_ObwTAVPyo/profile/dirserviceprovider/src/nsProfileLock.cpp&l=433 -const FilePath::CharType* FirefoxProfileLock::kLockFileName = +const base::FilePath::CharType* FirefoxProfileLock::kLockFileName = FILE_PATH_LITERAL(".parentlock"); -const FilePath::CharType* FirefoxProfileLock::kOldLockFileName = +const base::FilePath::CharType* FirefoxProfileLock::kOldLockFileName = FILE_PATH_LITERAL("lock"); #else -const FilePath::CharType* FirefoxProfileLock::kLockFileName = +const base::FilePath::CharType* FirefoxProfileLock::kLockFileName = FILE_PATH_LITERAL("parent.lock"); #endif -FirefoxProfileLock::FirefoxProfileLock(const FilePath& path) { +FirefoxProfileLock::FirefoxProfileLock(const base::FilePath& path) { Init(); lock_file_ = path.Append(kLockFileName); Lock(); diff --git a/chrome/browser/importer/firefox_profile_lock.h b/chrome/browser/importer/firefox_profile_lock.h index 210d878..98141675 100644 --- a/chrome/browser/importer/firefox_profile_lock.h +++ b/chrome/browser/importer/firefox_profile_lock.h @@ -67,7 +67,7 @@ class FirefoxProfileLock { public: - explicit FirefoxProfileLock(const FilePath& path); + explicit FirefoxProfileLock(const base::FilePath& path); ~FirefoxProfileLock(); // Locks and releases the profile. @@ -81,13 +81,13 @@ class FirefoxProfileLock { FRIEND_TEST_ALL_PREFIXES(FirefoxProfileLockTest, ProfileLock); FRIEND_TEST_ALL_PREFIXES(FirefoxProfileLockTest, ProfileLockOrphaned); - static const FilePath::CharType* kLockFileName; - static const FilePath::CharType* kOldLockFileName; + static const base::FilePath::CharType* kLockFileName; + static const base::FilePath::CharType* kOldLockFileName; void Init(); // Full path of the lock file in the profile folder. - FilePath lock_file_; + base::FilePath lock_file_; // The handle of the lock file. #if defined(OS_WIN) @@ -98,7 +98,7 @@ class FirefoxProfileLock { // On Posix systems Firefox apparently first tries to put a fcntl lock // on a file and if that fails, it does a regular exculsive open on another // file. This variable contains the location of this other file. - FilePath old_lock_file_; + base::FilePath old_lock_file_; // Method that tries to put a fcntl lock on file specified by |lock_file_|. // Returns false if lock is already held by another process. true in all diff --git a/chrome/browser/importer/firefox_profile_lock_unittest.cc b/chrome/browser/importer/firefox_profile_lock_unittest.cc index a9a2257..1f1f043 100644 --- a/chrome/browser/importer/firefox_profile_lock_unittest.cc +++ b/chrome/browser/importer/firefox_profile_lock_unittest.cc @@ -33,8 +33,9 @@ TEST_F(FirefoxProfileLockTest, LockTest) { // Tests basic functionality and verifies that the lock file is deleted after // use. TEST_F(FirefoxProfileLockTest, ProfileLock) { - FilePath test_path = temp_dir_.path(); - FilePath lock_file_path = test_path.Append(FirefoxProfileLock::kLockFileName); + base::FilePath test_path = temp_dir_.path(); + base::FilePath lock_file_path = + test_path.Append(FirefoxProfileLock::kLockFileName); scoped_ptr<FirefoxProfileLock> lock; EXPECT_EQ(static_cast<FirefoxProfileLock*>(NULL), lock.get()); @@ -65,8 +66,9 @@ TEST_F(FirefoxProfileLockTest, ProfileLock) { // If for some reason the lock file is left behind by the previous owner, we // should still be able to lock it, at least in the Windows implementation. TEST_F(FirefoxProfileLockTest, ProfileLockOrphaned) { - FilePath test_path = temp_dir_.path(); - FilePath lock_file_path = test_path.Append(FirefoxProfileLock::kLockFileName); + base::FilePath test_path = temp_dir_.path(); + base::FilePath lock_file_path = + test_path.Append(FirefoxProfileLock::kLockFileName); // Create the orphaned lock file. FILE* lock_file = file_util::OpenFile(lock_file_path, "w"); @@ -87,7 +89,7 @@ TEST_F(FirefoxProfileLockTest, ProfileLockOrphaned) { #if !defined(OS_POSIX) // Tests two locks contending for the same lock file. TEST_F(FirefoxProfileLockTest, ProfileLockContention) { - FilePath test_path = temp_dir_.path(); + base::FilePath test_path = temp_dir_.path(); scoped_ptr<FirefoxProfileLock> lock1; EXPECT_EQ(static_cast<FirefoxProfileLock*>(NULL), lock1.get()); diff --git a/chrome/browser/importer/firefox_proxy_settings.cc b/chrome/browser/importer/firefox_proxy_settings.cc index f92df2e..427bca84 100644 --- a/chrome/browser/importer/firefox_proxy_settings.cc +++ b/chrome/browser/importer/firefox_proxy_settings.cc @@ -88,10 +88,10 @@ bool FirefoxProxySettings::GetSettings(FirefoxProxySettings* settings) { DCHECK(settings); settings->Reset(); - FilePath profile_path = GetFirefoxProfilePath(); + base::FilePath profile_path = GetFirefoxProfilePath(); if (profile_path.empty()) return false; - FilePath pref_file = profile_path.AppendASCII(kPrefFileName); + base::FilePath pref_file = profile_path.AppendASCII(kPrefFileName); return GetSettingsFromFile(pref_file, settings); } @@ -159,7 +159,7 @@ bool FirefoxProxySettings::ToProxyConfig(net::ProxyConfig* config) { } // static -bool FirefoxProxySettings::GetSettingsFromFile(const FilePath& pref_file, +bool FirefoxProxySettings::GetSettingsFromFile(const base::FilePath& pref_file, FirefoxProxySettings* settings) { DictionaryValue dictionary; if (!ParsePrefFile(pref_file, &dictionary)) diff --git a/chrome/browser/importer/firefox_proxy_settings_unittest.cc b/chrome/browser/importer/firefox_proxy_settings_unittest.cc index 3781741..3912793 100644 --- a/chrome/browser/importer/firefox_proxy_settings_unittest.cc +++ b/chrome/browser/importer/firefox_proxy_settings_unittest.cc @@ -17,7 +17,7 @@ class TestFirefoxProxySettings : public FirefoxProxySettings { public: TestFirefoxProxySettings() {} - static bool TestGetSettingsFromFile(const FilePath& pref_file, + static bool TestGetSettingsFromFile(const base::FilePath& pref_file, FirefoxProxySettings* settings) { return GetSettingsFromFile(pref_file, settings); } @@ -26,7 +26,7 @@ class TestFirefoxProxySettings : public FirefoxProxySettings { TEST_F(FirefoxProxySettingsTest, TestParse) { FirefoxProxySettings settings; - FilePath js_pref_path; + base::FilePath js_pref_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &js_pref_path)); js_pref_path = js_pref_path.AppendASCII("firefox3_pref.js"); @@ -68,7 +68,7 @@ TEST_F(FirefoxProxySettingsTest, TestParse) { TEST_F(FirefoxProxySettingsTest, TestParseAutoConfigUrl) { FirefoxProxySettings settings; - FilePath js_pref_path; + base::FilePath js_pref_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &js_pref_path)); js_pref_path = js_pref_path.AppendASCII("firefox3_pref_pac_url.js"); diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index 481b1228..b1d606b 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -120,21 +120,21 @@ struct IEOrderBookmarkComparator { bool operator()(const ProfileWriter::BookmarkEntry& lhs, const ProfileWriter::BookmarkEntry& rhs) const { static const uint32 kNotSorted = 0xfffffffb; // IE uses this magic value. - FilePath lhs_prefix; - FilePath rhs_prefix; + base::FilePath lhs_prefix; + base::FilePath rhs_prefix; for (size_t i = 0; i <= lhs.path.size() && i <= rhs.path.size(); ++i) { - const FilePath::StringType lhs_i = + const base::FilePath::StringType lhs_i = (i < lhs.path.size() ? lhs.path[i] : lhs.title + L".url"); - const FilePath::StringType rhs_i = + const base::FilePath::StringType rhs_i = (i < rhs.path.size() ? rhs.path[i] : rhs.title + L".url"); lhs_prefix = lhs_prefix.Append(lhs_i); rhs_prefix = rhs_prefix.Append(rhs_i); if (lhs_i == rhs_i) continue; // The first path element that differs between the two. - std::map<FilePath, uint32>::const_iterator lhs_iter = + std::map<base::FilePath, uint32>::const_iterator lhs_iter = sort_index_->find(lhs_prefix); - std::map<FilePath, uint32>::const_iterator rhs_iter = + std::map<base::FilePath, uint32>::const_iterator rhs_iter = sort_index_->find(rhs_prefix); uint32 lhs_sort_index = (lhs_iter == sort_index_->end() ? kNotSorted : lhs_iter->second); @@ -147,7 +147,7 @@ struct IEOrderBookmarkComparator { } return lhs.path.size() < rhs.path.size(); } - const std::map<FilePath, uint32>* sort_index_; + const std::map<base::FilePath, uint32>* sort_index_; }; // IE stores the order of the Favorites menu in registry under: @@ -169,8 +169,8 @@ struct IEOrderBookmarkComparator { bool ParseFavoritesOrderBlob( const Importer* importer, const std::vector<uint8>& blob, - const FilePath& path, - std::map<FilePath, uint32>* sort_index) WARN_UNUSED_RESULT { + const base::FilePath& path, + std::map<base::FilePath, uint32>* sort_index) WARN_UNUSED_RESULT { static const int kItemCountOffset = 16; static const int kItemListStartOffset = 20; @@ -204,8 +204,8 @@ bool ParseFavoritesOrderBlob( TCHAR item_filename[MAX_PATH]; if (!idlist || FAILED(SHGetPathFromIDList(idlist, item_filename))) return false; - FilePath item_relative_path = - path.Append(FilePath(item_filename).BaseName()); + base::FilePath item_relative_path = + path.Append(base::FilePath(item_filename).BaseName()); // Record the retrieved information and go to the next item. sort_index->insert(std::make_pair(item_relative_path, item_sort_index)); @@ -217,8 +217,8 @@ bool ParseFavoritesOrderBlob( bool ParseFavoritesOrderRegistryTree( const Importer* importer, const base::win::RegKey& key, - const FilePath& path, - std::map<FilePath, uint32>* sort_index) WARN_UNUSED_RESULT { + const base::FilePath& path, + std::map<base::FilePath, uint32>* sort_index) WARN_UNUSED_RESULT { // Parse the order information of the current folder. DWORD blob_length = 0; if (key.ReadValue(L"Order", NULL, &blob_length, NULL) == ERROR_SUCCESS) { @@ -237,7 +237,7 @@ bool ParseFavoritesOrderRegistryTree( ++child) { base::win::RegKey subkey(key.Handle(), child.Name(), KEY_READ); if (subkey.Valid()) { - FilePath subpath(path.Append(child.Name())); + base::FilePath subpath(path.Append(child.Name())); if (!ParseFavoritesOrderRegistryTree(importer, subkey, subpath, sort_index)) { return false; @@ -249,11 +249,12 @@ bool ParseFavoritesOrderRegistryTree( bool ParseFavoritesOrderInfo( const Importer* importer, - std::map<FilePath, uint32>* sort_index) WARN_UNUSED_RESULT { + std::map<base::FilePath, uint32>* sort_index) WARN_UNUSED_RESULT { base::win::RegKey key(HKEY_CURRENT_USER, kIEFavoritesOrderKey, KEY_READ); if (!key.Valid()) return false; - return ParseFavoritesOrderRegistryTree(importer, key, FilePath(), sort_index); + return ParseFavoritesOrderRegistryTree(importer, key, base::FilePath(), + sort_index); } // Reads the sort order from registry. If failed, we don't touch the list @@ -261,7 +262,7 @@ bool ParseFavoritesOrderInfo( void SortBookmarksInIEOrder( const Importer* importer, std::vector<ProfileWriter::BookmarkEntry>* bookmarks) { - std::map<FilePath, uint32> sort_index; + std::map<base::FilePath, uint32> sort_index; if (!ParseFavoritesOrderInfo(importer, &sort_index)) return; IEOrderBookmarkComparator compare = {&sort_index}; @@ -327,7 +328,8 @@ GURL ReadFaviconURLFromInternetShortcut(IUniformResourceLocator* url_locator) { // IE7 and above store the data. bool ReadFaviconDataFromInternetShortcut(const string16& file, std::string* data) { - return file_util::ReadFileToString(FilePath(file + kFaviconStreamName), data); + return file_util::ReadFileToString( + base::FilePath(file + kFaviconStreamName), data); } // Reads the favicon imaga data in the Internet cache. IE6 doesn't hold the data @@ -347,7 +349,8 @@ bool ReadFaviconDataFromCache(const GURL& favicon_url, std::string* data) { NULL, NULL, 0)) { return false; } - return file_util::ReadFileToString(FilePath(cache->lpszLocalFileName), data); + return file_util::ReadFileToString(base::FilePath(cache->lpszLocalFileName), + data); } // Reads the binary image data of favicon of an internet shortcut file |file|. @@ -774,7 +777,7 @@ bool IEImporter::GetFavoritesInfo(IEImporter::FavoritesInfo* info) { if (FAILED(SHGetFolderPath(NULL, CSIDL_FAVORITES, NULL, SHGFP_TYPE_CURRENT, buffer))) return false; - info->path = FilePath(buffer); + info->path = base::FilePath(buffer); // There is a Links folder under Favorites folder in Windows Vista, but it // is not recording in Vista's registry. So in Vista, we assume the Links @@ -799,9 +802,9 @@ void IEImporter::ParseFavoritesFolder( const FavoritesInfo& info, BookmarkVector* bookmarks, std::vector<history::ImportedFaviconUsage>* favicons) { - FilePath file; - std::vector<FilePath::StringType> file_list; - FilePath favorites_path(info.path); + base::FilePath file; + std::vector<base::FilePath::StringType> file_list; + base::FilePath favorites_path(info.path); // Favorites path length. Make sure it doesn't include the trailing \. size_t favorites_path_len = favorites_path.StripTrailingSeparators().value().size(); @@ -818,9 +821,9 @@ void IEImporter::ParseFavoritesFolder( typedef std::map<GURL, history::ImportedFaviconUsage> FaviconMap; FaviconMap favicon_map; - for (std::vector<FilePath::StringType>::iterator it = file_list.begin(); + for (std::vector<base::FilePath::StringType>::iterator it = file_list.begin(); it != file_list.end(); ++it) { - FilePath shortcut(*it); + base::FilePath shortcut(*it); if (!LowerCaseEqualsASCII(shortcut.Extension(), ".url")) continue; @@ -845,11 +848,12 @@ void IEImporter::ParseFavoritesFolder( // ex. Suppose that the Favorites folder is C:\Users\Foo\Favorites. // C:\Users\Foo\Favorites\Foo.url -> "" // C:\Users\Foo\Favorites\Links\Bar\Baz.url -> "Links\Bar" - FilePath::StringType relative_string = + base::FilePath::StringType relative_string = shortcut.DirName().value().substr(favorites_path_len); - if (!relative_string.empty() && FilePath::IsSeparator(relative_string[0])) + if (!relative_string.empty() && + base::FilePath::IsSeparator(relative_string[0])) relative_string = relative_string.substr(1); - FilePath relative_path(relative_string); + base::FilePath relative_path(relative_string); ProfileWriter::BookmarkEntry entry; // Remove the dot, the file extension, and the directory path. diff --git a/chrome/browser/importer/ie_importer.h b/chrome/browser/importer/ie_importer.h index 59790d3..f072d5a 100644 --- a/chrome/browser/importer/ie_importer.h +++ b/chrome/browser/importer/ie_importer.h @@ -29,7 +29,7 @@ class IEImporter : public Importer { // A struct that hosts the information of IE Favorite folder. struct FavoritesInfo { - FilePath path; + base::FilePath path; string16 links_folder; }; @@ -77,7 +77,7 @@ class IEImporter : public Importer { // IE does not have source path. It's used in unit tests only for providing a // fake source. - FilePath source_path_; + base::FilePath source_path_; DISALLOW_COPY_AND_ASSIGN(IEImporter); }; diff --git a/chrome/browser/importer/ie_importer_unittest_win.cc b/chrome/browser/importer/ie_importer_unittest_win.cc index e815102..7dd282f 100644 --- a/chrome/browser/importer/ie_importer_unittest_win.cc +++ b/chrome/browser/importer/ie_importer_unittest_win.cc @@ -118,7 +118,7 @@ const FaviconGroup kIEFaviconGroup[2] = { L"http://chinese-title-favorite/"}}, }; -bool CreateOrderBlob(const FilePath& favorites_folder, +bool CreateOrderBlob(const base::FilePath& favorites_folder, const string16& path, const std::vector<string16>& entries) { if (entries.size() > 255) @@ -163,7 +163,7 @@ bool CreateOrderBlob(const FilePath& favorites_folder, return true; } -bool CreateUrlFileWithFavicon(const FilePath& file, +bool CreateUrlFileWithFavicon(const base::FilePath& file, const std::wstring& url, const std::wstring& favicon_url) { base::win::ScopedComPtr<IUniformResourceLocator> locator; @@ -212,7 +212,7 @@ bool CreateUrlFileWithFavicon(const FilePath& file, sizeof kDummyFaviconImageData) != -1); } -bool CreateUrlFile(const FilePath& file, const std::wstring& url) { +bool CreateUrlFile(const base::FilePath& file, const std::wstring& url) { return CreateUrlFileWithFavicon(file, url, std::wstring()); } @@ -443,10 +443,10 @@ class IEImporterTest : public ImporterTest { TEST_F(IEImporterTest, IEImporter) { // Sets up a favorites folder. base::win::ScopedCOMInitializer com_init; - FilePath path = temp_dir_.path().AppendASCII("Favorites"); + base::FilePath path = temp_dir_.path().AppendASCII("Favorites"); CreateDirectory(path.value().c_str(), NULL); CreateDirectory(path.AppendASCII("SubFolder").value().c_str(), NULL); - FilePath links_path = path.AppendASCII("Links"); + base::FilePath links_path = path.AppendASCII("Links"); CreateDirectory(links_path.value().c_str(), NULL); CreateDirectory(links_path.AppendASCII("SubFolderOfLinks").value().c_str(), NULL); @@ -488,7 +488,7 @@ TEST_F(IEImporterTest, IEImporter) { L"SubFolder.url", }; ASSERT_TRUE(CreateOrderBlob( - FilePath(path), L"", + base::FilePath(path), L"", std::vector<string16>(root_links, root_links + arraysize(root_links)))); HRESULT res; @@ -532,7 +532,7 @@ TEST_F(IEImporterTest, IEImporter) { TEST_F(IEImporterTest, IEImporterMalformedFavoritesRegistry) { // Sets up a favorites folder. base::win::ScopedCOMInitializer com_init; - FilePath path = temp_dir_.path().AppendASCII("Favorites"); + base::FilePath path = temp_dir_.path().AppendASCII("Favorites"); CreateDirectory(path.value().c_str(), NULL); CreateDirectory(path.AppendASCII("b").value().c_str(), NULL); ASSERT_TRUE(CreateUrlFile(path.AppendASCII("a.url"), diff --git a/chrome/browser/importer/importer_data_types.h b/chrome/browser/importer/importer_data_types.h index e8fbfde..996d2be 100644 --- a/chrome/browser/importer/importer_data_types.h +++ b/chrome/browser/importer/importer_data_types.h @@ -36,8 +36,8 @@ struct SourceProfile { string16 importer_name; ImporterType importer_type; - FilePath source_path; - FilePath app_path; + base::FilePath source_path; + base::FilePath app_path; uint16 services_supported; // Bitmask of ImportItem. // The URLRequestContextGetter is only used for Google Toolbar. scoped_refptr<net::URLRequestContextGetter> request_context_getter; diff --git a/chrome/browser/importer/importer_list.cc b/chrome/browser/importer/importer_list.cc index 53b9249..2e29b67 100644 --- a/chrome/browser/importer/importer_list.cc +++ b/chrome/browser/importer/importer_list.cc @@ -56,13 +56,13 @@ void DetectSafariProfiles(std::vector<importer::SourceProfile*>* profiles) { #endif // defined(OS_MACOSX) void DetectFirefoxProfiles(std::vector<importer::SourceProfile*>* profiles) { - FilePath profile_path = GetFirefoxProfilePath(); + base::FilePath profile_path = GetFirefoxProfilePath(); if (profile_path.empty()) return; // Detects which version of Firefox is installed. importer::ImporterType firefox_type; - FilePath app_path; + base::FilePath app_path; int version = 0; #if defined(OS_WIN) version = GetCurrentFirefoxMajorVersionFromRegistry(); diff --git a/chrome/browser/importer/mork_reader.cc b/chrome/browser/importer/mork_reader.cc index ccfa98e..0181468 100644 --- a/chrome/browser/importer/mork_reader.cc +++ b/chrome/browser/importer/mork_reader.cc @@ -113,7 +113,7 @@ MorkReader::~MorkReader() { delete i->second; } -bool MorkReader::Read(const FilePath& path) { +bool MorkReader::Read(const base::FilePath& path) { stream_.open(path.value().c_str()); if (!stream_.is_open()) return false; @@ -545,7 +545,8 @@ void AddToHistory(MorkReader::ColumnDataList* column_values, // It sets up the file stream and loops over the lines in the file to // parse them, then adds the resulting row set to history. -void ImportHistoryFromFirefox2(const FilePath& file, ImporterBridge* bridge) { +void ImportHistoryFromFirefox2(const base::FilePath& file, + ImporterBridge* bridge) { MorkReader reader; reader.Read(file); diff --git a/chrome/browser/importer/nss_decryptor_mac.mm b/chrome/browser/importer/nss_decryptor_mac.mm index d9d3d7a..ebcd271 100644 --- a/chrome/browser/importer/nss_decryptor_mac.mm +++ b/chrome/browser/importer/nss_decryptor_mac.mm @@ -19,12 +19,13 @@ // fallback path needs to be set to the directory containing the libraries. // To do so, the process this function runs in must have the // DYLD_FALLBACK_LIBRARY_PATH set on startup to said directory. -bool NSSDecryptor::Init(const FilePath& dll_path, const FilePath& db_path) { +bool NSSDecryptor::Init(const base::FilePath& dll_path, + const base::FilePath& db_path) { if (getenv("DYLD_FALLBACK_LIBRARY_PATH") == NULL) { LOG(ERROR) << "DYLD_FALLBACK_LIBRARY_PATH variable not set"; return false; } - FilePath nss3_path = dll_path.Append("libnss3.dylib"); + base::FilePath nss3_path = dll_path.Append("libnss3.dylib"); void* nss_3_lib = dlopen(nss3_path.value().c_str(), RTLD_LAZY); if (!nss_3_lib) { diff --git a/chrome/browser/importer/nss_decryptor_system_nss.cc b/chrome/browser/importer/nss_decryptor_system_nss.cc index 078f83e..10a4c62 100644 --- a/chrome/browser/importer/nss_decryptor_system_nss.cc +++ b/chrome/browser/importer/nss_decryptor_system_nss.cc @@ -24,7 +24,8 @@ NSSDecryptor::~NSSDecryptor() { } } -bool NSSDecryptor::Init(const FilePath& dll_path, const FilePath& db_path) { +bool NSSDecryptor::Init(const base::FilePath& dll_path, + const base::FilePath& db_path) { crypto::EnsureNSSInit(); is_nss_initialized_ = true; const std::string modspec = diff --git a/chrome/browser/importer/nss_decryptor_win.cc b/chrome/browser/importer/nss_decryptor_win.cc index bb1b2d4..a6fe5453e 100644 --- a/chrome/browser/importer/nss_decryptor_win.cc +++ b/chrome/browser/importer/nss_decryptor_win.cc @@ -37,7 +37,8 @@ const wchar_t NSSDecryptor::kSoftokn3Library[] = L"softokn3.dll"; const wchar_t NSSDecryptor::kPLDS4Library[] = L"plds4.dll"; const wchar_t NSSDecryptor::kNSPR4Library[] = L"nspr4.dll"; -bool NSSDecryptor::Init(const FilePath& dll_path, const FilePath& db_path) { +bool NSSDecryptor::Init(const base::FilePath& dll_path, + const base::FilePath& db_path) { // We call SetDllDirectory to work around a Purify bug (GetModuleHandle // fails inside Purify under certain conditions). SetDllDirectory only // exists on Windows XP SP1 or later, so we look up its address at run time. @@ -59,7 +60,7 @@ bool NSSDecryptor::Init(const FilePath& dll_path, const FilePath& db_path) { // Fall back on LoadLibraryEx if SetDllDirectory isn't available. We // actually prefer this method because it doesn't change the DLL search // path, which is a process-wide property. - FilePath path = dll_path.Append(kNSS3Library); + base::FilePath path = dll_path.Append(kNSS3Library); nss3_dll_ = LoadLibraryEx(path.value().c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); if (nss3_dll_ == NULL) @@ -75,7 +76,7 @@ bool NSSDecryptor::Init(const FilePath& dll_path, const FilePath& db_path) { // LOAD_WITH_ALTERED_SEARCH_PATH flag. This helps because LoadLibrary // doesn't load a DLL again if it's already loaded. This workaround is // harmless for NSS 3.11. - path = FilePath(dll_path).Append(kSoftokn3Library); + path = base::FilePath(dll_path).Append(kSoftokn3Library); softokn3_dll_ = LoadLibraryEx(path.value().c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); if (softokn3_dll_ == NULL) { @@ -102,7 +103,7 @@ NSSDecryptor::~NSSDecryptor() { Free(); } -bool NSSDecryptor::InitNSS(const FilePath& db_path, +bool NSSDecryptor::InitNSS(const base::FilePath& db_path, base::NativeLibrary plds4_dll, base::NativeLibrary nspr4_dll) { // NSPR DLLs are already loaded now. diff --git a/chrome/browser/importer/safari_importer.h b/chrome/browser/importer/safari_importer.h index a5dbba4..bf01630 100644 --- a/chrome/browser/importer/safari_importer.h +++ b/chrome/browser/importer/safari_importer.h @@ -40,7 +40,7 @@ class SafariImporter : public Importer { public: // |library_dir| is the full path to the ~/Library directory, // We pass it in as a parameter for testing purposes. - explicit SafariImporter(const FilePath& library_dir); + explicit SafariImporter(const base::FilePath& library_dir); // Importer: virtual void StartImport(const importer::SourceProfile& source_profile, @@ -52,7 +52,8 @@ class SafariImporter : public Importer { // in: library_dir - ~/Library or a standin for testing purposes. // out: services_supported - the service supported for import. // Returns true if we can import the Safari profile. - static bool CanImport(const FilePath& library_dir, uint16* services_supported); + static bool CanImport(const base::FilePath& library_dir, + uint16* services_supported); private: FRIEND_TEST_ALL_PREFIXES(SafariImporterTest, BookmarkImport); @@ -104,7 +105,7 @@ class SafariImporter : public Importer { const FaviconMap& favicon_map, std::vector<history::ImportedFaviconUsage>* favicons); - FilePath library_dir_; + base::FilePath library_dir_; DISALLOW_COPY_AND_ASSIGN(SafariImporter); }; diff --git a/chrome/browser/importer/safari_importer.mm b/chrome/browser/importer/safari_importer.mm index 921ebc4..6b8809a 100644 --- a/chrome/browser/importer/safari_importer.mm +++ b/chrome/browser/importer/safari_importer.mm @@ -41,7 +41,7 @@ bool CanImportSafariURL(const GURL& url) { } // namespace -SafariImporter::SafariImporter(const FilePath& library_dir) +SafariImporter::SafariImporter(const base::FilePath& library_dir) : library_dir_(library_dir) { } @@ -49,7 +49,7 @@ SafariImporter::~SafariImporter() { } // static -bool SafariImporter::CanImport(const FilePath& library_dir, +bool SafariImporter::CanImport(const base::FilePath& library_dir, uint16* services_supported) { DCHECK(services_supported); *services_supported = importer::NONE; @@ -57,9 +57,9 @@ bool SafariImporter::CanImport(const FilePath& library_dir, // Import features are toggled by the following: // bookmarks import: existence of ~/Library/Safari/Bookmarks.plist file. // history import: existence of ~/Library/Safari/History.plist file. - FilePath safari_dir = library_dir.Append("Safari"); - FilePath bookmarks_path = safari_dir.Append("Bookmarks.plist"); - FilePath history_path = safari_dir.Append("History.plist"); + base::FilePath safari_dir = library_dir.Append("Safari"); + base::FilePath bookmarks_path = safari_dir.Append("Bookmarks.plist"); + base::FilePath history_path = safari_dir.Append("History.plist"); if (file_util::PathExists(bookmarks_path)) *services_supported |= importer::FAVORITES; @@ -135,7 +135,7 @@ bool SafariImporter::OpenDatabase(sql::Connection* db) { stringByAppendingPathComponent:@"WebpageIcons.db"]; const char* db_path = [favicons_db_path fileSystemRepresentation]; - return db->Open(FilePath(db_path)); + return db->Open(base::FilePath(db_path)); } void SafariImporter::ImportFaviconURLs(sql::Connection* db, diff --git a/chrome/browser/importer/safari_importer_unittest.mm b/chrome/browser/importer/safari_importer_unittest.mm index ff29c6d..ca9e700 100644 --- a/chrome/browser/importer/safari_importer_unittest.mm +++ b/chrome/browser/importer/safari_importer_unittest.mm @@ -23,19 +23,19 @@ // simulated Library directory containing dummy data files in the same // structure as ~/Library in the Chrome test data directory. // This function returns the path to that directory. -FilePath GetTestSafariLibraryPath() { - FilePath test_dir; - PathService::Get(chrome::DIR_TEST_DATA, &test_dir); +base::FilePath GetTestSafariLibraryPath() { + base::FilePath test_dir; + PathService::Get(chrome::DIR_TEST_DATA, &test_dir); - // Our simulated ~/Library directory - test_dir = test_dir.AppendASCII("safari_import"); - return test_dir; + // Our simulated ~/Library directory + test_dir = test_dir.AppendASCII("safari_import"); + return test_dir; } class SafariImporterTest : public PlatformTest { public: SafariImporter* GetSafariImporter() { - FilePath test_library_dir = GetTestSafariLibraryPath(); + base::FilePath test_library_dir = GetTestSafariLibraryPath(); CHECK(file_util::PathExists(test_library_dir)) << "Missing test data directory"; |