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

Unified Diff: chrome/browser/importer/importer_list.cc

Issue 1492663006: Improved handling of importer profile creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing header file Created 5 years 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/importer/importer_list.h ('k') | chrome/utility/importer/importer_creator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/importer/importer_list.cc
diff --git a/chrome/browser/importer/importer_list.cc b/chrome/browser/importer/importer_list.cc
index e006503fa39129a8d6ac5c50f480b8130bbde9a3..be62f4231aeed5e845081403b63d23042248bd94 100644
--- a/chrome/browser/importer/importer_list.cc
+++ b/chrome/browser/importer/importer_list.cc
@@ -29,30 +29,29 @@ using content::BrowserThread;
namespace {
#if defined(OS_WIN)
-void DetectIEProfiles(std::vector<importer::SourceProfile*>* profiles) {
+void DetectIEProfiles(std::vector<importer::SourceProfile>* profiles) {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
// IE always exists and doesn't have multiple profiles.
- importer::SourceProfile* ie = new importer::SourceProfile;
- ie->importer_name = l10n_util::GetStringUTF16(IDS_IMPORT_FROM_IE);
- ie->importer_type = importer::TYPE_IE;
- ie->source_path.clear();
- ie->app_path.clear();
- ie->services_supported = importer::HISTORY | importer::FAVORITES |
- importer::COOKIES | importer::PASSWORDS | importer::SEARCH_ENGINES;
+ importer::SourceProfile ie;
+ ie.importer_name = l10n_util::GetStringUTF16(IDS_IMPORT_FROM_IE);
+ ie.importer_type = importer::TYPE_IE;
+ ie.services_supported = importer::HISTORY | importer::FAVORITES |
+ importer::COOKIES | importer::PASSWORDS |
+ importer::SEARCH_ENGINES;
profiles->push_back(ie);
}
-void DetectEdgeProfiles(std::vector<importer::SourceProfile*>* profiles) {
- importer::SourceProfile* edge = new importer::SourceProfile;
- edge->importer_name = l10n_util::GetStringUTF16(IDS_IMPORT_FROM_EDGE);
- edge->importer_type = importer::TYPE_EDGE;
- edge->services_supported = importer::FAVORITES;
- edge->source_path = importer::GetEdgeDataFilePath();
+void DetectEdgeProfiles(std::vector<importer::SourceProfile>* profiles) {
+ importer::SourceProfile edge;
+ edge.importer_name = l10n_util::GetStringUTF16(IDS_IMPORT_FROM_EDGE);
+ edge.importer_type = importer::TYPE_EDGE;
+ edge.services_supported = importer::FAVORITES;
+ edge.source_path = importer::GetEdgeDataFilePath();
profiles->push_back(edge);
}
void DetectBuiltinWindowsProfiles(
- std::vector<importer::SourceProfile*>* profiles) {
+ std::vector<importer::SourceProfile>* profiles) {
// Make the assumption on Windows 10 that Edge exists and is probably default.
if (importer::EdgeImporterCanImport())
DetectEdgeProfiles(profiles);
@@ -62,18 +61,16 @@ void DetectBuiltinWindowsProfiles(
#endif // defined(OS_WIN)
#if defined(OS_MACOSX)
-void DetectSafariProfiles(std::vector<importer::SourceProfile*>* profiles) {
+void DetectSafariProfiles(std::vector<importer::SourceProfile>* profiles) {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
uint16 items = importer::NONE;
if (!SafariImporterCanImport(base::mac::GetUserLibraryPath(), &items))
return;
- importer::SourceProfile* safari = new importer::SourceProfile;
- safari->importer_name = l10n_util::GetStringUTF16(IDS_IMPORT_FROM_SAFARI);
- safari->importer_type = importer::TYPE_SAFARI;
- safari->source_path.clear();
- safari->app_path.clear();
- safari->services_supported = items;
+ importer::SourceProfile safari;
+ safari.importer_name = l10n_util::GetStringUTF16(IDS_IMPORT_FROM_SAFARI);
+ safari.importer_type = importer::TYPE_SAFARI;
+ safari.services_supported = items;
profiles->push_back(safari);
}
#endif // defined(OS_MACOSX)
@@ -82,7 +79,7 @@ void DetectSafariProfiles(std::vector<importer::SourceProfile*>* profiles) {
// locale-specific search engines feature (see firefox_importer.cc for
// details).
void DetectFirefoxProfiles(const std::string locale,
- std::vector<importer::SourceProfile*>* profiles) {
+ std::vector<importer::SourceProfile>* profiles) {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
base::FilePath profile_path = GetFirefoxProfilePath();
if (profile_path.empty())
@@ -105,28 +102,28 @@ void DetectFirefoxProfiles(const std::string locale,
return;
}
- importer::SourceProfile* firefox = new importer::SourceProfile;
- firefox->importer_name = GetFirefoxImporterName(app_path);
- firefox->importer_type = firefox_type;
- firefox->source_path = profile_path;
+ importer::SourceProfile firefox;
+ firefox.importer_name = GetFirefoxImporterName(app_path);
+ firefox.importer_type = firefox_type;
+ firefox.source_path = profile_path;
#if defined(OS_WIN)
- firefox->app_path = GetFirefoxInstallPathFromRegistry();
+ firefox.app_path = GetFirefoxInstallPathFromRegistry();
#endif
- if (firefox->app_path.empty())
- firefox->app_path = app_path;
- firefox->services_supported = importer::HISTORY | importer::FAVORITES |
- importer::PASSWORDS | importer::SEARCH_ENGINES |
- importer::AUTOFILL_FORM_DATA;
- firefox->locale = locale;
+ if (firefox.app_path.empty())
+ firefox.app_path = app_path;
+ firefox.services_supported = importer::HISTORY | importer::FAVORITES |
+ importer::PASSWORDS | importer::SEARCH_ENGINES |
+ importer::AUTOFILL_FORM_DATA;
+ firefox.locale = locale;
profiles->push_back(firefox);
}
-std::vector<importer::SourceProfile*> DetectSourceProfilesWorker(
+std::vector<importer::SourceProfile> DetectSourceProfilesWorker(
const std::string& locale,
bool include_interactive_profiles) {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
- std::vector<importer::SourceProfile*> profiles;
+ std::vector<importer::SourceProfile> profiles;
// The first run import will automatically take settings from the first
// profile detected, which should be the user's current default.
@@ -150,11 +147,11 @@ std::vector<importer::SourceProfile*> DetectSourceProfilesWorker(
DetectFirefoxProfiles(locale, &profiles);
#endif
if (include_interactive_profiles) {
- importer::SourceProfile* bookmarks_profile = new importer::SourceProfile;
- bookmarks_profile->importer_name =
+ importer::SourceProfile bookmarks_profile;
+ bookmarks_profile.importer_name =
l10n_util::GetStringUTF16(IDS_IMPORT_FROM_BOOKMARKS_HTML_FILE);
- bookmarks_profile->importer_type = importer::TYPE_BOOKMARKS_FILE;
- bookmarks_profile->services_supported = importer::FAVORITES;
+ bookmarks_profile.importer_type = importer::TYPE_BOOKMARKS_FILE;
+ bookmarks_profile.services_supported = importer::FAVORITES;
profiles.push_back(bookmarks_profile);
}
@@ -191,12 +188,12 @@ void ImporterList::DetectSourceProfiles(
const importer::SourceProfile& ImporterList::GetSourceProfileAt(
size_t index) const {
DCHECK_LT(index, count());
- return *source_profiles_[index];
+ return source_profiles_[index];
}
void ImporterList::SourceProfilesLoaded(
const base::Closure& profiles_loaded_callback,
- const std::vector<importer::SourceProfile*>& profiles) {
+ const std::vector<importer::SourceProfile>& profiles) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
source_profiles_.assign(profiles.begin(), profiles.end());
« no previous file with comments | « chrome/browser/importer/importer_list.h ('k') | chrome/utility/importer/importer_creator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698