summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-07 22:55:30 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-07 22:55:30 +0000
commit111ca63cacf4cedb65be41fd4cabfa5ad7bb6b86 (patch)
tree19bfebe83f96b4db5b78bb86f989667a11d04554
parente8d82c6124232e1678eb242e5c7369bd20ac949d (diff)
downloadchromium_src-111ca63cacf4cedb65be41fd4cabfa5ad7bb6b86.zip
chromium_src-111ca63cacf4cedb65be41fd4cabfa5ad7bb6b86.tar.gz
chromium_src-111ca63cacf4cedb65be41fd4cabfa5ad7bb6b86.tar.bz2
Importer: Fix ImporterList::DetectSourceProfiles to run on the FILE thread, as
it access the file system. Fix up a few call sites. BUG=60825 TEST=none Review URL: http://codereview.chromium.org/5566003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68533 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd3
-rw-r--r--chrome/browser/automation/testing_automation_provider.cc95
-rw-r--r--chrome/browser/automation/testing_automation_provider.h34
-rw-r--r--chrome/browser/dom_ui/options/import_data_handler.cc82
-rw-r--r--chrome/browser/dom_ui/options/import_data_handler.h11
-rw-r--r--chrome/browser/gtk/import_dialog_gtk.cc59
-rw-r--r--chrome/browser/gtk/import_dialog_gtk.h15
-rw-r--r--chrome/browser/importer/importer.cc30
-rw-r--r--chrome/browser/importer/importer.h67
-rw-r--r--chrome/browser/importer/importer_list.cc248
-rw-r--r--chrome/browser/importer/importer_list.h69
-rw-r--r--chrome/browser/resources/options/import_data_overlay.html4
-rw-r--r--chrome/browser/resources/options/import_data_overlay.js1
-rw-r--r--chrome/browser/ui/cocoa/import_settings_dialog.h2
-rw-r--r--chrome/browser/ui/cocoa/import_settings_dialog.mm8
-rw-r--r--chrome/profile_import/profile_import_thread.cc4
16 files changed, 466 insertions, 266 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 43613e6..79cd054 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -4715,6 +4715,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_IMPORT_SEARCH_ENGINES_CHKBOX" desc="Checkbox for importing search engines">
Search engines
</message>
+ <message name="IDS_IMPORT_LOADING_PROFILES" desc="Status text to notify the user that profiles are being loaded">
+ Loading...
+ </message>
<message name="IDS_IMPORT_COMMIT" desc="Text for OK button on dialog">
Import
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 6b13f28..9098cf6 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -39,6 +39,7 @@
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/history/top_sites.h"
+#include "chrome/browser/importer/importer.h"
#include "chrome/browser/notifications/balloon.h"
#include "chrome/browser/notifications/balloon_collection.h"
#include "chrome/browser/notifications/balloon_host.h"
@@ -242,6 +243,49 @@ TestingAutomationProvider::~TestingAutomationProvider() {
BrowserList::RemoveObserver(this);
}
+void TestingAutomationProvider::SourceProfilesLoaded() {
+ DCHECK_NE(static_cast<ImporterHost*>(NULL), importer_host_.get());
+
+ // Get the correct ProfileInfo based on the browser the user provided.
+ importer::ProfileInfo profile_info;
+ int num_browsers = importer_host_->GetAvailableProfileCount();
+ int i = 0;
+ for ( ; i < num_browsers; i++) {
+ string16 name = WideToUTF16Hack(importer_host_->GetSourceProfileNameAt(i));
+ if (name == import_settings_data_.browser_name) {
+ profile_info = importer_host_->GetSourceProfileInfoAt(i);
+ break;
+ }
+ }
+ // If we made it to the end of the loop, then the input was bad.
+ if (i == num_browsers) {
+ AutomationJSONReply(this, import_settings_data_.reply_message).SendError(
+ "Invalid browser name string found.");
+ return;
+ }
+
+ importer_host_->SetObserver(
+ new AutomationProviderImportSettingsObserver(
+ this, import_settings_data_.reply_message));
+
+ Profile* profile = import_settings_data_.browser->profile();
+ importer_host_->StartImportSettings(profile_info,
+ profile,
+ import_settings_data_.import_items,
+ new ProfileWriter(profile),
+ import_settings_data_.first_run);
+}
+
+void TestingAutomationProvider::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ DCHECK(type == NotificationType::SESSION_END);
+ // OnBrowserRemoved does a ReleaseLater. When session end is received we exit
+ // before the task runs resulting in this object not being deleted. This
+ // Release balance out the Release scheduled by OnBrowserRemoved.
+ Release();
+}
+
void TestingAutomationProvider::OnMessageReceived(
const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(TestingAutomationProvider, message)
@@ -3149,19 +3193,16 @@ void TestingAutomationProvider::ImportSettings(Browser* browser,
string_to_import_item["HOME_PAGE"] = importer::HOME_PAGE;
string_to_import_item["ALL"] = importer::ALL;
- string16 browser_name;
- int import_items = 0;
ListValue* import_items_list = NULL;
- bool first_run;
-
- if (!args->GetString("import_from", &browser_name) ||
- !args->GetBoolean("first_run", &first_run) ||
+ if (!args->GetString("import_from", &import_settings_data_.browser_name) ||
+ !args->GetBoolean("first_run", &import_settings_data_.first_run) ||
!args->GetList("import_items", &import_items_list)) {
AutomationJSONReply(this, reply_message).SendError(
"Incorrect type for one or more of the arguments.");
return;
}
+ import_settings_data_.import_items = 0;
int num_items = import_items_list->GetSize();
for (int i = 0; i < num_items; i++) {
std::string item;
@@ -3172,34 +3213,16 @@ void TestingAutomationProvider::ImportSettings(Browser* browser,
"Invalid item string found in import_items.");
return;
}
- import_items |= string_to_import_item[item];
+ import_settings_data_.import_items |= string_to_import_item[item];
}
- ImporterHost* importer_host = new ImporterHost();
- // Get the correct ProfileInfo based on the browser they user provided.
- importer::ProfileInfo profile_info;
- int num_browsers = importer_host->GetAvailableProfileCount();
- int i = 0;
- for ( ; i < num_browsers; i++) {
- string16 name = WideToUTF16Hack(importer_host->GetSourceProfileNameAt(i));
- if (name == browser_name) {
- profile_info = importer_host->GetSourceProfileInfoAt(i);
- break;
- }
- }
- // If we made it to the end of the loop, then the input was bad.
- if (i == num_browsers) {
- AutomationJSONReply(this, reply_message).SendError(
- "Invalid browser name string found.");
- return;
- }
+ import_settings_data_.browser = browser;
+ import_settings_data_.reply_message = reply_message;
- Profile* profile = browser->profile();
-
- importer_host->SetObserver(
- new AutomationProviderImportSettingsObserver(this, reply_message));
- importer_host->StartImportSettings(profile_info, profile, import_items,
- new ProfileWriter(profile), first_run);
+ // The remaining functionality of importing settings is in
+ // SourceProfilesLoaded(), which is called by |importer_host_| once the source
+ // profiles are loaded.
+ importer_host_ = new ImporterHost(this);
}
namespace {
@@ -4562,16 +4585,6 @@ void TestingAutomationProvider::OnBrowserRemoved(const Browser* browser) {
}
}
-void TestingAutomationProvider::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- DCHECK(type == NotificationType::SESSION_END);
- // OnBrowserRemoved does a ReleaseLater. When session end is received we exit
- // before the task runs resulting in this object not being deleted. This
- // Release balance out the Release scheduled by OnBrowserRemoved.
- Release();
-}
-
void TestingAutomationProvider::OnRemoveProvider() {
AutomationProviderList::GetInstance()->RemoveProvider(this);
}
diff --git a/chrome/browser/automation/testing_automation_provider.h b/chrome/browser/automation/testing_automation_provider.h
index ac3ad58..b1af561 100644
--- a/chrome/browser/automation/testing_automation_provider.h
+++ b/chrome/browser/automation/testing_automation_provider.h
@@ -11,33 +11,53 @@
#include "chrome/browser/automation/automation_provider.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/history/history.h"
+#include "chrome/browser/importer/importer_list.h"
#include "chrome/browser/sync/profile_sync_service_harness.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/page_type.h"
class DictionaryValue;
+class ImporterHost;
class TemplateURLModel;
// This is an automation provider containing testing calls.
class TestingAutomationProvider : public AutomationProvider,
public BrowserList::Observer,
+ public ImporterList::Observer,
public NotificationObserver {
public:
explicit TestingAutomationProvider(Profile* profile);
- // BrowserList::Observer implementation
+ // BrowserList::Observer implementation.
virtual void OnBrowserAdded(const Browser* browser);
virtual void OnBrowserRemoved(const Browser* browser);
- // IPC implementations
+ // IPC::Channel::Listener implementation.
virtual void OnMessageReceived(const IPC::Message& msg);
virtual void OnChannelError();
private:
class PopupMenuWaiter;
+ // Storage for ImportSettings() to resume operations after a callback.
+ struct ImportSettingsData {
+ string16 browser_name;
+ int import_items;
+ bool first_run;
+ Browser* browser;
+ IPC::Message* reply_message;
+ };
+
virtual ~TestingAutomationProvider();
+ // ImporterList::Observer implementation.
+ virtual void SourceProfilesLoaded();
+
+ // NotificationObserver implementation.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
// IPC Message callbacks.
void CloseBrowser(int handle, IPC::Message* reply_message);
void CloseBrowserAsync(int browser_handle);
@@ -756,10 +776,6 @@ class TestingAutomationProvider : public AutomationProvider,
bool success,
history::RedirectList* redirects);
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
void OnRemoveProvider(); // Called via PostTask
#if defined(TOOLKIT_VIEWS)
@@ -782,6 +798,12 @@ class TestingAutomationProvider : public AutomationProvider,
NotificationRegistrar registrar_;
+ // Used to import settings from browser profiles.
+ scoped_refptr<ImporterHost> importer_host_;
+
+ // The stored data for the ImportSettings operation.
+ ImportSettingsData import_settings_data_;
+
DISALLOW_COPY_AND_ASSIGN(TestingAutomationProvider);
};
diff --git a/chrome/browser/dom_ui/options/import_data_handler.cc b/chrome/browser/dom_ui/options/import_data_handler.cc
index 0b092e0..85fd571 100644
--- a/chrome/browser/dom_ui/options/import_data_handler.cc
+++ b/chrome/browser/dom_ui/options/import_data_handler.cc
@@ -35,6 +35,8 @@ void ImportDataHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(IDS_IMPORT_SETTINGS_TITLE));
localized_strings->SetString("importFromLabel",
l10n_util::GetStringUTF16(IDS_IMPORT_FROM_LABEL));
+ localized_strings->SetString("importLoading",
+ l10n_util::GetStringUTF16(IDS_IMPORT_LOADING_PROFILES));
localized_strings->SetString("importDescription",
l10n_util::GetStringUTF16(IDS_IMPORT_ITEMS_LABEL));
localized_strings->SetString("importHistory",
@@ -52,44 +54,8 @@ void ImportDataHandler::GetLocalizedValues(
}
void ImportDataHandler::Initialize() {
- importer_list_.reset(new ImporterList);
-
- // The ImporterHost object creates an ImporterList, which calls PathExists
- // one or more times. Because we are currently in the UI thread, this will
- // trigger a DCHECK due to IO being done on the UI thread. For now we will
- // suppress the DCHECK. See the following bug for more detail:
- // http://crbug.com/60825
- base::ThreadRestrictions::ScopedAllowIO allow_io;
- importer_list_->DetectSourceProfiles();
- int profiles_count = importer_list_->GetAvailableProfileCount();
-
- ListValue browser_profiles;
- if (profiles_count > 0) {
- for (int i = 0; i < profiles_count; i++) {
- const importer::ProfileInfo& source_profile =
- importer_list_->GetSourceProfileInfoAt(i);
- string16 browser_name = WideToUTF16Hack(source_profile.description);
- uint16 browser_services = source_profile.services_supported;
-
- DictionaryValue* browser_profile = new DictionaryValue();
- browser_profile->SetString("name", browser_name);
- browser_profile->SetInteger("index", i);
- browser_profile->SetBoolean("history",
- (browser_services & importer::HISTORY) != 0);
- browser_profile->SetBoolean("favorites",
- (browser_services & importer::FAVORITES) != 0);
- browser_profile->SetBoolean("passwords",
- (browser_services & importer::PASSWORDS) != 0);
- browser_profile->SetBoolean("search",
- (browser_services & importer::SEARCH_ENGINES) != 0);
-
- browser_profiles.Append(browser_profile);
- }
- }
-
- dom_ui_->CallJavascriptFunction(
- L"options.ImportDataOverlay.updateSupportedBrowsers",
- browser_profiles);
+ importer_list_ = new ImporterList;
+ importer_list_->DetectSourceProfiles(this);
}
void ImportDataHandler::RegisterMessages() {
@@ -131,21 +97,14 @@ void ImportDataHandler::ImportData(const ListValue* args) {
dom_ui_->CallJavascriptFunction(
L"ImportDataOverlay.setImportingState", state);
- // The ImporterHost object creates an ImporterList, which calls PathExists
- // one or more times. Because we are currently in the UI thread, this will
- // trigger a DCHECK due to IO being done on the UI thread. For now we will
- // supress the DCHECK. See the following bug for more detail:
- // http://crbug.com/60825
- base::ThreadRestrictions::ScopedAllowIO allow_io;
-
// TODO(csilv): Out-of-process import has only been qualified on MacOS X,
// so we will only use it on that platform since it is required. Remove this
// conditional logic once oop import is qualified for Linux/Windows.
// http://crbug.com/22142
#if defined(OS_MACOSX)
- importer_host_ = new ExternalProcessImporterHost;
+ importer_host_ = new ExternalProcessImporterHost(this);
#else
- importer_host_ = new ImporterHost;
+ importer_host_ = new ImporterHost(this);
#endif
importer_host_->SetObserver(this);
Profile* profile = dom_ui_->GetProfile();
@@ -175,3 +134,32 @@ void ImportDataHandler::ImportEnded() {
dom_ui_->CallJavascriptFunction(L"ImportDataOverlay.dismiss");
}
+
+void ImportDataHandler::SourceProfilesLoaded() {
+ ListValue browser_profiles;
+ int profiles_count = importer_list_->GetAvailableProfileCount();
+ for (int i = 0; i < profiles_count; i++) {
+ const importer::ProfileInfo& source_profile =
+ importer_list_->GetSourceProfileInfoAt(i);
+ string16 browser_name = WideToUTF16Hack(source_profile.description);
+ uint16 browser_services = source_profile.services_supported;
+
+ DictionaryValue* browser_profile = new DictionaryValue();
+ browser_profile->SetString("name", browser_name);
+ browser_profile->SetInteger("index", i);
+ browser_profile->SetBoolean("history",
+ (browser_services & importer::HISTORY) != 0);
+ browser_profile->SetBoolean("favorites",
+ (browser_services & importer::FAVORITES) != 0);
+ browser_profile->SetBoolean("passwords",
+ (browser_services & importer::PASSWORDS) != 0);
+ browser_profile->SetBoolean("search",
+ (browser_services & importer::SEARCH_ENGINES) != 0);
+
+ browser_profiles.Append(browser_profile);
+ }
+
+ dom_ui_->CallJavascriptFunction(
+ L"options.ImportDataOverlay.updateSupportedBrowsers",
+ browser_profiles);
+}
diff --git a/chrome/browser/dom_ui/options/import_data_handler.h b/chrome/browser/dom_ui/options/import_data_handler.h
index 1c7b872..8f4ed61 100644
--- a/chrome/browser/dom_ui/options/import_data_handler.h
+++ b/chrome/browser/dom_ui/options/import_data_handler.h
@@ -5,12 +5,14 @@
#ifndef CHROME_BROWSER_DOM_UI_OPTIONS_IMPORT_DATA_HANDLER_H_
#define CHROME_BROWSER_DOM_UI_OPTIONS_IMPORT_DATA_HANDLER_H_
+#include "base/ref_counted.h"
#include "chrome/browser/dom_ui/options/options_ui.h"
#include "chrome/browser/importer/importer.h"
// Chrome personal stuff import data overlay UI handler.
class ImportDataHandler : public OptionsPageUIHandler,
- public ImporterHost::Observer {
+ public ImporterHost::Observer,
+ public ImporterList::Observer {
public:
ImportDataHandler();
virtual ~ImportDataHandler();
@@ -25,13 +27,16 @@ class ImportDataHandler : public OptionsPageUIHandler,
private:
void ImportData(const ListValue* args);
- // ImporterHost observer implementation.
+ // ImporterHost::Observer implementation.
virtual void ImportStarted();
virtual void ImportItemStarted(importer::ImportItem item);
virtual void ImportItemEnded(importer::ImportItem item);
virtual void ImportEnded();
- scoped_ptr<ImporterList> importer_list_;
+ // ImporterList::Observer implementation.
+ virtual void SourceProfilesLoaded();
+
+ scoped_refptr<ImporterList> importer_list_;
// If non-null it means importing is in progress. ImporterHost takes care
// of deleting itself when done import.
diff --git a/chrome/browser/gtk/import_dialog_gtk.cc b/chrome/browser/gtk/import_dialog_gtk.cc
index 786007c..d1f828a 100644
--- a/chrome/browser/gtk/import_dialog_gtk.cc
+++ b/chrome/browser/gtk/import_dialog_gtk.cc
@@ -44,7 +44,7 @@ ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile,
int initial_state)
: parent_(parent),
profile_(profile),
- importer_host_(new ImporterHost()),
+ importer_host_(new ImporterHost(this)),
initial_state_(initial_state) {
// Build the dialog.
std::string dialog_name = l10n_util::GetStringUTF8(
@@ -65,10 +65,10 @@ ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile,
// Add import button separately as we might need to disable it, if
// no supported browsers found.
- GtkWidget* import_button = gtk_util::AddButtonToDialog(dialog_,
+ import_button_ = gtk_util::AddButtonToDialog(dialog_,
l10n_util::GetStringUTF8(IDS_IMPORT_COMMIT).c_str(),
GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT);
- GTK_WIDGET_SET_FLAGS(import_button, GTK_CAN_DEFAULT);
+ GTK_WIDGET_SET_FLAGS(import_button_, GTK_CAN_DEFAULT);
gtk_dialog_set_default_response(GTK_DIALOG(dialog_), GTK_RESPONSE_ACCEPT);
GtkWidget* content_area = GTK_DIALOG(dialog_)->vbox;
@@ -125,27 +125,14 @@ ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile,
gtk_box_pack_start(GTK_BOX(content_area), vbox, FALSE, FALSE, 0);
- // Detect any supported browsers that we can import from and fill
- // up the combo box. If none found, disable all controls except cancel.
- int profiles_count = importer_host_->GetAvailableProfileCount();
- if (profiles_count > 0) {
- for (int i = 0; i < profiles_count; i++) {
- std::wstring profile = importer_host_->GetSourceProfileNameAt(i);
- gtk_combo_box_append_text(GTK_COMBO_BOX(combo_),
- WideToUTF8(profile).c_str());
- }
- gtk_widget_grab_focus(import_button);
- } else {
- gtk_combo_box_append_text(GTK_COMBO_BOX(combo_),
- l10n_util::GetStringUTF8(IDS_IMPORT_NO_PROFILE_FOUND).c_str());
- gtk_widget_set_sensitive(bookmarks_, FALSE);
- gtk_widget_set_sensitive(search_engines_, FALSE);
- gtk_widget_set_sensitive(passwords_, FALSE);
- gtk_widget_set_sensitive(history_, FALSE);
- gtk_widget_set_sensitive(import_button, FALSE);
- }
+ // Let the user know profiles are being loaded.
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo_),
+ l10n_util::GetStringUTF8(IDS_IMPORT_LOADING_PROFILES).c_str());
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_), 0);
+ // Disable controls until source profiles are loaded.
+ SetDialogControlsSensitive(false);
+
g_signal_connect(dialog_, "response",
G_CALLBACK(OnDialogResponseThunk), this);
@@ -160,6 +147,26 @@ ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile,
ImportDialogGtk::~ImportDialogGtk() {
}
+void ImportDialogGtk::SourceProfilesLoaded() {
+ // Detect any supported browsers that we can import from and fill
+ // up the combo box. If none found, disable all controls except cancel.
+ int profiles_count = importer_host_->GetAvailableProfileCount();
+ SetDialogControlsSensitive(profiles_count != 0);
+ gtk_combo_box_remove_text(GTK_COMBO_BOX(combo_), 0);
+ if (profiles_count > 0) {
+ for (int i = 0; i < profiles_count; i++) {
+ std::wstring profile = importer_host_->GetSourceProfileNameAt(i);
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo_),
+ WideToUTF8(profile).c_str());
+ }
+ gtk_widget_grab_focus(import_button_);
+ } else {
+ gtk_combo_box_append_text(GTK_COMBO_BOX(combo_),
+ l10n_util::GetStringUTF8(IDS_IMPORT_NO_PROFILE_FOUND).c_str());
+ }
+ gtk_combo_box_set_active(GTK_COMBO_BOX(combo_), 0);
+}
+
void ImportDialogGtk::OnDialogResponse(GtkWidget* widget, int response) {
gtk_widget_hide_all(dialog_);
if (response == GTK_RESPONSE_ACCEPT) {
@@ -187,6 +194,14 @@ void ImportDialogGtk::UpdateDialogButtons() {
GetCheckedItems() != 0);
}
+void ImportDialogGtk::SetDialogControlsSensitive(bool sensitive) {
+ gtk_widget_set_sensitive(bookmarks_, sensitive);
+ gtk_widget_set_sensitive(search_engines_, sensitive);
+ gtk_widget_set_sensitive(passwords_, sensitive);
+ gtk_widget_set_sensitive(history_, sensitive);
+ gtk_widget_set_sensitive(import_button_, sensitive);
+}
+
uint16 ImportDialogGtk::GetCheckedItems() {
uint16 items = importer::NONE;
if (IsChecked(bookmarks_))
diff --git a/chrome/browser/gtk/import_dialog_gtk.h b/chrome/browser/gtk/import_dialog_gtk.h
index a1126b8..f52b845 100644
--- a/chrome/browser/gtk/import_dialog_gtk.h
+++ b/chrome/browser/gtk/import_dialog_gtk.h
@@ -12,14 +12,15 @@
class AccessibleWidgetHelper;
class Profile;
-class ImportDialogGtk : public ImportObserver {
+class ImportDialogGtk : public ImportObserver,
+ public ImporterList::Observer {
public:
// Displays the import box to import data from another browser into |profile|
// |initial_state| is a bitmask of ImportItems. Each checkbox for the bits in
// is checked.
static void Show(GtkWindow* parent, Profile* profile, int initial_state);
- // Overridden from ImportObserver:
+ // ImportObserver implementation.
virtual void ImportCanceled();
virtual void ImportComplete();
@@ -27,6 +28,9 @@ class ImportDialogGtk : public ImportObserver {
ImportDialogGtk(GtkWindow* parent, Profile* profile, int initial_state);
~ImportDialogGtk();
+ // ImporterList::Observer implementation.
+ virtual void SourceProfilesLoaded();
+
// Handler to respond to OK or Cancel responses from the dialog.
CHROMEGTK_CALLBACK_1(ImportDialogGtk, void, OnDialogResponse, int);
@@ -37,6 +41,10 @@ class ImportDialogGtk : public ImportObserver {
// checkboxes.
void UpdateDialogButtons();
+ // Sets the sensitivity of all controls on the dialog except the cancel
+ // button.
+ void SetDialogControlsSensitive(bool sensitive);
+
// Create a bitmask from the checkboxes of the dialog.
uint16 GetCheckedItems();
@@ -61,6 +69,9 @@ class ImportDialogGtk : public ImportObserver {
// History checkbox
GtkWidget* history_;
+ // Import button.
+ GtkWidget* import_button_;
+
// Our current profile
Profile* profile_;
diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc
index c1dc196..4286f4e 100644
--- a/chrome/browser/importer/importer.cc
+++ b/chrome/browser/importer/importer.cc
@@ -85,8 +85,23 @@ ImporterHost::ImporterHost()
installed_bookmark_observer_(false),
is_source_readable_(true),
headless_(false),
- parent_window_(NULL) {
- importer_list_.DetectSourceProfiles();
+ parent_window_(NULL),
+ importer_list_(new ImporterList) {
+ importer_list_->DetectSourceProfilesHack();
+}
+
+ImporterHost::ImporterHost(ImporterList::Observer* observer)
+ : profile_(NULL),
+ observer_(NULL),
+ task_(NULL),
+ importer_(NULL),
+ waiting_for_bookmarkbar_model_(false),
+ installed_bookmark_observer_(false),
+ is_source_readable_(true),
+ headless_(false),
+ parent_window_(NULL),
+ importer_list_(new ImporterList) {
+ importer_list_->DetectSourceProfiles(observer);
}
ImporterHost::~ImporterHost() {
@@ -171,7 +186,7 @@ void ImporterHost::StartImportSettings(
// so that it doesn't block the UI. When the import is complete, observer
// will be notified.
writer_ = writer;
- importer_ = importer_list_.CreateImporterByType(profile_info.browser_type);
+ importer_ = ImporterList::CreateImporterByType(profile_info.browser_type);
// If we fail to create Importer, exit as we cannot do anything.
if (!importer_) {
ImportEnded();
@@ -307,6 +322,15 @@ ExternalProcessImporterHost::ExternalProcessImporterHost()
import_process_launched_(false) {
}
+ExternalProcessImporterHost::ExternalProcessImporterHost(
+ ImporterList::Observer* observer)
+ : ImporterHost(observer),
+ items_(0),
+ import_to_bookmark_bar_(false),
+ cancelled_(false),
+ import_process_launched_(false) {
+}
+
void ExternalProcessImporterHost::Loaded(BookmarkModel* model) {
DCHECK(model->IsLoaded());
model->RemoveObserver(this);
diff --git a/chrome/browser/importer/importer.h b/chrome/browser/importer/importer.h
index 1cb9db7..d8cecac 100644
--- a/chrome/browser/importer/importer.h
+++ b/chrome/browser/importer/importer.h
@@ -55,9 +55,37 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>,
public BookmarkModelObserver,
public NotificationObserver {
public:
+ // An interface which an object can implement to be notified of events during
+ // the import process.
+ class Observer {
+ public:
+ // Invoked when data for the specified item is about to be collected.
+ virtual void ImportItemStarted(importer::ImportItem item) = 0;
+
+ // Invoked when data for the specified item has been collected from the
+ // source profile and is now ready for further processing.
+ virtual void ImportItemEnded(importer::ImportItem item) = 0;
+
+ // Invoked when the import begins.
+ virtual void ImportStarted() = 0;
+
+ // Invoked when the source profile has been imported.
+ virtual void ImportEnded() = 0;
+
+ protected:
+ virtual ~Observer() {}
+ };
+
+ // DEPRECATED: Calls the synchronous version of
+ // ImporterList::DetectSourceProfiles.
+ // TODO(jhawkins): Remove this constructor once all callers are fixed.
+ // See http://crbug.com/65633 and http://crbug.com/65638.
ImporterHost();
- // BookmarkModelObserver methods.
+ // |observer| must not be NULL.
+ explicit ImporterHost(ImporterList::Observer* observer);
+
+ // BookmarkModelObserver implementation.
virtual void Loaded(BookmarkModel* model);
virtual void BookmarkNodeMoved(BookmarkModel* model,
const BookmarkNode* old_parent,
@@ -79,7 +107,8 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>,
const BookmarkNode* node) {}
virtual void BookmarkModelBeingDeleted(BookmarkModel* model);
- // NotificationObserver method. Called when TemplateURLModel has been loaded.
+ // NotificationObserver implementation. Called when TemplateURLModel has been
+ // loaded.
void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
@@ -122,24 +151,6 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>,
parent_window_ = parent_window;
}
- // An interface which an object can implement to be notified of events during
- // the import process.
- class Observer {
- public:
- virtual ~Observer() {}
- // Invoked when data for the specified item is about to be collected.
- virtual void ImportItemStarted(importer::ImportItem item) = 0;
-
- // Invoked when data for the specified item has been collected from the
- // source profile and is now ready for further processing.
- virtual void ImportItemEnded(importer::ImportItem item) = 0;
-
- // Invoked when the import begins.
- virtual void ImportStarted() = 0;
-
- // Invoked when the source profile has been imported.
- virtual void ImportEnded() = 0;
- };
void SetObserver(Observer* observer);
// A series of functions invoked at the start, during and end of the end
@@ -152,25 +163,25 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>,
virtual void ImportEnded();
int GetAvailableProfileCount() const {
- return importer_list_.GetAvailableProfileCount();
+ return importer_list_->GetAvailableProfileCount();
}
// Returns the name of the profile at the 'index' slot. The profiles are
// ordered such that the profile at index 0 is the likely default browser.
std::wstring GetSourceProfileNameAt(int index) const {
- return importer_list_.GetSourceProfileNameAt(index);
+ return importer_list_->GetSourceProfileNameAt(index);
}
// Returns the ProfileInfo at the specified index. The ProfileInfo should be
// passed to StartImportSettings().
const importer::ProfileInfo& GetSourceProfileInfoAt(int index) const {
- return importer_list_.GetSourceProfileInfoAt(index);
+ return importer_list_->GetSourceProfileInfoAt(index);
}
// Returns the ProfileInfo with the given browser type.
const importer::ProfileInfo& GetSourceProfileInfoForBrowserType(
int browser_type) const {
- return importer_list_.GetSourceProfileInfoForBrowserType(browser_type);
+ return importer_list_->GetSourceProfileInfoForBrowserType(browser_type);
}
protected:
@@ -240,7 +251,7 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>,
virtual void InvokeTaskIfDone();
// Used to create an importer of the appropriate type.
- ImporterList importer_list_;
+ scoped_refptr<ImporterList> importer_list_;
DISALLOW_COPY_AND_ASSIGN(ImporterHost);
};
@@ -249,8 +260,14 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>,
// the importer bridge and the external process importer client.
class ExternalProcessImporterHost : public ImporterHost {
public:
+ // DEPRECATED: Calls the deprecated ImporterHost constructor.
+ // TODO(jhawkins): Remove this constructor once all callers are fixed.
+ // See http://crbug.com/65633 and http://crbug.com/65638.
ExternalProcessImporterHost();
+ // |observer| must not be NULL.
+ explicit ExternalProcessImporterHost(ImporterList::Observer* observer);
+
// Called when the BookmarkModel has finished loading. Calls InvokeTaskIfDone
// to start importing.
virtual void Loaded(BookmarkModel* model);
diff --git a/chrome/browser/importer/importer_list.cc b/chrome/browser/importer/importer_list.cc
index 6ac6517..e38cc5e 100644
--- a/chrome/browser/importer/importer_list.cc
+++ b/chrome/browser/importer/importer_list.cc
@@ -27,39 +27,94 @@
#include "chrome/browser/importer/safari_importer.h"
#endif
-ImporterList::ImporterList() {
+namespace {
+
+#if defined(OS_WIN)
+void DetectIEProfiles(std::vector<importer::ProfileInfo*>* profiles) {
+ // IE always exists and doesn't have multiple profiles.
+ ProfileInfo* ie = new ProfileInfo();
+ ie->description = l10n_util::GetString(IDS_IMPORT_FROM_IE);
+ ie->browser_type = importer::MS_IE;
+ ie->source_path.clear();
+ ie->app_path.clear();
+ ie->services_supported = importer::HISTORY | importer::FAVORITES |
+ importer::COOKIES | importer::PASSWORDS | importer::SEARCH_ENGINES;
+ profiles->push_back(ie);
}
+#endif // defined(OS_WIN)
-ImporterList::~ImporterList() {
- STLDeleteContainerPointers(source_profiles_.begin(), source_profiles_.end());
+#if defined(OS_MACOSX)
+void DetectSafariProfiles(std::vector<importer::ProfileInfo*>* profiles) {
+ uint16 items = importer::NONE;
+ if (!SafariImporter::CanImport(mac_util::GetUserLibraryPath(), &items))
+ return;
+
+ importer::ProfileInfo* safari = new importer::ProfileInfo();
+ safari->browser_type = importer::SAFARI;
+ safari->description = l10n_util::GetString(IDS_IMPORT_FROM_SAFARI);
+ safari->source_path.clear();
+ safari->app_path.clear();
+ safari->services_supported = items;
+ profiles->push_back(safari);
}
+#endif // defined(OS_MACOSX)
-void ImporterList::DetectSourceProfiles() {
-// The first run import will automatically take settings from the first
-// profile detected, which should be the user's current default.
+void DetectFirefoxProfiles(std::vector<importer::ProfileInfo*>* profiles) {
+ FilePath profile_path = GetFirefoxProfilePath();
+ if (profile_path.empty())
+ return;
+
+ // Detects which version of Firefox is installed.
+ importer::ProfileType firefox_type;
+ FilePath app_path;
+ int version = 0;
#if defined(OS_WIN)
- if (ShellIntegration::IsFirefoxDefaultBrowser()) {
- DetectFirefoxProfiles();
- DetectIEProfiles();
- } else {
- DetectIEProfiles();
- DetectFirefoxProfiles();
- }
- // TODO(brg) : Current UI requires win_util.
- DetectGoogleToolbarProfiles();
-#elif defined(OS_MACOSX)
- if (ShellIntegration::IsFirefoxDefaultBrowser()) {
- DetectFirefoxProfiles();
- DetectSafariProfiles();
+ version = GetCurrentFirefoxMajorVersionFromRegistry();
+#endif
+ if (version < 2)
+ GetFirefoxVersionAndPathFromProfile(profile_path, &version, &app_path);
+
+ if (version == 2) {
+ firefox_type = importer::FIREFOX2;
+ } else if (version >= 3) {
+ firefox_type = importer::FIREFOX3;
} else {
- DetectSafariProfiles();
- DetectFirefoxProfiles();
+ // Ignores other versions of firefox.
+ return;
}
-#else
- 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;
+#if defined(OS_WIN)
+ firefox->app_path = FilePath::FromWStringHack(
+ GetFirefoxInstallPathFromRegistry());
#endif
+ if (firefox->app_path.empty())
+ firefox->app_path = app_path;
+ firefox->services_supported = importer::HISTORY | importer::FAVORITES |
+ importer::PASSWORDS | importer::SEARCH_ENGINES;
+ profiles->push_back(firefox);
+}
+
+void DetectGoogleToolbarProfiles(std::vector<importer::ProfileInfo*>* profiles) {
+ if (FirstRun::IsChromeFirstRun())
+ return;
+
+ importer::ProfileInfo* google_toolbar = new importer::ProfileInfo();
+ google_toolbar->browser_type = importer::GOOGLE_TOOLBAR5;
+ google_toolbar->description = l10n_util::GetString(
+ IDS_IMPORT_FROM_GOOGLE_TOOLBAR);
+ google_toolbar->source_path.clear();
+ google_toolbar->app_path.clear();
+ google_toolbar->services_supported = importer::FAVORITES;
+ profiles->push_back(google_toolbar);
}
+} // namespace
+
+// static
Importer* ImporterList::CreateImporterByType(importer::ProfileType type) {
switch (type) {
#if defined(OS_WIN)
@@ -85,23 +140,53 @@ Importer* ImporterList::CreateImporterByType(importer::ProfileType type) {
return NULL;
}
+ImporterList::ImporterList()
+ : source_thread_id_(BrowserThread::UI),
+ observer_(NULL),
+ source_profiles_loaded_(false) {
+}
+
+ImporterList::~ImporterList() {
+}
+
+void ImporterList::DetectSourceProfiles(Observer* observer) {
+ DCHECK(observer);
+ observer_ = observer;
+
+ BrowserThread::GetCurrentThreadIdentifier(&source_thread_id_);
+
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
+ FROM_HERE,
+ NewRunnableMethod(this, &ImporterList::DetectSourceProfilesWorker));
+}
+
+void ImporterList::DetectSourceProfilesHack() {
+ DetectSourceProfilesWorker();
+}
+
int ImporterList::GetAvailableProfileCount() const {
+ DCHECK(source_profiles_loaded_);
return static_cast<int>(source_profiles_.size());
}
std::wstring ImporterList::GetSourceProfileNameAt(int index) const {
+ DCHECK(source_profiles_loaded_);
DCHECK(index >=0 && index < GetAvailableProfileCount());
return source_profiles_[index]->description;
}
const importer::ProfileInfo& ImporterList::GetSourceProfileInfoAt(
int index) const {
+ DCHECK(source_profiles_loaded_);
DCHECK(index >=0 && index < GetAvailableProfileCount());
return *source_profiles_[index];
}
const importer::ProfileInfo& ImporterList::GetSourceProfileInfoForBrowserType(
int browser_type) const {
+ DCHECK(source_profiles_loaded_);
+
int count = GetAvailableProfileCount();
for (int i = 0; i < count; ++i) {
if (source_profiles_[i]->browser_type == browser_type)
@@ -111,83 +196,62 @@ const importer::ProfileInfo& ImporterList::GetSourceProfileInfoForBrowserType(
return *(new importer::ProfileInfo());
}
-#if defined(OS_WIN)
-void ImporterList::DetectIEProfiles() {
- // IE always exists and don't have multiple profiles.
- ProfileInfo* ie = new ProfileInfo();
- ie->description = l10n_util::GetString(IDS_IMPORT_FROM_IE);
- ie->browser_type = importer::MS_IE;
- ie->source_path.clear();
- ie->app_path.clear();
- ie->services_supported = importer::HISTORY | importer::FAVORITES |
- importer::COOKIES | importer::PASSWORDS | importer::SEARCH_ENGINES;
- source_profiles_.push_back(ie);
-}
-#endif
+void ImporterList::DetectSourceProfilesWorker() {
+ // TODO(jhawkins): Remove this condition once DetectSourceProfileHack is
+ // removed. |observer_| is NULL when said method is called.
+ if (observer_)
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
-void ImporterList::DetectFirefoxProfiles() {
- FilePath profile_path = GetFirefoxProfilePath();
- if (profile_path.empty())
- return;
+ std::vector<importer::ProfileInfo*> profiles;
- // Detects which version of Firefox is installed.
- importer::ProfileType firefox_type;
- FilePath app_path;
- int version = 0;
+// The first run import will automatically take settings from the first
+// profile detected, which should be the user's current default.
#if defined(OS_WIN)
- version = GetCurrentFirefoxMajorVersionFromRegistry();
-#endif
- if (version < 2)
- GetFirefoxVersionAndPathFromProfile(profile_path, &version, &app_path);
-
- if (version == 2) {
- firefox_type = importer::FIREFOX2;
- } else if (version >= 3) {
- firefox_type = importer::FIREFOX3;
+ if (ShellIntegration::IsFirefoxDefaultBrowser()) {
+ DetectFirefoxProfiles(&profiles);
+ DetectIEProfiles(&profiles);
} else {
- // Ignores other versions of firefox.
- return;
+ DetectIEProfiles(&profiles);
+ DetectFirefoxProfiles(&profiles);
}
-
- 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;
-#if defined(OS_WIN)
- firefox->app_path = FilePath::FromWStringHack(
- GetFirefoxInstallPathFromRegistry());
+ // TODO(brg) : Current UI requires win_util.
+ DetectGoogleToolbarProfiles(&profiles);
+#elif defined(OS_MACOSX)
+ if (ShellIntegration::IsFirefoxDefaultBrowser()) {
+ DetectFirefoxProfiles(&profiles);
+ DetectSafariProfiles(&profiles);
+ } else {
+ DetectSafariProfiles(&profiles);
+ DetectFirefoxProfiles(&profiles);
+ }
+#else
+ DetectFirefoxProfiles(&profiles);
#endif
- if (firefox->app_path.empty())
- firefox->app_path = app_path;
- firefox->services_supported = importer::HISTORY | importer::FAVORITES |
- importer::PASSWORDS | importer::SEARCH_ENGINES;
- source_profiles_.push_back(firefox);
-}
-void ImporterList::DetectGoogleToolbarProfiles() {
- if (!FirstRun::IsChromeFirstRun()) {
- importer::ProfileInfo* google_toolbar = new importer::ProfileInfo();
- google_toolbar->browser_type = importer::GOOGLE_TOOLBAR5;
- google_toolbar->description = l10n_util::GetString(
- IDS_IMPORT_FROM_GOOGLE_TOOLBAR);
- google_toolbar->source_path.clear();
- google_toolbar->app_path.clear();
- google_toolbar->services_supported = importer::FAVORITES;
- source_profiles_.push_back(google_toolbar);
+ // TODO(jhawkins): Remove this condition once DetectSourceProfileHack is
+ // removed. |observer_| is NULL when said method is called.
+ if (observer_) {
+ BrowserThread::PostTask(
+ source_thread_id_,
+ FROM_HERE,
+ NewRunnableMethod(this, &ImporterList::SourceProfilesLoaded, profiles));
+ } else {
+ source_profiles_->assign(profiles.begin(), profiles.end());
+ source_profiles_loaded_ = true;
}
}
-#if defined(OS_MACOSX)
-void ImporterList::DetectSafariProfiles() {
- uint16 items = importer::NONE;
- if (SafariImporter::CanImport(mac_util::GetUserLibraryPath(), &items)) {
- importer::ProfileInfo* safari = new importer::ProfileInfo();
- safari->browser_type = importer::SAFARI;
- safari->description = l10n_util::GetString(IDS_IMPORT_FROM_SAFARI);
- safari->source_path.clear();
- safari->app_path.clear();
- safari->services_supported = items;
- source_profiles_.push_back(safari);
- }
+void ImporterList::SourceProfilesLoaded(
+ const std::vector<importer::ProfileInfo*>& profiles) {
+ DCHECK_NE(static_cast<Observer*>(NULL), observer_);
+
+ BrowserThread::ID current_thread_id;
+ BrowserThread::GetCurrentThreadIdentifier(&current_thread_id);
+ DCHECK_EQ(current_thread_id, source_thread_id_);
+
+ source_profiles_->assign(profiles.begin(), profiles.end());
+ source_profiles_loaded_ = true;
+ observer_->SourceProfilesLoaded();
+ observer_ = NULL;
+ source_thread_id_ = BrowserThread::UI;
}
-#endif // OS_MACOSX
diff --git a/chrome/browser/importer/importer_list.h b/chrome/browser/importer/importer_list.h
index 6f98046..fc801fc 100644
--- a/chrome/browser/importer/importer_list.h
+++ b/chrome/browser/importer/importer_list.h
@@ -9,23 +9,42 @@
#include <string>
#include <vector>
-#include "build/build_config.h"
#include "base/basictypes.h"
+#include "base/platform_thread.h"
+#include "base/ref_counted.h"
+#include "base/scoped_vector.h"
+#include "build/build_config.h"
+#include "chrome/browser/browser_thread.h"
#include "chrome/browser/importer/importer_data_types.h"
class Importer;
-class ImporterList {
+class ImporterList : public base::RefCountedThreadSafe<ImporterList> {
public:
+ // Any class calling DetectSourceProfiles() must implement this interface in
+ // order to be called back when the source profiles are loaded.
+ class Observer {
+ public:
+ virtual void SourceProfilesLoaded() = 0;
+
+ protected:
+ virtual ~Observer() {}
+ };
+
+ static Importer* CreateImporterByType(importer::ProfileType type);
+
ImporterList();
- ~ImporterList();
// Detects the installed browsers and their associated profiles, then
// stores their information in a list. It returns the list of description
- // of all profiles.
- void DetectSourceProfiles();
+ // of all profiles. Calls into DetectSourceProfilesWorker() on the FILE thread
+ // to do the real work of detecting source profiles. |observer| must be
+ // non-NULL.
+ void DetectSourceProfiles(Observer* observer);
- Importer* CreateImporterByType(importer::ProfileType type);
+ // DEPRECATED: This method is synchronous and performs file operations which
+ // may end up blocking the current thread, which is usually the UI thread.
+ void DetectSourceProfilesHack();
// Returns the number of different browser profiles you can import from.
int GetAvailableProfileCount() const;
@@ -42,19 +61,35 @@ class ImporterList {
const importer::ProfileInfo& GetSourceProfileInfoForBrowserType(
int browser_type) const;
- // Helper methods for detecting available profiles.
-#if defined(OS_WIN)
- void DetectIEProfiles();
-#endif
- void DetectFirefoxProfiles();
- void DetectGoogleToolbarProfiles();
-#if defined(OS_MACOSX)
- void DetectSafariProfiles();
-#endif
-
private:
+ friend class base::RefCountedThreadSafe<ImporterList>;
+
+ ~ImporterList();
+
+ // The worker method for DetectSourceProfiles(). Must be called on the FILE
+ // thread.
+ void DetectSourceProfilesWorker();
+
+ // Called by DetectSourceProfilesWorker() on the source thread. This method
+ // notifies |observer_| that the source profiles are loaded. |profiles| is
+ // the vector of loaded profiles.
+ void SourceProfilesLoaded(
+ const std::vector<importer::ProfileInfo*>& profiles);
+
// The list of profiles with the default one first.
- std::vector<importer::ProfileInfo*> source_profiles_;
+ ScopedVector<importer::ProfileInfo> source_profiles_;
+
+ // The ID of the thread DetectSourceProfiles() is called on. Only valid after
+ // DetectSourceProfiles() is called and until SourceProfilesLoaded() has
+ // returned.
+ BrowserThread::ID source_thread_id_;
+
+ // Weak reference. Only valid after DetectSourceProfiles() is called and until
+ // SourceProfilesLoaded() has returned.
+ Observer* observer_;
+
+ // True if source profiles are loaded.
+ bool source_profiles_loaded_;
DISALLOW_COPY_AND_ASSIGN(ImporterList);
};
diff --git a/chrome/browser/resources/options/import_data_overlay.html b/chrome/browser/resources/options/import_data_overlay.html
index 069b29c..ace3502 100644
--- a/chrome/browser/resources/options/import_data_overlay.html
+++ b/chrome/browser/resources/options/import_data_overlay.html
@@ -2,7 +2,9 @@
<h1 i18n-content="importDataTitle"></h1>
<div>
<span i18n-content="importFromLabel"></span>
- <select id="import-browsers"></select>
+ <select id="import-browsers">
+ <option i18n-content="importLoading"></option>
+ </select>
</div>
<div id="import-checkboxes">
<div i18n-content="importDescription"></div>
diff --git a/chrome/browser/resources/options/import_data_overlay.js b/chrome/browser/resources/options/import_data_overlay.js
index c44fcbb..0b7ebab 100644
--- a/chrome/browser/resources/options/import_data_overlay.js
+++ b/chrome/browser/resources/options/import_data_overlay.js
@@ -120,6 +120,7 @@ cr.define('options', function() {
updateSupportedBrowsers_: function(browsers) {
ImportDataOverlay.browserProfiles = browsers;
var browserSelect = $('import-browsers');
+ browserSelect.remove(0); // Remove the 'Loading...' option.
browserSelect.textContent = '';
var browserCount = browsers.length;
diff --git a/chrome/browser/ui/cocoa/import_settings_dialog.h b/chrome/browser/ui/cocoa/import_settings_dialog.h
index 2b84ff9..a9ff7f4 100644
--- a/chrome/browser/ui/cocoa/import_settings_dialog.h
+++ b/chrome/browser/ui/cocoa/import_settings_dialog.h
@@ -19,7 +19,7 @@ class Profile;
@private
NSWindow* parentWindow_; // weak
Profile* profile_; // weak
- scoped_ptr<ImporterList> importerList_;
+ scoped_refptr<ImporterList> importerList_;
scoped_nsobject<NSArray> sourceBrowsersList_;
NSUInteger sourceBrowserIndex_;
// The following are all bound via the properties below.
diff --git a/chrome/browser/ui/cocoa/import_settings_dialog.mm b/chrome/browser/ui/cocoa/import_settings_dialog.mm
index 2989d06..5e6da7a 100644
--- a/chrome/browser/ui/cocoa/import_settings_dialog.mm
+++ b/chrome/browser/ui/cocoa/import_settings_dialog.mm
@@ -112,9 +112,9 @@ bool importSettingsDialogVisible = false;
// are bound to the Browser List array controller and the popup name
// presentation. The services element is used to indirectly control
// checkbox enabling.
- importerList_.reset(new ImporterList);
+ importerList_ = new ImporterList;
ImporterList& importerList(*(importerList_.get()));
- importerList.DetectSourceProfiles();
+ importerList.DetectSourceProfilesHack();
int profilesCount = importerList.GetAvailableProfileCount();
// There shoule be at least the default profile so this should never be zero.
DCHECK(profilesCount > 0);
@@ -146,9 +146,9 @@ bool importSettingsDialogVisible = false;
sourceBrowsersList_.reset([profiles retain]);
// Create and initialize an importerList_ when running unit tests.
if (!importerList_.get()) {
- importerList_.reset(new ImporterList);
+ importerList_ = new ImporterList;
ImporterList& importerList(*(importerList_.get()));
- importerList.DetectSourceProfiles();
+ importerList.DetectSourceProfilesHack();
}
}
return self;
diff --git a/chrome/profile_import/profile_import_thread.cc b/chrome/profile_import/profile_import_thread.cc
index 5700823..2368573 100644
--- a/chrome/profile_import/profile_import_thread.cc
+++ b/chrome/profile_import/profile_import_thread.cc
@@ -52,8 +52,8 @@ void ProfileImportThread::OnImportStart(
bool import_to_bookmark_bar) {
bridge_ = new ExternalProcessImporterBridge(this, localized_strings);
- ImporterList importer_list;
- importer_ = importer_list.CreateImporterByType(profile_info.browser_type);
+ scoped_refptr<ImporterList> importer_list(new ImporterList);
+ importer_ = importer_list->CreateImporterByType(profile_info.browser_type);
if (!importer_) {
Send(new ProfileImportProcessHostMsg_Import_Finished(false,
"Importer could not be created."));