Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1629)

Unified Diff: chrome/browser/ui/webui/options/import_data_handler.cc

Issue 24195005: Fix ImportDataHandler crash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/import_data_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options/import_data_handler.cc
diff --git a/chrome/browser/ui/webui/options/import_data_handler.cc b/chrome/browser/ui/webui/options/import_data_handler.cc
index cc1231576523f36f7709b9cb9245158f049b72f6..cb9d9ceb39b236e956af9eef4c9a922d78ea7db0 100644
--- a/chrome/browser/ui/webui/options/import_data_handler.cc
+++ b/chrome/browser/ui/webui/options/import_data_handler.cc
@@ -86,6 +86,32 @@ void ImportDataHandler::RegisterMessages() {
base::Unretained(this)));
}
+void ImportDataHandler::StartImport(
+ const importer::SourceProfile& source_profile,
+ uint16 imported_items) {
+ if (!imported_items)
+ return;
+
+ // If another import is already ongoing, let it finish silently.
+ if (importer_host_)
+ importer_host_->set_observer(NULL);
+
+ base::FundamentalValue importing(true);
+ web_ui()->CallJavascriptFunction("ImportDataOverlay.setImportingState",
+ importing);
+ import_did_succeed_ = false;
+
+ importer_host_ = new ExternalProcessImporterHost();
+ importer_host_->set_observer(this);
+ Profile* profile = Profile::FromWebUI(web_ui());
+ importer_host_->StartImportSettings(source_profile, profile,
+ imported_items,
+ new ProfileWriter(profile));
+
+ importer::LogImporterUseToMetrics("ImportDataHandler",
+ source_profile.importer_type);
+}
+
void ImportDataHandler::ImportData(const ListValue* args) {
std::string string_value;
@@ -114,22 +140,9 @@ void ImportDataHandler::ImportData(const ListValue* args) {
importer_list_->GetSourceProfileAt(browser_index);
uint16 supported_items = source_profile.services_supported;
- uint16 import_services = (selected_items & supported_items);
- if (import_services) {
- base::FundamentalValue state(true);
- web_ui()->CallJavascriptFunction("ImportDataOverlay.setImportingState",
- state);
- import_did_succeed_ = false;
-
- importer_host_ = new ExternalProcessImporterHost();
- importer_host_->set_observer(this);
- Profile* profile = Profile::FromWebUI(web_ui());
- importer_host_->StartImportSettings(source_profile, profile,
- import_services,
- new ProfileWriter(profile));
-
- importer::LogImporterUseToMetrics("ImportDataHandler",
- source_profile.importer_type);
+ uint16 imported_items = (selected_items & supported_items);
+ if (imported_items) {
+ StartImport(source_profile, imported_items);
} else {
LOG(WARNING) << "There were no settings to import from '"
<< source_profile.importer_name << "'.";
@@ -203,24 +216,14 @@ void ImportDataHandler::ImportEnded() {
}
void ImportDataHandler::FileSelected(const base::FilePath& path,
- int index,
- void* params) {
- base::FundamentalValue importing(true);
- web_ui()->CallJavascriptFunction("ImportDataOverlay.setImportingState",
- importing);
- import_did_succeed_ = false;
-
- importer_host_ = new ExternalProcessImporterHost();
- importer_host_->set_observer(this);
+ int /* index */,
+ void* /* params */) {
Evan Stade 2013/09/17 23:20:10 nit: int /*index*/ (no spaces around var name)
gab 2013/09/18 14:32:35 Done.
importer::SourceProfile source_profile;
source_profile.importer_type = importer::TYPE_BOOKMARKS_FILE;
source_profile.source_path = path;
- Profile* profile = Profile::FromWebUI(web_ui());
-
- importer_host_->StartImportSettings(
- source_profile, profile, importer::FAVORITES, new ProfileWriter(profile));
+ StartImport(source_profile, importer::FAVORITES);
}
void ImportDataHandler::HandleChooseBookmarksFile(const base::ListValue* args) {
« no previous file with comments | « chrome/browser/ui/webui/options/import_data_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698