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

Side by Side Diff: chrome/browser/importer/importer.cc

Issue 204051: Fix crash during import by checking for errors and exiting early. (Closed)
Patch Set: Created 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/importer/importer.h" 5 #include "chrome/browser/importer/importer.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "app/gfx/favicon_size.h" 10 #include "app/gfx/favicon_size.h"
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 void ImporterHost::StartImportSettings(const ProfileInfo& profile_info, 521 void ImporterHost::StartImportSettings(const ProfileInfo& profile_info,
522 Profile* target_profile, 522 Profile* target_profile,
523 uint16 items, 523 uint16 items,
524 ProfileWriter* writer, 524 ProfileWriter* writer,
525 bool first_run) { 525 bool first_run) {
526 // Preserves the observer and creates a task, since we do async import 526 // Preserves the observer and creates a task, since we do async import
527 // so that it doesn't block the UI. When the import is complete, observer 527 // so that it doesn't block the UI. When the import is complete, observer
528 // will be notified. 528 // will be notified.
529 writer_ = writer; 529 writer_ = writer;
530 importer_ = CreateImporterByType(profile_info.browser_type); 530 importer_ = CreateImporterByType(profile_info.browser_type);
531 // If we fail to create Importer, exit as we can not do anything.
532 if (!importer_) {
533 ImportEnded();
534 return;
535 }
536
531 importer_->AddRef(); 537 importer_->AddRef();
532 538
533 bool import_to_bookmark_bar = first_run; 539 bool import_to_bookmark_bar = first_run;
534 if (target_profile && target_profile->GetBookmarkModel()->IsLoaded()) { 540 if (target_profile && target_profile->GetBookmarkModel()->IsLoaded()) {
535 std::vector<GURL> starred_urls; 541 std::vector<GURL> starred_urls;
536 target_profile->GetBookmarkModel()->GetBookmarks(&starred_urls); 542 target_profile->GetBookmarkModel()->GetBookmarks(&starred_urls);
537 import_to_bookmark_bar = (starred_urls.size() == 0); 543 import_to_bookmark_bar = (starred_urls.size() == 0);
538 } 544 }
539 importer_->set_import_to_bookmark_bar(import_to_bookmark_bar); 545 importer_->set_import_to_bookmark_bar(import_to_bookmark_bar);
540 task_ = NewRunnableMethod(importer_, &Importer::StartImport, 546 task_ = NewRunnableMethod(importer_, &Importer::StartImport,
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 // TODO(jeremy):Check that Safari folder is in fact present. 837 // TODO(jeremy):Check that Safari folder is in fact present.
832 ProfileInfo* safari = new ProfileInfo(); 838 ProfileInfo* safari = new ProfileInfo();
833 safari->browser_type = SAFARI; 839 safari->browser_type = SAFARI;
834 safari->description = l10n_util::GetString(IDS_IMPORT_FROM_SAFARI); 840 safari->description = l10n_util::GetString(IDS_IMPORT_FROM_SAFARI);
835 safari->source_path.clear(); 841 safari->source_path.clear();
836 safari->app_path.clear(); 842 safari->app_path.clear();
837 safari->services_supported = HISTORY | FAVORITES | HOME_PAGE; 843 safari->services_supported = HISTORY | FAVORITES | HOME_PAGE;
838 source_profiles_.push_back(safari); 844 source_profiles_.push_back(safari);
839 } 845 }
840 #endif // OS_MACOSX 846 #endif // OS_MACOSX
OLDNEW
« chrome/browser/first_run_win.cc ('K') | « chrome/browser/first_run_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698