diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-07 22:55:30 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-07 22:55:30 +0000 |
commit | 111ca63cacf4cedb65be41fd4cabfa5ad7bb6b86 (patch) | |
tree | 19bfebe83f96b4db5b78bb86f989667a11d04554 /chrome/browser/dom_ui | |
parent | e8d82c6124232e1678eb242e5c7369bd20ac949d (diff) | |
download | chromium_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
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r-- | chrome/browser/dom_ui/options/import_data_handler.cc | 82 | ||||
-rw-r--r-- | chrome/browser/dom_ui/options/import_data_handler.h | 11 |
2 files changed, 43 insertions, 50 deletions
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. |