diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/cocoa/first_run_dialog.h | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/first_run_dialog.mm | 6 | ||||
-rw-r--r-- | chrome/browser/first_run_mac.mm | 29 | ||||
-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 |
10 files changed, 128 insertions, 31 deletions
diff --git a/chrome/browser/cocoa/first_run_dialog.h b/chrome/browser/cocoa/first_run_dialog.h index f7f2a11..5e5bd1e 100644 --- a/chrome/browser/cocoa/first_run_dialog.h +++ b/chrome/browser/cocoa/first_run_dialog.h @@ -16,6 +16,7 @@ BOOL make_default_browser_; BOOL import_bookmarks_; int browser_import_selected_index_; + NSArray* browser_import_list_; } // Called when the "Start Google Chrome" button is pressed. @@ -33,6 +34,7 @@ @property(assign) BOOL makeDefaultBrowser; @property(assign) BOOL importBookmarks; @property(assign) int browserImportSelectedIndex; +@property(retain) NSArray* browserImportList; @end diff --git a/chrome/browser/cocoa/first_run_dialog.mm b/chrome/browser/cocoa/first_run_dialog.mm index 7af9bcd..d5c9737 100644 --- a/chrome/browser/cocoa/first_run_dialog.mm +++ b/chrome/browser/cocoa/first_run_dialog.mm @@ -15,6 +15,7 @@ @synthesize makeDefaultBrowser = make_default_browser_; @synthesize importBookmarks = import_bookmarks_; @synthesize browserImportSelectedIndex = browser_import_selected_index_; +@synthesize browserImportList = browser_import_list_; - (id)init { self = [super initWithWindowNibName:@"FirstRunDialog"]; @@ -26,6 +27,11 @@ return self; } +- (void)dealloc { + [browser_import_list_ release]; + [super dealloc]; +} + - (IBAction)showWindow:(id)sender { // Neat weirdness in the below code - the Application menu stays enabled // while the window is open but selecting items from it (e.g. Quit) has diff --git a/chrome/browser/first_run_mac.mm b/chrome/browser/first_run_mac.mm index 2764a31..d839bf4 100644 --- a/chrome/browser/first_run_mac.mm +++ b/chrome/browser/first_run_mac.mm @@ -8,6 +8,7 @@ #include "base/sys_string_conversions.h" #import "chrome/app/breakpad_mac.h" #import "chrome/browser/cocoa/first_run_dialog.h" +#include "chrome/browser/importer/importer.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/shell_integration.h" #include "chrome/installer/util/google_update_constants.h" @@ -46,10 +47,26 @@ bool OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) { scoped_nsobject<FirstRunDialogController> dialog( [[FirstRunDialogController alloc] init]); + scoped_refptr<ImporterHost> importer_host(new ImporterHost()); + + // Set list of browsers we know how to import. + ssize_t profiles_count = importer_host->GetAvailableProfileCount(); + + // TODO(jeremy): Test on newly created account. + // TODO(jeremy): Correctly handle case where no browsers to import from + // are detected. + NSMutableArray *browsers = [NSMutableArray arrayWithCapacity:profiles_count]; + for (int i = 0; i < profiles_count; ++i) { + std::wstring profile = importer_host->GetSourceProfileNameAt(i); + [browsers addObject:base::SysWideToNSString(profile)]; + } + [dialog.get() setBrowserImportList:browsers]; + // FirstRunDialogController will call exit if "Cancel" is clicked. [dialog.get() showWindow:nil]; - // If user clicked cancel, bail. + // If user clicked cancel, bail - browser_main will return if we haven't + // turned off the first run flag when this function returns. if ([dialog.get() userDidCancel]) { return false; } @@ -66,13 +83,21 @@ bool OpenFirstRunDialog(Profile* profile, ProcessSingleton* process_singleton) { GoogleUpdateSettings::SetCollectStatsConsent(stats_enabled); + // If selected set as default browser. BOOL make_default_browser = [dialog.get() makeDefaultBrowser]; if (make_default_browser) { bool success = ShellIntegration::SetAsDefaultBrowser(); DCHECK(success); } - // TODO(jeremy): Import Bookmarks. + // Import bookmarks. + const ProfileInfo& source_profile = importer_host->GetSourceProfileInfoAt( + [dialog.get() browserImportSelectedIndex]); + int items = SEARCH_ENGINES + HISTORY + FAVORITES + HOME_PAGE + PASSWORDS; + // TODO(port): Call StartImportingWithUI here instead and launch + // a new process that does the actual import. + importer_host->StartImportSettings(source_profile, profile, items, + new ProfileWriter(profile), true); #endif // defined(GOOGLE_CHROME_BUILD) return true; 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; +} |