summaryrefslogtreecommitdiffstats
path: root/chrome
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
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')
-rw-r--r--chrome/browser/gtk/import_dialog_gtk.cc40
-rw-r--r--chrome/browser/gtk/import_dialog_gtk.h15
-rw-r--r--chrome/browser/gtk/import_lock_dialog_gtk.cc53
-rw-r--r--chrome/browser/gtk/import_lock_dialog_gtk.h38
-rw-r--r--chrome/browser/gtk/import_progress_dialog_gtk.cc202
-rw-r--r--chrome/browser/gtk/import_progress_dialog_gtk.h81
-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
-rw-r--r--chrome/chrome.gyp4
12 files changed, 456 insertions, 60 deletions
diff --git a/chrome/browser/gtk/import_dialog_gtk.cc b/chrome/browser/gtk/import_dialog_gtk.cc
index 15f9438..43c2df1 100644
--- a/chrome/browser/gtk/import_dialog_gtk.cc
+++ b/chrome/browser/gtk/import_dialog_gtk.cc
@@ -6,7 +6,6 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
-#include "chrome/browser/profile.h"
#include "grit/generated_resources.h"
// static
@@ -14,10 +13,21 @@ void ImportDialogGtk::Show(GtkWindow* parent, Profile* profile) {
new ImportDialogGtk(parent, profile);
}
+////////////////////////////////////////////////////////////////////////////////
+// ImportObserver implementation:
+void ImportDialogGtk::ImportCanceled() {
+ ImportComplete();
+}
+
+void ImportDialogGtk::ImportComplete() {
+ gtk_widget_destroy(dialog_);
+ delete this;
+}
+
ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile) :
- profile_(profile), importer_host_(new ImporterHost()) {
+ parent_(parent), profile_(profile), importer_host_(new ImporterHost()) {
// Build the dialog.
- GtkWidget* dialog = gtk_dialog_new_with_buttons(
+ dialog_ = gtk_dialog_new_with_buttons(
l10n_util::GetStringUTF8(IDS_IMPORT_SETTINGS_TITLE).c_str(),
parent,
(GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
@@ -29,9 +39,9 @@ ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile) :
// TODO(rahulk): find how to set size properly so that the dialog
// box width is at least enough to display full title.
- gtk_widget_set_size_request(dialog, 300, -1);
+ gtk_widget_set_size_request(dialog_, 300, -1);
- GtkWidget* content_area = GTK_DIALOG(dialog)->vbox;
+ GtkWidget* content_area = GTK_DIALOG(dialog_)->vbox;
gtk_box_set_spacing(GTK_BOX(content_area), 18);
GtkWidget* combo_hbox = gtk_hbox_new(FALSE, 12);
@@ -75,13 +85,14 @@ ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile) :
gtk_box_pack_start(GTK_BOX(vbox), history_, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(content_area), vbox, FALSE, FALSE, 0);
- g_signal_connect(dialog, "response",
+ g_signal_connect(dialog_, "response",
G_CALLBACK(HandleOnResponseDialog), this);
- gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
- gtk_widget_show_all(dialog);
+ gtk_window_set_resizable(GTK_WINDOW(dialog_), FALSE);
+ gtk_widget_show_all(dialog_);
}
void ImportDialogGtk::OnDialogResponse(GtkWidget* widget, int response) {
+ gtk_widget_hide_all(dialog_);
if (response == GTK_RESPONSE_ACCEPT) {
uint16 items = NONE;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(bookmarks_)))
@@ -95,14 +106,9 @@ void ImportDialogGtk::OnDialogResponse(GtkWidget* widget, int response) {
const ProfileInfo& source_profile = importer_host_->GetSourceProfileInfoAt(
gtk_combo_box_get_active(GTK_COMBO_BOX(combo_)));
-
- // TODO(rahulk): We should not do the import on this thread. Instead
- // we need to start this asynchronously and launch a UI that shows the
- // progress of import.
- importer_host_->StartImportSettings(source_profile, profile_, items,
- new ProfileWriter(profile_), false);
+ StartImportingWithUI(parent_, items, importer_host_.get(),
+ source_profile, profile_, this, false);
+ } else {
+ ImportCanceled();
}
-
- delete this;
- gtk_widget_destroy(GTK_WIDGET(widget));
}
diff --git a/chrome/browser/gtk/import_dialog_gtk.h b/chrome/browser/gtk/import_dialog_gtk.h
index 351aed6..f3d4f03 100644
--- a/chrome/browser/gtk/import_dialog_gtk.h
+++ b/chrome/browser/gtk/import_dialog_gtk.h
@@ -7,14 +7,17 @@
#include "chrome/browser/importer/importer.h"
-class Profile;
-typedef struct _GtkWindow GtkWindow;
+#include "chrome/browser/profile.h"
-class ImportDialogGtk {
+class ImportDialogGtk : public ImportObserver {
public:
// Displays the import box to import data from another browser into |profile|
static void Show(GtkWindow* parent, Profile* profile);
+ // Overridden from ImportObserver:
+ virtual void ImportCanceled();
+ virtual void ImportComplete();
+
private:
ImportDialogGtk(GtkWindow* parent, Profile* profile);
~ImportDialogGtk() { }
@@ -26,6 +29,12 @@ class ImportDialogGtk {
}
void OnDialogResponse(GtkWidget* widget, int response);
+ // Parent window
+ GtkWindow* parent_;
+
+ // Import Dialog
+ GtkWidget* dialog_;
+
// Combo box that displays list of profiles from which we can import.
GtkWidget* combo_;
diff --git a/chrome/browser/gtk/import_lock_dialog_gtk.cc b/chrome/browser/gtk/import_lock_dialog_gtk.cc
new file mode 100644
index 0000000..179df9f
--- /dev/null
+++ b/chrome/browser/gtk/import_lock_dialog_gtk.cc
@@ -0,0 +1,53 @@
+// 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/gtk/import_lock_dialog_gtk.h"
+
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
+#include "grit/generated_resources.h"
+#include "grit/chromium_strings.h"
+
+// static
+void ImportLockDialogGtk::Show(GtkWindow* parent, ImporterHost* importer_host) {
+ new ImportLockDialogGtk(parent, importer_host);
+}
+
+ImportLockDialogGtk::ImportLockDialogGtk(GtkWindow* parent,
+ ImporterHost* importer_host) : importer_host_(importer_host) {
+ // Build the dialog.
+ dialog_ = gtk_dialog_new_with_buttons(
+ l10n_util::GetStringUTF8(IDS_IMPORTER_LOCK_TITLE).c_str(),
+ parent,
+ (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
+ GTK_STOCK_OK,
+ GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_REJECT,
+ NULL);
+
+ GtkWidget* content_area = GTK_DIALOG(dialog_)->vbox;
+ gtk_box_set_spacing(GTK_BOX(content_area), 18);
+ GtkWidget* label = gtk_label_new(
+ l10n_util::GetStringUTF8(IDS_IMPORTER_LOCK_TEXT).c_str());
+ gtk_label_set_single_line_mode(GTK_LABEL(label), FALSE);
+ gtk_box_pack_start(GTK_BOX(content_area), label, FALSE, FALSE, 0);
+
+ g_signal_connect(dialog_, "response",
+ G_CALLBACK(HandleOnResponseDialog), this);
+ gtk_window_set_resizable(GTK_WINDOW(dialog_), FALSE);
+ gtk_widget_show_all(dialog_);
+}
+
+void ImportLockDialogGtk::OnDialogResponse(GtkWidget* widget, int response) {
+ if (response == GTK_RESPONSE_ACCEPT) {
+ MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
+ importer_host_.get(), &ImporterHost::OnLockViewEnd, true));
+ } else {
+ MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
+ importer_host_.get(), &ImporterHost::OnLockViewEnd, false));
+ }
+ gtk_widget_destroy(dialog_);
+ delete this;
+}
diff --git a/chrome/browser/gtk/import_lock_dialog_gtk.h b/chrome/browser/gtk/import_lock_dialog_gtk.h
new file mode 100644
index 0000000..99087d3
--- /dev/null
+++ b/chrome/browser/gtk/import_lock_dialog_gtk.h
@@ -0,0 +1,38 @@
+// 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.
+
+#ifndef CHROME_BROWSER_GTK_IMPORT_LOCK_DIALOG_GTK_H_
+#define CHROME_BROWSER_GTK_IMPORT_LOCK_DIALOG_GTK_H_
+
+#include "chrome/browser/importer/importer.h"
+
+#include <gtk/gtk.h>
+
+class ImportLockDialogGtk {
+ public:
+ // Displays the Firefox profile locked warning
+ static void Show(GtkWindow* parent, ImporterHost* importer_host);
+
+ private:
+ ImportLockDialogGtk(GtkWindow* parent, ImporterHost* importer_host);
+ ~ImportLockDialogGtk() { }
+
+ static void HandleOnResponseDialog(GtkWidget* widget,
+ int response,
+ gpointer user_data) {
+ reinterpret_cast<ImportLockDialogGtk*>(user_data)->OnDialogResponse(
+ widget, response);
+ }
+ void OnDialogResponse(GtkWidget* widget, int response);
+
+ // Dialog box
+ GtkWidget* dialog_;
+
+ // Utility class that does the actual import.
+ scoped_refptr<ImporterHost> importer_host_;
+
+ DISALLOW_COPY_AND_ASSIGN(ImportLockDialogGtk);
+};
+
+#endif // CHROME_BROWSER_GTK_IMPORT_LOCK_DIALOG_GTK_H_
diff --git a/chrome/browser/gtk/import_progress_dialog_gtk.cc b/chrome/browser/gtk/import_progress_dialog_gtk.cc
new file mode 100644
index 0000000..1dc828e
--- /dev/null
+++ b/chrome/browser/gtk/import_progress_dialog_gtk.cc
@@ -0,0 +1,202 @@
+// 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/gtk/import_progress_dialog_gtk.h"
+
+#include "app/l10n_util.h"
+#include "app/resource_bundle.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+
+namespace {
+void SetItemImportStatus(GtkWidget* chkbox, int res_id, bool is_done) {
+ std::string status = l10n_util::GetStringUTF8(res_id);
+ // Windows version of this has fancy throbbers to indicate progress. Here
+ // we rely on text until we can have something equivalent on Linux.
+ if (is_done)
+ status.append(" done.");
+ else
+ status.append(" importing...");
+ gtk_button_set_label(GTK_BUTTON(chkbox), status.c_str());
+}
+} // namespace
+
+// static
+void ImportProgressDialogGtk::StartImport(GtkWindow* parent,
+ int16 items,
+ ImporterHost* importer_host,
+ const ProfileInfo& browser_profile,
+ Profile* profile,
+ ImportObserver* observer,
+ bool first_run) {
+ ImportProgressDialogGtk* v = new ImportProgressDialogGtk(
+ WideToUTF16(browser_profile.description), items, importer_host, observer,
+ parent, browser_profile.browser_type == BOOKMARKS_HTML);
+
+ // In headless mode it means that we don't show the progress window, but it
+ // still need it to exist. No user interaction will be required.
+ if (!importer_host->is_headless())
+ v->ShowDialog();
+
+ importer_host->StartImportSettings(browser_profile, profile, items,
+ new ProfileWriter(profile),
+ first_run);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// ImporterHost::Observer implementation:
+void ImportProgressDialogGtk::ImportItemStarted(ImportItem item) {
+ DCHECK(items_ & item);
+ switch (item) {
+ case FAVORITES:
+ SetItemImportStatus(bookmarks_,
+ IDS_IMPORT_PROGRESS_STATUS_BOOKMARKS, false);
+ break;
+ case SEARCH_ENGINES:
+ SetItemImportStatus(search_engines_,
+ IDS_IMPORT_PROGRESS_STATUS_SEARCH, false);
+ break;
+ case PASSWORDS:
+ SetItemImportStatus(passwords_,
+ IDS_IMPORT_PROGRESS_STATUS_PASSWORDS, false);
+ break;
+ case HISTORY:
+ SetItemImportStatus(history_,
+ IDS_IMPORT_PROGRESS_STATUS_HISTORY, false);
+ break;
+ default:
+ break;
+ }
+}
+
+void ImportProgressDialogGtk::ImportItemEnded(ImportItem item) {
+ DCHECK(items_ & item);
+ switch (item) {
+ case FAVORITES:
+ SetItemImportStatus(bookmarks_,
+ IDS_IMPORT_PROGRESS_STATUS_BOOKMARKS, true);
+ break;
+ case SEARCH_ENGINES:
+ SetItemImportStatus(search_engines_,
+ IDS_IMPORT_PROGRESS_STATUS_SEARCH, true);
+ break;
+ case PASSWORDS:
+ SetItemImportStatus(passwords_,
+ IDS_IMPORT_PROGRESS_STATUS_PASSWORDS, true);
+ break;
+ case HISTORY:
+ SetItemImportStatus(history_,
+ IDS_IMPORT_PROGRESS_STATUS_HISTORY, true);
+ break;
+ default:
+ break;
+ }
+}
+
+void ImportProgressDialogGtk::ImportStarted() {
+ importing_ = true;
+}
+
+void ImportProgressDialogGtk::ImportEnded() {
+ importing_ = false;
+ importer_host_->SetObserver(NULL);
+ if (observer_)
+ observer_->ImportComplete();
+ CloseDialog();
+}
+
+ImportProgressDialogGtk::ImportProgressDialogGtk(const string16& source_profile,
+ int16 items, ImporterHost* importer_host, ImportObserver* observer,
+ GtkWindow* parent, bool bookmarks_import) :
+ parent_(parent), importing_(true), observer_(observer),
+ items_(items), importer_host_(importer_host) {
+ importer_host_->SetObserver(this);
+
+ // Build the dialog.
+ dialog_ = gtk_dialog_new_with_buttons(
+ l10n_util::GetStringUTF8(IDS_IMPORT_PROGRESS_TITLE).c_str(),
+ parent_,
+ (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_REJECT,
+ NULL);
+
+ GtkWidget* content_area = GTK_DIALOG(dialog_)->vbox;
+ gtk_box_set_spacing(GTK_BOX(content_area), 18);
+
+ GtkWidget* import_info = gtk_label_new(
+ l10n_util::GetStringFUTF8(IDS_IMPORT_PROGRESS_INFO,
+ source_profile).c_str());
+ gtk_label_set_single_line_mode(GTK_LABEL(import_info), FALSE);
+ gtk_box_pack_start(GTK_BOX(content_area), import_info, FALSE, FALSE, 0);
+
+ bookmarks_ = gtk_check_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_IMPORT_PROGRESS_STATUS_BOOKMARKS).c_str());
+ gtk_box_pack_start(GTK_BOX(content_area), bookmarks_, FALSE, FALSE, 0);
+ gtk_widget_set_sensitive(bookmarks_, FALSE);
+ if (items_ & FAVORITES)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bookmarks_), TRUE);
+
+ search_engines_ = gtk_check_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_IMPORT_PROGRESS_STATUS_SEARCH).c_str());
+ gtk_box_pack_start(GTK_BOX(content_area), search_engines_, FALSE, FALSE, 0);
+ gtk_widget_set_sensitive(search_engines_, FALSE);
+ if (items_ & SEARCH_ENGINES)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(search_engines_), TRUE);
+
+ passwords_ = gtk_check_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_IMPORT_PROGRESS_STATUS_PASSWORDS).c_str());
+ gtk_box_pack_start(GTK_BOX(content_area), passwords_, FALSE, FALSE, 0);
+ gtk_widget_set_sensitive(passwords_, FALSE);
+ if (items_ & PASSWORDS)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(passwords_), TRUE);
+
+ history_ = gtk_check_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_IMPORT_PROGRESS_STATUS_HISTORY).c_str());
+ gtk_box_pack_start(GTK_BOX(content_area), history_, FALSE, FALSE, 0);
+ gtk_widget_set_sensitive(history_, FALSE);
+ if (items_ & HISTORY)
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(history_), TRUE);
+
+ g_signal_connect(dialog_, "response",
+ G_CALLBACK(HandleOnResponseDialog), this);
+ gtk_window_set_resizable(GTK_WINDOW(dialog_), FALSE);
+}
+
+void ImportProgressDialogGtk::CloseDialog() {
+ gtk_widget_destroy(dialog_);
+ dialog_ = NULL;
+ delete this;
+}
+
+void ImportProgressDialogGtk::OnDialogResponse(GtkWidget* widget,
+ int response) {
+ if (!importing_) {
+ CloseDialog();
+ return;
+ }
+
+ // Only response to the dialog is to close it so we hide immediately.
+ gtk_widget_hide_all(dialog_);
+ if (response == GTK_RESPONSE_REJECT)
+ importer_host_->Cancel();
+}
+
+void ImportProgressDialogGtk::ShowDialog() {
+ gtk_widget_show_all(dialog_);
+}
+
+
+void StartImportingWithUI(GtkWindow* parent,
+ int16 items,
+ ImporterHost* importer_host,
+ const ProfileInfo& browser_profile,
+ Profile* profile,
+ ImportObserver* observer,
+ bool first_run) {
+ DCHECK(items != 0);
+ ImportProgressDialogGtk::StartImport(parent, items, importer_host,
+ browser_profile, profile, observer,
+ first_run);
+}
diff --git a/chrome/browser/gtk/import_progress_dialog_gtk.h b/chrome/browser/gtk/import_progress_dialog_gtk.h
new file mode 100644
index 0000000..bc8d6c9
--- /dev/null
+++ b/chrome/browser/gtk/import_progress_dialog_gtk.h
@@ -0,0 +1,81 @@
+// 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.
+
+#ifndef CHROME_BROWSER_GTK_IMPORT_PROGRESS_DIALOG_GTK_H_
+#define CHROME_BROWSER_GTK_IMPORT_PROGRESS_DIALOG_GTK_H_
+
+#include "chrome/browser/importer/importer.h"
+
+#include <gtk/gtk.h>
+
+#include "chrome/browser/profile.h"
+
+class ImportProgressDialogGtk : public ImporterHost::Observer {
+ public:
+ // Displays the import progress dialog box and starts the import
+ static void StartImport(GtkWindow* parent, int16 items,
+ ImporterHost* importer_host,
+ const ProfileInfo& browser_profile,
+ Profile* profile,
+ ImportObserver* observer, bool first_run);
+
+ // Overridden from ImporterHost::Observer:
+ virtual void ImportItemStarted(ImportItem item);
+ virtual void ImportItemEnded(ImportItem item);
+ virtual void ImportStarted();
+ virtual void ImportEnded();
+
+ private:
+ ImportProgressDialogGtk(const string16& source_profile, int16 items,
+ ImporterHost* importer_host, ImportObserver* observer,
+ GtkWindow* parent, bool bookmarks_import);
+ ~ImportProgressDialogGtk() { }
+
+ static void HandleOnResponseDialog(GtkWidget* widget,
+ int response,
+ gpointer user_data) {
+ reinterpret_cast<ImportProgressDialogGtk*>(user_data)->OnDialogResponse(
+ widget, response);
+ }
+
+ void CloseDialog();
+
+ void OnDialogResponse(GtkWidget* widget, int response);
+
+ void ShowDialog();
+
+ // Parent window
+ GtkWindow* parent_;
+
+ // Import progress dialog
+ GtkWidget* dialog_;
+
+ // Bookmarks/Favorites checkbox
+ GtkWidget* bookmarks_;
+
+ // Search Engines checkbox
+ GtkWidget* search_engines_;
+
+ // Passwords checkbox
+ GtkWidget* passwords_;
+
+ // History checkbox
+ GtkWidget* history_;
+
+ // Boolean that tells whether we are currently in the mid of import process
+ bool importing_;
+
+ // Observer that we need to notify about import events
+ ImportObserver* observer_;
+
+ // Items to import from the other browser.
+ int16 items_;
+
+ // Utility class that does the actual import.
+ scoped_refptr<ImporterHost> importer_host_;
+
+ DISALLOW_COPY_AND_ASSIGN(ImportProgressDialogGtk);
+};
+
+#endif // CHROME_BROWSER_GTK_IMPORT_PROGRESS_DIALOG_GTK_H_
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,
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 6bb8a83..68ec37e 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -910,6 +910,10 @@
'browser/gtk/hung_renderer_dialog_gtk.cc',
'browser/gtk/import_dialog_gtk.cc',
'browser/gtk/import_dialog_gtk.h',
+ 'browser/gtk/import_lock_dialog_gtk.cc',
+ 'browser/gtk/import_lock_dialog_gtk.h',
+ 'browser/gtk/import_progress_dialog_gtk.cc',
+ 'browser/gtk/import_progress_dialog_gtk.h',
'browser/gtk/info_bubble_gtk.cc',
'browser/gtk/info_bubble_gtk.h',
'browser/gtk/infobar_container_gtk.cc',