diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-29 21:12:11 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-29 21:12:11 +0000 |
commit | 839575632d4a75a63c7b803f81dbdf83683546e1 (patch) | |
tree | b1523c997da62a4bf8419695a807077c57b0cf08 /chrome/browser/importer | |
parent | 1e463e1ebb3e81fbdaf6add1c64f4ad0ff68f67f (diff) | |
download | chromium_src-839575632d4a75a63c7b803f81dbdf83683546e1.zip chromium_src-839575632d4a75a63c7b803f81dbdf83683546e1.tar.gz chromium_src-839575632d4a75a63c7b803f81dbdf83683546e1.tar.bz2 |
First cut at Firefox import on OSX + stubs for Safari import.
Known limitations:
* Runs in browser process, should run in a separate process.
* No UI.
* No FF password import.
BUG=15455
TEST=Check that firefox settings are correctly imported on first run, firefox password importing and Safari importing still don't work.
Review URL: http://codereview.chromium.org/160341
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21995 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/importer')
-rw-r--r-- | chrome/browser/importer/firefox_importer_unittest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/importer/firefox_importer_utils_mac.cc | 23 | ||||
-rw-r--r-- | chrome/browser/importer/firefox_importer_utils_mac.mm | 31 | ||||
-rw-r--r-- | chrome/browser/importer/importer.cc | 23 | ||||
-rw-r--r-- | chrome/browser/importer/importer.h | 6 | ||||
-rw-r--r-- | chrome/browser/importer/nss_decryptor_mac.h | 13 | ||||
-rw-r--r-- | chrome/browser/importer/nss_decryptor_mac.mm | 23 |
7 files changed, 93 insertions, 29 deletions
diff --git a/chrome/browser/importer/firefox_importer_unittest.cc b/chrome/browser/importer/firefox_importer_unittest.cc index 4766a9d..1c0af23 100644 --- a/chrome/browser/importer/firefox_importer_unittest.cc +++ b/chrome/browser/importer/firefox_importer_unittest.cc @@ -14,6 +14,8 @@ using base::Time; +// TODO(jeremy): Port NSSDecryptor to OSX and enable these tests. +#if !defined(OS_MACOSX) TEST(FirefoxImporterTest, Firefox2NSS3Decryptor) { std::wstring nss_path; ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &nss_path)); @@ -45,6 +47,7 @@ TEST(FirefoxImporterTest, Firefox3NSS3Decryptor) { EXPECT_EQ(L"\x4E2D", decryptor.Decrypt("MDIEEPgAAAAAAAAAAAAAAAAAAAE" "wFAYIKoZIhvcNAwcECLWqqiccfQHWBAie74hxnULxlw==")); } +#endif // !OS_MACOSX TEST(FirefoxImporterTest, Firefox2BookmarkParse) { bool result; diff --git a/chrome/browser/importer/firefox_importer_utils_mac.cc b/chrome/browser/importer/firefox_importer_utils_mac.cc deleted file mode 100644 index 26a4f4b..0000000 --- a/chrome/browser/importer/firefox_importer_utils_mac.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2009 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. - -#include "chrome/browser/importer/firefox_importer_utils.h" - -#include "base/file_util.h" - -FilePath GetProfilesINI() { - FilePath ini_file; - // ~/Library/Application Support/Firefox on OS X. - // This should be changed to NSSearchPathForDirectoriesInDomains(). - // See bug http://code.google.com/p/chromium/issues/detail?id=15455 - const char *home = getenv("HOME"); - if (home && home[0]) { - ini_file = FilePath(home).Append( - "Library/Application Support/Firefox/profiles.ini"); - } - if (file_util::PathExists(ini_file)) - return ini_file; - - return FilePath(); -} diff --git a/chrome/browser/importer/firefox_importer_utils_mac.mm b/chrome/browser/importer/firefox_importer_utils_mac.mm new file mode 100644 index 0000000..5fd24b0 --- /dev/null +++ b/chrome/browser/importer/firefox_importer_utils_mac.mm @@ -0,0 +1,31 @@ +// Copyright (c) 2009 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. + +#include <Cocoa/Cocoa.h> + +#include "chrome/browser/importer/firefox_importer_utils.h" + +#include "base/file_util.h" + +FilePath GetProfilesINI() { + FilePath ini_file; + NSArray* dirs = + NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, + NSUserDomainMask, YES); + if ([dirs count]) { + NSString* app_support_dir = [dirs objectAtIndex:0]; + NSString* firefox_dir = [app_support_dir + stringByAppendingPathComponent:@"Firefox"]; + NSString* profiles_ini = [firefox_dir + stringByAppendingPathComponent:@"profiles.ini"]; + if (profiles_ini) { + ini_file = FilePath([profiles_ini fileSystemRepresentation]); + } + } + + if (file_util::PathExists(ini_file)) + return ini_file; + + return FilePath(); +} diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc index f311540..df32899 100644 --- a/chrome/browser/importer/importer.cc +++ b/chrome/browser/importer/importer.cc @@ -650,6 +650,12 @@ Importer* ImporterHost::CreateImporterByType(ProfileType type) { return new Firefox3Importer(); case GOOGLE_TOOLBAR5: return new Toolbar5Importer(); +#if defined(OS_MACOSX) + case SAFARI: + // TODO(jeremy): Implement. + NOTIMPLEMENTED(); + return NULL; +#endif // OS_MACOSX } NOTREACHED(); return NULL; @@ -694,6 +700,9 @@ void ImporterHost::DetectSourceProfiles() { // TODO(brg) : Current UI requires win_util. DetectGoogleToolbarProfiles(); #else +#if defined(OS_MACOSX) + DetectSafariProfiles(); +#endif DetectFirefoxProfiles(); #endif } @@ -807,3 +816,17 @@ void ImporterHost::DetectGoogleToolbarProfiles() { source_profiles_.push_back(google_toolbar); } } + +#if defined(OS_MACOSX) +void ImporterHost::DetectSafariProfiles() { + // TODO(jeremy):Check that Safari folder is in fact present. + ProfileInfo* safari = new ProfileInfo(); + safari->browser_type = SAFARI; + safari->description = l10n_util::GetString(IDS_IMPORT_FROM_SAFARI); + safari->source_path.clear(); + safari->app_path.clear(); + safari->services_supported = HISTORY | FAVORITES | COOKIES | PASSWORDS | + SEARCH_ENGINES; + source_profiles_.push_back(safari); +} +#endif // OS_MACOSX diff --git a/chrome/browser/importer/importer.h b/chrome/browser/importer/importer.h index 839725a..78b2114 100644 --- a/chrome/browser/importer/importer.h +++ b/chrome/browser/importer/importer.h @@ -36,6 +36,9 @@ enum ProfileType { #endif FIREFOX2, FIREFOX3, +#if defined(OS_MACOSX) + SAFARI, +#endif GOOGLE_TOOLBAR5, // Identifies a 'bookmarks.html' file. BOOKMARKS_HTML @@ -292,6 +295,9 @@ class ImporterHost : public base::RefCounted<ImporterHost>, #endif void DetectFirefoxProfiles(); void DetectGoogleToolbarProfiles(); +#if defined(OS_MACOSX) + void DetectSafariProfiles(); +#endif NotificationRegistrar registrar_; diff --git a/chrome/browser/importer/nss_decryptor_mac.h b/chrome/browser/importer/nss_decryptor_mac.h index b540fe9..46933cc 100644 --- a/chrome/browser/importer/nss_decryptor_mac.h +++ b/chrome/browser/importer/nss_decryptor_mac.h @@ -119,12 +119,7 @@ class NSSDecryptor { // Initializes NSS if it hasn't already been initialized. bool Init(const std::wstring& /* dll_path */, - const std::wstring& /* db_path */) { - // TODO(port): Load the NSS libraries and call InitNSS() - // http://code.google.com/p/chromium/issues/detail?id=15455 - NOTIMPLEMENTED(); - return false; - } + const std::wstring& /* db_path */); // Decrypts Firefox stored passwords. Before using this method, // make sure Init() returns true. @@ -152,6 +147,12 @@ class NSSDecryptor { PLArenaFinishFunc PL_ArenaFinish; PRCleanupFunc PR_Cleanup; + // Libraries necessary for decrypting the passwords. + static const wchar_t kNSS3Library[]; + static const wchar_t kSoftokn3Library[]; + static const wchar_t kPLDS4Library[]; + static const wchar_t kNSPR4Library[]; + // True if NSS_Init() has been called bool is_nss_initialized_; diff --git a/chrome/browser/importer/nss_decryptor_mac.mm b/chrome/browser/importer/nss_decryptor_mac.mm new file mode 100644 index 0000000..97e85b6 --- /dev/null +++ b/chrome/browser/importer/nss_decryptor_mac.mm @@ -0,0 +1,23 @@ +// Copyright (c) 2009 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. + +#include <Cocoa/Cocoa.h> + +#include "chrome/browser/importer/nss_decryptor_mac.h" + +#include "base/logging.h" + +// static +const wchar_t NSSDecryptor::kNSS3Library[] = L"libnss3.dylib"; +const wchar_t NSSDecryptor::kSoftokn3Library[] = L"libsoftokn3.dylib"; +const wchar_t NSSDecryptor::kPLDS4Library[] = L"libplds4.dylib"; +const wchar_t NSSDecryptor::kNSPR4Library[] = L"libnspr4.dylib"; + +bool NSSDecryptor::Init(const std::wstring& dll_path, + const std::wstring& db_path) { + // TODO(port): Load the NSS libraries and call InitNSS() + // http://code.google.com/p/chromium/issues/detail?id=15455 + NOTIMPLEMENTED(); + return false; +} |