diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-15 14:31:14 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-15 14:31:14 +0000 |
commit | ca0a0caf5b257c4c57dfe30db8e73390ff56df81 (patch) | |
tree | d8349a2a1e3163d1ef5124cd52abd69aa3277c32 /chrome/browser | |
parent | fa2ec14e389ee931a4af09ced0224fe29c0823d9 (diff) | |
download | chromium_src-ca0a0caf5b257c4c57dfe30db8e73390ff56df81.zip chromium_src-ca0a0caf5b257c4c57dfe30db8e73390ff56df81.tar.gz chromium_src-ca0a0caf5b257c4c57dfe30db8e73390ff56df81.tar.bz2 |
Use FilePath in ProfileInfo struct.
BUG=24672
TEST=out/Debug/unit_tests
Review URL: http://codereview.chromium.org/1741012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47370 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/extensions/extension_bookmarks_module.cc | 2 | ||||
-rw-r--r-- | chrome/browser/first_run.cc | 2 | ||||
-rw-r--r-- | chrome/browser/importer/firefox2_importer.cc | 4 | ||||
-rw-r--r-- | chrome/browser/importer/firefox3_importer.cc | 4 | ||||
-rw-r--r-- | chrome/browser/importer/firefox_profile_lock.cc | 6 | ||||
-rw-r--r-- | chrome/browser/importer/firefox_profile_lock.h | 4 | ||||
-rw-r--r-- | chrome/browser/importer/firefox_profile_lock_unittest.cc | 12 | ||||
-rw-r--r-- | chrome/browser/importer/ie_importer.cc | 4 | ||||
-rw-r--r-- | chrome/browser/importer/importer_data_types.h | 23 | ||||
-rw-r--r-- | chrome/browser/importer/importer_list.cc | 7 | ||||
-rw-r--r-- | chrome/browser/importer/importer_unittest.cc | 60 |
11 files changed, 65 insertions, 63 deletions
diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc index 629ae76..8361b82 100644 --- a/chrome/browser/extensions/extension_bookmarks_module.cc +++ b/chrome/browser/extensions/extension_bookmarks_module.cc @@ -828,7 +828,7 @@ void ImportBookmarksFunction::FileSelected(const FilePath& path, ImporterHost* host = new ImporterHost(); importer::ProfileInfo profile_info; profile_info.browser_type = importer::BOOKMARKS_HTML; - profile_info.source_path = path.ToWStringHack(); + profile_info.source_path = path; host->StartImportSettings(profile_info, profile(), importer::FAVORITES, diff --git a/chrome/browser/first_run.cc b/chrome/browser/first_run.cc index 88e31a3..f4952eb 100644 --- a/chrome/browser/first_run.cc +++ b/chrome/browser/first_run.cc @@ -127,7 +127,7 @@ bool FirstRun::SetMinimalFirstRunBubblePref() { } int FirstRun::ImportFromFile(Profile* profile, const CommandLine& cmdline) { - std::wstring file_path = cmdline.GetSwitchValue(switches::kImportFromFile); + FilePath file_path = cmdline.GetSwitchValuePath(switches::kImportFromFile); if (file_path.empty()) { NOTREACHED(); return false; diff --git a/chrome/browser/importer/firefox2_importer.cc b/chrome/browser/importer/firefox2_importer.cc index 11d8109..655638c 100644 --- a/chrome/browser/importer/firefox2_importer.cc +++ b/chrome/browser/importer/firefox2_importer.cc @@ -51,8 +51,8 @@ void Firefox2Importer::StartImport(ProfileInfo profile_info, uint16 items, ImporterBridge* bridge) { bridge_ = bridge; - source_path_ = FilePath::FromWStringHack(profile_info.source_path); - app_path_ = FilePath::FromWStringHack(profile_info.app_path); + source_path_ = profile_info.source_path; + app_path_ = profile_info.app_path; parsing_bookmarks_html_file_ = (profile_info.browser_type == BOOKMARKS_HTML); diff --git a/chrome/browser/importer/firefox3_importer.cc b/chrome/browser/importer/firefox3_importer.cc index a71f995..6010f45 100644 --- a/chrome/browser/importer/firefox3_importer.cc +++ b/chrome/browser/importer/firefox3_importer.cc @@ -37,8 +37,8 @@ void Firefox3Importer::StartImport(ProfileInfo profile_info, uint16 items, ImporterBridge* bridge) { bridge_ = bridge; - source_path_ = FilePath::FromWStringHack(profile_info.source_path); - app_path_ = FilePath::FromWStringHack(profile_info.app_path); + source_path_ = profile_info.source_path; + app_path_ = profile_info.app_path; // The order here is important! diff --git a/chrome/browser/importer/firefox_profile_lock.cc b/chrome/browser/importer/firefox_profile_lock.cc index ca6935c..fff771d 100644 --- a/chrome/browser/importer/firefox_profile_lock.cc +++ b/chrome/browser/importer/firefox_profile_lock.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -68,9 +68,9 @@ const FilePath::CharType* FirefoxProfileLock::kLockFileName = FILE_PATH_LITERAL("parent.lock"); #endif -FirefoxProfileLock::FirefoxProfileLock(const std::wstring& path) { +FirefoxProfileLock::FirefoxProfileLock(const FilePath& path) { Init(); - lock_file_ = FilePath::FromWStringHack(path).Append(kLockFileName); + 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 d04fc35..8c828ec7 100644 --- a/chrome/browser/importer/firefox_profile_lock.h +++ b/chrome/browser/importer/firefox_profile_lock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -69,7 +69,7 @@ class FirefoxProfileLock { public: - explicit FirefoxProfileLock(const std::wstring& path); + explicit FirefoxProfileLock(const FilePath& path); ~FirefoxProfileLock(); // Locks and releases the profile. diff --git a/chrome/browser/importer/firefox_profile_lock_unittest.cc b/chrome/browser/importer/firefox_profile_lock_unittest.cc index 1d86ff5..09214b7 100644 --- a/chrome/browser/importer/firefox_profile_lock_unittest.cc +++ b/chrome/browser/importer/firefox_profile_lock_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -34,7 +34,7 @@ class FirefoxProfileLockTest : public testing::Test { }; TEST_F(FirefoxProfileLockTest, LockTest) { - FirefoxProfileLock lock1(test_path_.ToWStringHack()); + FirefoxProfileLock lock1(test_path_); ASSERT_TRUE(lock1.HasAcquired()); lock1.Unlock(); ASSERT_FALSE(lock1.HasAcquired()); @@ -55,7 +55,7 @@ TEST_F(FirefoxProfileLockTest, ProfileLock) { scoped_ptr<FirefoxProfileLock> lock; EXPECT_EQ(static_cast<FirefoxProfileLock*>(NULL), lock.get()); EXPECT_FALSE(file_util::PathExists(lock_file_path)); - lock.reset(new FirefoxProfileLock(test_path.ToWStringHack())); + lock.reset(new FirefoxProfileLock(test_path)); EXPECT_TRUE(lock->HasAcquired()); EXPECT_TRUE(file_util::PathExists(lock_file_path)); lock->Unlock(); @@ -96,7 +96,7 @@ TEST_F(FirefoxProfileLockTest, ProfileLockOrphaned) { scoped_ptr<FirefoxProfileLock> lock; EXPECT_EQ(static_cast<FirefoxProfileLock*>(NULL), lock.get()); - lock.reset(new FirefoxProfileLock(test_path.ToWStringHack())); + lock.reset(new FirefoxProfileLock(test_path)); EXPECT_TRUE(lock->HasAcquired()); lock->Unlock(); EXPECT_FALSE(lock->HasAcquired()); @@ -114,12 +114,12 @@ TEST_F(FirefoxProfileLockTest, ProfileLockContention) { scoped_ptr<FirefoxProfileLock> lock1; EXPECT_EQ(static_cast<FirefoxProfileLock*>(NULL), lock1.get()); - lock1.reset(new FirefoxProfileLock(test_path.ToWStringHack())); + lock1.reset(new FirefoxProfileLock(test_path)); EXPECT_TRUE(lock1->HasAcquired()); scoped_ptr<FirefoxProfileLock> lock2; EXPECT_EQ(static_cast<FirefoxProfileLock*>(NULL), lock2.get()); - lock2.reset(new FirefoxProfileLock(test_path.ToWStringHack())); + lock2.reset(new FirefoxProfileLock(test_path)); EXPECT_FALSE(lock2->HasAcquired()); lock1->Unlock(); diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index d171d58..cae26ba 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -68,7 +68,7 @@ void IEImporter::StartImport(ProfileInfo profile_info, uint16 items, ImporterBridge* bridge) { bridge_ = bridge; - source_path_ = profile_info.source_path; + source_path_ = profile_info.source_path.ToWStringHack(); bridge_->NotifyStarted(); diff --git a/chrome/browser/importer/importer_data_types.h b/chrome/browser/importer/importer_data_types.h index 52da02c..444cc45 100644 --- a/chrome/browser/importer/importer_data_types.h +++ b/chrome/browser/importer/importer_data_types.h @@ -8,6 +8,7 @@ #include <string> #include "base/basictypes.h" +#include "base/file_path.h" // Types needed for importing data from other browsers and the Google // Toolbar. @@ -15,14 +16,14 @@ namespace importer { // An enumeration of the type of data that can be imported. enum ImportItem { - NONE = 0x0000, - HISTORY = 0x0001, - FAVORITES = 0x0002, - COOKIES = 0x0004, // Not supported yet. - PASSWORDS = 0x0008, - SEARCH_ENGINES = 0x0010, - HOME_PAGE = 0x0020, - ALL = 0x003f + NONE = 0, + HISTORY = 1 << 0, + FAVORITES = 1 << 1, + COOKIES = 1 << 2, // Not supported yet. + PASSWORDS = 1 << 3, + SEARCH_ENGINES = 1 << 4, + HOME_PAGE = 1 << 5, + ALL = (1 << 6) - 1 // All the bits should be 1, hence the -1. }; // An enumeration of the type of browsers that we support to import @@ -46,9 +47,9 @@ enum ProfileType { struct ProfileInfo { std::wstring description; importer::ProfileType browser_type; - std::wstring source_path; - std::wstring app_path; - uint16 services_supported; // Bitmap of ImportItem + FilePath source_path; + FilePath app_path; + uint16 services_supported; // Bitmask of ImportItem. }; } // namespace importer diff --git a/chrome/browser/importer/importer_list.cc b/chrome/browser/importer/importer_list.cc index f9ddaea..2fdd559 100644 --- a/chrome/browser/importer/importer_list.cc +++ b/chrome/browser/importer/importer_list.cc @@ -145,12 +145,13 @@ void ImporterList::DetectFirefoxProfiles() { importer::ProfileInfo* firefox = new importer::ProfileInfo(); firefox->description = l10n_util::GetString(IDS_IMPORT_FROM_FIREFOX); firefox->browser_type = firefox_type; - firefox->source_path = profile_path.ToWStringHack(); + firefox->source_path = profile_path; #if defined(OS_WIN) - firefox->app_path = GetFirefoxInstallPathFromRegistry(); + firefox->app_path = FilePath::FromWStringHack( + GetFirefoxInstallPathFromRegistry()); #endif if (firefox->app_path.empty()) - firefox->app_path = app_path.ToWStringHack(); + firefox->app_path = app_path; firefox->services_supported = importer::HISTORY | importer::FAVORITES | importer::COOKIES | importer::PASSWORDS | importer::SEARCH_ENGINES; source_profiles_.push_back(firefox); diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc index edc3620..eac9bed 100644 --- a/chrome/browser/importer/importer_unittest.cc +++ b/chrome/browser/importer/importer_unittest.cc @@ -50,42 +50,42 @@ class ImporterTest : public testing::Test { virtual void SetUp() { // Creates a new profile in a new subdirectory in the temp directory. ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_path_)); - file_util::AppendToPath(&test_path_, L"ImporterTest"); + test_path_ = test_path_.AppendASCII("ImporterTest"); file_util::Delete(test_path_, true); - CreateDirectory(test_path_.c_str(), NULL); + file_util::CreateDirectory(test_path_); profile_path_ = test_path_; - file_util::AppendToPath(&profile_path_, L"profile"); - CreateDirectory(profile_path_.c_str(), NULL); + profile_path_ = profile_path_.AppendASCII("profile"); + file_util::CreateDirectory(profile_path_); app_path_ = test_path_; - file_util::AppendToPath(&app_path_, L"app"); - CreateDirectory(app_path_.c_str(), NULL); + app_path_ = app_path_.AppendASCII("app"); + file_util::CreateDirectory(app_path_); } virtual void TearDown() { // Deletes the profile and cleans up the profile directory. ASSERT_TRUE(file_util::Delete(test_path_, true)); - ASSERT_FALSE(file_util::PathExists(FilePath::FromWStringHack(test_path_))); + ASSERT_FALSE(file_util::PathExists(test_path_)); } - void Firefox3xImporterTest(std::wstring profile_dir, + void Firefox3xImporterTest(std::string profile_dir, ImporterHost::Observer* observer, ProfileWriter* writer, bool import_search_plugins) { - std::wstring data_path; + FilePath data_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); - file_util::AppendToPath(&data_path, profile_dir + L"\\*"); + data_path = data_path.AppendASCII(profile_dir).AppendASCII("*"); ASSERT_TRUE(file_util::CopyDirectory(data_path, profile_path_, true)); ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); - file_util::AppendToPath(&data_path, L"firefox3_nss"); + data_path = data_path.AppendASCII("firefox3_nss"); ASSERT_TRUE(file_util::CopyDirectory(data_path, profile_path_, false)); - std::wstring search_engine_path = app_path_; - file_util::AppendToPath(&search_engine_path, L"searchplugins"); - CreateDirectory(search_engine_path.c_str(), NULL); + FilePath search_engine_path = app_path_; + search_engine_path = search_engine_path.AppendASCII("searchplugins"); + file_util::CreateDirectory(search_engine_path); if (import_search_plugins) { ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); - file_util::AppendToPath(&data_path, L"firefox3_searchplugins"); - if (!file_util::PathExists(FilePath::FromWStringHack(data_path))) { + data_path = data_path.AppendASCII("firefox3_searchplugins"); + if (!file_util::PathExists(data_path)) { // TODO(maruel): Create search test data that we can open source! LOG(ERROR) << L"Missing internal test data"; return; @@ -113,9 +113,9 @@ class ImporterTest : public testing::Test { MessageLoopForUI message_loop_; ChromeThread ui_thread_; ChromeThread file_thread_; - std::wstring test_path_; - std::wstring profile_path_; - std::wstring app_path_; + FilePath test_path_; + FilePath profile_path_; + FilePath app_path_; }; const int kMaxPathSize = 5; @@ -338,7 +338,7 @@ void WritePStore(IPStore* pstore, const GUID* type, const GUID* subtype) { TEST_F(ImporterTest, IEImporter) { // Sets up a favorites folder. win_util::ScopedCOMInitializer com_init; - std::wstring path = test_path_; + std::wstring path = test_path_.ToWStringHack(); file_util::AppendToPath(&path, L"Favorites"); CreateDirectory(path.c_str(), NULL); CreateDirectory((path + L"\\SubFolder").c_str(), NULL); @@ -654,20 +654,20 @@ class FirefoxObserver : public ProfileWriter, }; TEST_F(ImporterTest, Firefox2Importer) { - std::wstring data_path; + FilePath data_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); - file_util::AppendToPath(&data_path, L"firefox2_profile\\*"); + data_path = data_path.AppendASCII("firefox2_profile").AppendASCII("*"); ASSERT_TRUE(file_util::CopyDirectory(data_path, profile_path_, true)); ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); - file_util::AppendToPath(&data_path, L"firefox2_nss"); + data_path = data_path.AppendASCII("firefox2_nss"); ASSERT_TRUE(file_util::CopyDirectory(data_path, profile_path_, false)); - std::wstring search_engine_path = app_path_; - file_util::AppendToPath(&search_engine_path, L"searchplugins"); - CreateDirectory(search_engine_path.c_str(), NULL); + 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)); - file_util::AppendToPath(&data_path, L"firefox2_searchplugins"); - if (!file_util::PathExists(FilePath::FromWStringHack(data_path))) { + data_path = data_path.AppendASCII("firefox2_searchplugins"); + if (!file_util::PathExists(data_path)) { // TODO(maruel): Create test data that we can open source! LOG(ERROR) << L"Missing internal test data"; return; @@ -859,7 +859,7 @@ class Firefox3Observer : public ProfileWriter, TEST_F(ImporterTest, Firefox30Importer) { scoped_refptr<Firefox3Observer> observer = new Firefox3Observer(); - Firefox3xImporterTest(L"firefox3_profile", observer.get(), observer.get(), + Firefox3xImporterTest("firefox3_profile", observer.get(), observer.get(), true); } @@ -867,6 +867,6 @@ TEST_F(ImporterTest, Firefox35Importer) { bool import_search_engines = false; scoped_refptr<Firefox3Observer> observer = new Firefox3Observer(import_search_engines); - Firefox3xImporterTest(L"firefox35_profile", observer.get(), observer.get(), + Firefox3xImporterTest("firefox35_profile", observer.get(), observer.get(), import_search_engines); } |