diff options
author | sargrass@google.com <sargrass@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-20 23:21:59 +0000 |
---|---|---|
committer | sargrass@google.com <sargrass@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-20 23:21:59 +0000 |
commit | 443d39bb87e00b7a95de64df6ed19e5c23db56b7 (patch) | |
tree | 9f8f07e94034e82c50f6869103806e1bfd14cf10 /chrome | |
parent | 2ee2da82416e6976b8f41b9a41549bfa128a0e09 (diff) | |
download | chromium_src-443d39bb87e00b7a95de64df6ed19e5c23db56b7.zip chromium_src-443d39bb87e00b7a95de64df6ed19e5c23db56b7.tar.gz chromium_src-443d39bb87e00b7a95de64df6ed19e5c23db56b7.tar.bz2 |
Fix a bug in ImportingData Overlay which cause crash when importing data multiple times.
Fix the problem when force closing the tab while importing.
BUG=49095
TEST=None
Review URL: http://codereview.chromium.org/3167028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56933 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
4 files changed, 21 insertions, 5 deletions
diff --git a/chrome/browser/dom_ui/import_data_handler.cc b/chrome/browser/dom_ui/import_data_handler.cc index 08332df..f771aba 100644 --- a/chrome/browser/dom_ui/import_data_handler.cc +++ b/chrome/browser/dom_ui/import_data_handler.cc @@ -22,11 +22,13 @@ ImportDataHandler::ImportDataHandler() { } ImportDataHandler::~ImportDataHandler() { + if (importer_host_ != NULL) { + importer_host_->SetObserver(NULL); + importer_host_ = NULL; + } } void ImportDataHandler::Initialize() { - importer_host_ = new ImporterHost(); - DetectSupportedBrowsers(); } void ImportDataHandler::GetLocalizedValues( @@ -54,9 +56,16 @@ void ImportDataHandler::GetLocalizedValues( void ImportDataHandler::RegisterMessages() { dom_ui_->RegisterMessageCallback( + "loadImporter", NewCallback(this, &ImportDataHandler::LoadImporter)); + dom_ui_->RegisterMessageCallback( "importData", NewCallback(this, &ImportDataHandler::ImportData)); } +void ImportDataHandler::LoadImporter(const ListValue* args) { + importer_host_ = new ImporterHost(); + DetectSupportedBrowsers(); +} + void ImportDataHandler::DetectSupportedBrowsers() { ListValue supported_browsers; int profiles_count = importer_host_->GetAvailableProfileCount(); @@ -120,4 +129,5 @@ void ImportDataHandler::ImportItemEnded(importer::ImportItem item) { void ImportDataHandler::ImportEnded() { dom_ui_->CallJavascriptFunction(L"ImportDataOverlay.dismiss"); + importer_host_ = NULL; } diff --git a/chrome/browser/dom_ui/import_data_handler.h b/chrome/browser/dom_ui/import_data_handler.h index bd8b72b..85bf9be 100644 --- a/chrome/browser/dom_ui/import_data_handler.h +++ b/chrome/browser/dom_ui/import_data_handler.h @@ -24,6 +24,7 @@ class ImportDataHandler : public OptionsPageUIHandler, virtual void RegisterMessages(); private: + void LoadImporter(const ListValue* args); void DetectSupportedBrowsers(); void ImportData(const ListValue* args); @@ -34,7 +35,7 @@ class ImportDataHandler : public OptionsPageUIHandler, virtual void ImportEnded(); // If non-null it means importing is in progress. ImporterHost takes care - // of deleting itself when done.import. + // of deleting itself when done import. scoped_refptr<ImporterHost> importer_host_; DISALLOW_COPY_AND_ASSIGN(ImportDataHandler); diff --git a/chrome/browser/resources/options/import_data_overlay.js b/chrome/browser/resources/options/import_data_overlay.js index 3bec1c2..455636b 100644 --- a/chrome/browser/resources/options/import_data_overlay.js +++ b/chrome/browser/resources/options/import_data_overlay.js @@ -109,6 +109,10 @@ cr.define('options', function() { }, }; + ImportDataOverlay.loadImporter = function() { + chrome.send('loadImporter'); + }; + ImportDataOverlay.updateSupportedBrowsers = function(browsers) { ImportDataOverlay.getInstance().updateSupportedBrowsers_(browsers); }; @@ -141,8 +145,8 @@ cr.define('options', function() { }; ImportDataOverlay.dismiss = function() { - OptionsPage.clearOverlays(); ImportDataOverlay.setImportingState(false); + OptionsPage.clearOverlays(); } // Export diff --git a/chrome/browser/resources/options/personal_options.js b/chrome/browser/resources/options/personal_options.js index d335f9a..a1fa4de 100644 --- a/chrome/browser/resources/options/personal_options.js +++ b/chrome/browser/resources/options/personal_options.js @@ -68,7 +68,8 @@ cr.define('options', function() { OptionsPage.showOverlay('stopSyncingOverlay'); }; $('import_data').onclick = function(event) { - OptionsPage.showOverlay('importDataOverlay'); + ImportDataOverlay.loadImporter(); + OptionsPage.showOverlay('importDataOverlay'); }; } |