summaryrefslogtreecommitdiffstats
path: root/chrome/browser/importer
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 16:36:10 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-27 16:36:10 +0000
commit6f10a83d4397a71caa64ed0019ba59a0d9e94dd2 (patch)
treec49eafb666273ab744d8c703fdfa8c29e26f7485 /chrome/browser/importer
parent11ca005c425ef920f54b7317a775eb9b7b1bc148 (diff)
downloadchromium_src-6f10a83d4397a71caa64ed0019ba59a0d9e94dd2.zip
chromium_src-6f10a83d4397a71caa64ed0019ba59a0d9e94dd2.tar.gz
chromium_src-6f10a83d4397a71caa64ed0019ba59a0d9e94dd2.tar.bz2
Make the import feature a little more complete:
- Now we show import progress of individual items - In case Firefox is running we display a warning and allow user to close it before proceeding - Delete the Firefox lock when import finishes BUG=11191 Review URL: http://codereview.chromium.org/114047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16986 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/importer')
-rw-r--r--chrome/browser/importer/firefox_importer_utils.cc52
-rw-r--r--chrome/browser/importer/firefox_importer_utils.h12
-rw-r--r--chrome/browser/importer/firefox_profile_lock_posix.cc1
-rw-r--r--chrome/browser/importer/importer.cc14
-rw-r--r--chrome/browser/importer/importer.h4
5 files changed, 43 insertions, 40 deletions
diff --git a/chrome/browser/importer/firefox_importer_utils.cc b/chrome/browser/importer/firefox_importer_utils.cc
index 66e30b0..afe484e 100644
--- a/chrome/browser/importer/firefox_importer_utils.cc
+++ b/chrome/browser/importer/firefox_importer_utils.cc
@@ -83,8 +83,8 @@ class SetDllDirectoryCaller {
} // namespace
-int GetCurrentFirefoxMajorVersion() {
#if defined(OS_WIN)
+int GetCurrentFirefoxMajorVersionFromRegistry() {
TCHAR ver_buffer[128];
DWORD ver_buffer_length = sizeof(ver_buffer);
int highest_version = 0;
@@ -100,13 +100,28 @@ int GetCurrentFirefoxMajorVersion() {
highest_version = std::max(highest_version, _wtoi(ver_buffer));
}
return highest_version;
-#else
- // TODO(port): Read in firefox configuration.
- NOTIMPLEMENTED();
- return 0;
-#endif
}
+std::wstring GetFirefoxInstallPathFromRegistry() {
+ // Detects the path that Firefox is installed in.
+ std::wstring registry_path = L"Software\\Mozilla\\Mozilla Firefox";
+ TCHAR buffer[MAX_PATH];
+ DWORD buffer_length = sizeof(buffer);
+ bool result;
+ result = ReadFromRegistry(HKEY_LOCAL_MACHINE, registry_path.c_str(),
+ L"CurrentVersion", buffer, &buffer_length);
+ if (!result)
+ return std::wstring();
+ registry_path += L"\\" + std::wstring(buffer) + L"\\Main";
+ buffer_length = sizeof(buffer);
+ result = ReadFromRegistry(HKEY_LOCAL_MACHINE, registry_path.c_str(),
+ L"Install Directory", buffer, &buffer_length);
+ if (!result)
+ return std::wstring();
+ return buffer;
+}
+#endif
+
#if defined(OS_WIN) || defined(OS_LINUX)
bool GetFirefoxVersionAndPathFromProfile(const std::wstring& profile_path,
int* version,
@@ -209,31 +224,6 @@ void ParseProfileINI(std::wstring file, DictionaryValue* root) {
}
#endif
-std::wstring GetFirefoxInstallPath() {
-#if defined(OS_WIN)
- // Detects the path that Firefox is installed in.
- std::wstring registry_path = L"Software\\Mozilla\\Mozilla Firefox";
- TCHAR buffer[MAX_PATH];
- DWORD buffer_length = sizeof(buffer);
- bool result;
- result = ReadFromRegistry(HKEY_LOCAL_MACHINE, registry_path.c_str(),
- L"CurrentVersion", buffer, &buffer_length);
- if (!result)
- return std::wstring();
- registry_path += L"\\" + std::wstring(buffer) + L"\\Main";
- buffer_length = sizeof(buffer);
- result = ReadFromRegistry(HKEY_LOCAL_MACHINE, registry_path.c_str(),
- L"Install Directory", buffer, &buffer_length);
- if (!result)
- return std::wstring();
- return buffer;
-#else
- // TODO(port): Load firefox configuration.
- NOTIMPLEMENTED();
- return std::wstring();
-#endif
-}
-
bool CanImportURL(const GURL& url) {
const char* kInvalidSchemes[] = {"wyciwyg", "place", "about", "chrome"};
diff --git a/chrome/browser/importer/firefox_importer_utils.h b/chrome/browser/importer/firefox_importer_utils.h
index 06b6063..7212919 100644
--- a/chrome/browser/importer/firefox_importer_utils.h
+++ b/chrome/browser/importer/firefox_importer_utils.h
@@ -14,11 +14,17 @@
class GURL;
class TemplateURL;
+#if defined(OS_WIN)
// Detects which version of Firefox is installed from registry. Returns its
// major version, and drops the minor version. Returns 0 if
// failed. If there are indicators of both FF2 and FF3 it is
// biased to return the biggest version.
-int GetCurrentFirefoxMajorVersion();
+int GetCurrentFirefoxMajorVersionFromRegistry();
+
+// Detects where Firefox lives. Returns a empty string if Firefox
+// is not installed.
+std::wstring GetFirefoxInstallPathFromRegistry();
+#endif
#if defined(OS_WIN) || defined(OS_LINUX)
// Detects version of Firefox and installation path from given Firefox profile
@@ -46,10 +52,6 @@ FilePath GetProfilesINI();
void ParseProfileINI(std::wstring file, DictionaryValue* root);
#endif
-// Detects where Firefox lives. Returns a empty string if Firefox
-// is not installed.
-std::wstring GetFirefoxInstallPath();
-
// Returns true if we want to add the URL to the history. We filter
// out the URL with a unsupported scheme.
bool CanImportURL(const GURL& url);
diff --git a/chrome/browser/importer/firefox_profile_lock_posix.cc b/chrome/browser/importer/firefox_profile_lock_posix.cc
index da047ab..b32dd54 100644
--- a/chrome/browser/importer/firefox_profile_lock_posix.cc
+++ b/chrome/browser/importer/firefox_profile_lock_posix.cc
@@ -70,6 +70,7 @@ void FirefoxProfileLock::Unlock() {
return;
close(lock_fd_);
lock_fd_ = -1;
+ file_util::Delete(lock_file_, false);
}
bool FirefoxProfileLock::HasAcquired() {
diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc
index 34906d6..01b2aed 100644
--- a/chrome/browser/importer/importer.cc
+++ b/chrome/browser/importer/importer.cc
@@ -43,6 +43,8 @@
#if defined(OS_WIN)
#include "chrome/browser/views/importer_lock_view.h"
#include "views/window/window.h"
+#elif defined(OS_LINUX)
+#include "chrome/browser/gtk/import_lock_dialog_gtk.h"
#endif
// ProfileWriter.
@@ -441,6 +443,8 @@ void ImporterHost::ShowWarningDialog() {
#if defined(OS_WIN)
views::Window::CreateChromeWindow(GetActiveWindow(), gfx::Rect(),
new ImporterLockView(this))->Show();
+#elif defined(OS_LINUX)
+ ImportLockDialogGtk::Show(NULL, this);
#else
// TODO(port): Need CreateChromeWindow.
NOTIMPLEMENTED();
@@ -711,9 +715,13 @@ void ImporterHost::DetectFirefoxProfiles() {
// Detects which version of Firefox is installed.
ProfileType firefox_type;
std::wstring app_path;
- int version = GetCurrentFirefoxMajorVersion();
+ int version = 0;
+#if defined(OS_WIN)
+ version = GetCurrentFirefoxMajorVersionFromRegistry();
+#endif
if (version != 2 && version != 3)
GetFirefoxVersionAndPathFromProfile(source_path, &version, &app_path);
+
if (version == 2) {
firefox_type = FIREFOX2;
} else if (version == 3) {
@@ -728,7 +736,9 @@ void ImporterHost::DetectFirefoxProfiles() {
firefox->description = l10n_util::GetString(IDS_IMPORT_FROM_FIREFOX);
firefox->browser_type = firefox_type;
firefox->source_path = source_path;
- firefox->app_path = GetFirefoxInstallPath();
+#if defined(OS_WIN)
+ firefox->app_path = GetFirefoxInstallPathFromRegistry();
+#endif
if (firefox->app_path.empty())
firefox->app_path = app_path;
firefox->services_supported = HISTORY | FAVORITES | COOKIES | PASSWORDS |
diff --git a/chrome/browser/importer/importer.h b/chrome/browser/importer/importer.h
index 420a733e..b42bc20 100644
--- a/chrome/browser/importer/importer.h
+++ b/chrome/browser/importer/importer.h
@@ -416,7 +416,7 @@ class ImportObserver {
};
-#if defined(OS_WIN)
+#if !defined(OS_MACOSX)
// TODO(port): Make StartImportingWithUI portable.
// Shows a UI for importing and begins importing the specified items from
@@ -424,7 +424,7 @@ class ImportObserver {
// complete, can be NULL. parent is the window to parent the UI to, can be NULL
// if there's nothing to parent to. first_run is true if it's invoked in the
// first run UI.
-void StartImportingWithUI(HWND parent_window,
+void StartImportingWithUI(gfx::NativeWindow parent_window,
int16 items,
ImporterHost* coordinator,
const ProfileInfo& source_profile,