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

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

Issue 24345002: Do not add "Bookmarks File" to ImporterList. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_list.h" 5 #include "chrome/browser/importer/importer_list.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/importer/importer_list_observer.h" 8 #include "chrome/browser/importer/importer_list_observer.h"
9 #include "chrome/browser/shell_integration.h" 9 #include "chrome/browser/shell_integration.h"
10 #include "chrome/common/importer/firefox_importer_utils.h" 10 #include "chrome/common/importer/firefox_importer_utils.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 ImporterList::ImporterList() 100 ImporterList::ImporterList()
101 : source_thread_id_(BrowserThread::UI), 101 : source_thread_id_(BrowserThread::UI),
102 observer_(NULL), 102 observer_(NULL),
103 is_observed_(false), 103 is_observed_(false),
104 source_profiles_loaded_(false) { 104 source_profiles_loaded_(false) {
105 } 105 }
106 106
107 void ImporterList::DetectSourceProfiles( 107 void ImporterList::DetectSourceProfiles(
108 const std::string& locale, 108 const std::string& locale,
109 bool include_interactive_profiles,
109 importer::ImporterListObserver* observer) { 110 importer::ImporterListObserver* observer) {
110 DCHECK(observer); 111 DCHECK(observer);
111 observer_ = observer; 112 observer_ = observer;
112 is_observed_ = true; 113 is_observed_ = true;
113 114
114 bool res = BrowserThread::GetCurrentThreadIdentifier(&source_thread_id_); 115 bool res = BrowserThread::GetCurrentThreadIdentifier(&source_thread_id_);
115 DCHECK(res); 116 DCHECK(res);
116 117
117 BrowserThread::PostTask( 118 BrowserThread::PostTask(BrowserThread::FILE,
118 BrowserThread::FILE, 119 FROM_HERE,
119 FROM_HERE, 120 base::Bind(&ImporterList::DetectSourceProfilesWorker,
120 base::Bind(&ImporterList::DetectSourceProfilesWorker, this, locale)); 121 this,
122 locale,
123 include_interactive_profiles));
121 } 124 }
122 125
123 void ImporterList::DetectSourceProfilesHack(const std::string& locale) { 126 void ImporterList::DetectSourceProfilesHack(const std::string& locale,
124 DetectSourceProfilesWorker(locale); 127 bool include_interactive_profiles) {
128 DetectSourceProfilesWorker(locale, include_interactive_profiles);
125 } 129 }
126 130
127 const importer::SourceProfile& ImporterList::GetSourceProfileAt( 131 const importer::SourceProfile& ImporterList::GetSourceProfileAt(
128 size_t index) const { 132 size_t index) const {
129 DCHECK(source_profiles_loaded_); 133 DCHECK(source_profiles_loaded_);
130 DCHECK_LT(index, count()); 134 DCHECK_LT(index, count());
131 return *source_profiles_[index]; 135 return *source_profiles_[index];
132 } 136 }
133 137
134 const importer::SourceProfile& ImporterList::GetSourceProfileForImporterType( 138 const importer::SourceProfile& ImporterList::GetSourceProfileForImporterType(
135 int importer_type) const { 139 int importer_type) const {
136 DCHECK(source_profiles_loaded_); 140 DCHECK(source_profiles_loaded_);
137 141
138 for (size_t i = 0; i < count(); ++i) { 142 for (size_t i = 0; i < count(); ++i) {
139 if (source_profiles_[i]->importer_type == importer_type) 143 if (source_profiles_[i]->importer_type == importer_type)
140 return *source_profiles_[i]; 144 return *source_profiles_[i];
141 } 145 }
142 NOTREACHED(); 146 NOTREACHED();
143 return *(new importer::SourceProfile); 147 return *(new importer::SourceProfile);
144 } 148 }
145 149
146 ImporterList::~ImporterList() { 150 ImporterList::~ImporterList() {
147 } 151 }
148 152
149 void ImporterList::DetectSourceProfilesWorker(const std::string& locale) { 153 void ImporterList::DetectSourceProfilesWorker(
154 const std::string& locale,
155 bool include_interactive_profiles) {
150 // TODO(jhawkins): Remove this condition once DetectSourceProfilesHack is 156 // TODO(jhawkins): Remove this condition once DetectSourceProfilesHack is
151 // removed. 157 // removed.
152 if (is_observed_) 158 if (is_observed_)
153 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 159 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
154 160
155 std::vector<importer::SourceProfile*> profiles; 161 std::vector<importer::SourceProfile*> profiles;
156 162
157 // The first run import will automatically take settings from the first 163 // The first run import will automatically take settings from the first
158 // profile detected, which should be the user's current default. 164 // profile detected, which should be the user's current default.
159 #if defined(OS_WIN) 165 #if defined(OS_WIN)
160 if (ShellIntegration::IsFirefoxDefaultBrowser()) { 166 if (ShellIntegration::IsFirefoxDefaultBrowser()) {
161 DetectFirefoxProfiles(locale, &profiles); 167 DetectFirefoxProfiles(locale, &profiles);
162 DetectIEProfiles(&profiles); 168 DetectIEProfiles(&profiles);
163 } else { 169 } else {
164 DetectIEProfiles(&profiles); 170 DetectIEProfiles(&profiles);
165 DetectFirefoxProfiles(locale, &profiles); 171 DetectFirefoxProfiles(locale, &profiles);
166 } 172 }
167 #elif defined(OS_MACOSX) 173 #elif defined(OS_MACOSX)
168 if (ShellIntegration::IsFirefoxDefaultBrowser()) { 174 if (ShellIntegration::IsFirefoxDefaultBrowser()) {
169 DetectFirefoxProfiles(locale, &profiles); 175 DetectFirefoxProfiles(locale, &profiles);
170 DetectSafariProfiles(&profiles); 176 DetectSafariProfiles(&profiles);
171 } else { 177 } else {
172 DetectSafariProfiles(&profiles); 178 DetectSafariProfiles(&profiles);
173 DetectFirefoxProfiles(locale, &profiles); 179 DetectFirefoxProfiles(locale, &profiles);
174 } 180 }
175 #else 181 #else
176 DetectFirefoxProfiles(locale, &profiles); 182 DetectFirefoxProfiles(locale, &profiles);
177 #endif 183 #endif
178 importer::SourceProfile* bookmarks_file = new importer::SourceProfile; 184 if (include_interactive_profiles) {
179 bookmarks_file->importer_name = 185 importer::SourceProfile* bookmarks_profile = new importer::SourceProfile;
180 l10n_util::GetStringUTF16(IDS_IMPORT_FROM_BOOKMARKS_HTML_FILE); 186 bookmarks_profile->importer_name =
181 bookmarks_file->importer_type = importer::TYPE_BOOKMARKS_FILE; 187 l10n_util::GetStringUTF16(IDS_IMPORT_FROM_BOOKMARKS_HTML_FILE);
182 bookmarks_file->services_supported = importer::FAVORITES; 188 bookmarks_profile->importer_type = importer::TYPE_BOOKMARKS_FILE;
183 profiles.push_back(bookmarks_file); 189 bookmarks_profile->services_supported = importer::FAVORITES;
190 profiles.push_back(bookmarks_profile);
191 }
184 192
185 // TODO(jhawkins): Remove this condition once DetectSourceProfilesHack is 193 // TODO(jhawkins): Remove this condition once DetectSourceProfilesHack is
186 // removed. 194 // removed.
187 if (is_observed_) { 195 if (is_observed_) {
188 BrowserThread::PostTask( 196 BrowserThread::PostTask(
189 source_thread_id_, 197 source_thread_id_,
190 FROM_HERE, 198 FROM_HERE,
191 base::Bind(&ImporterList::SourceProfilesLoaded, this, profiles)); 199 base::Bind(&ImporterList::SourceProfilesLoaded, this, profiles));
192 } else { 200 } else {
193 source_profiles_.assign(profiles.begin(), profiles.end()); 201 source_profiles_.assign(profiles.begin(), profiles.end());
(...skipping 14 matching lines...) Expand all
208 source_profiles_.assign(profiles.begin(), profiles.end()); 216 source_profiles_.assign(profiles.begin(), profiles.end());
209 source_profiles_loaded_ = true; 217 source_profiles_loaded_ = true;
210 source_thread_id_ = BrowserThread::UI; 218 source_thread_id_ = BrowserThread::UI;
211 219
212 observer_->OnSourceProfilesLoaded(); 220 observer_->OnSourceProfilesLoaded();
213 observer_ = NULL; 221 observer_ = NULL;
214 222
215 // TODO(jhawkins): Remove once DetectSourceProfilesHack is removed. 223 // TODO(jhawkins): Remove once DetectSourceProfilesHack is removed.
216 is_observed_ = false; 224 is_observed_ = false;
217 } 225 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/importer_list.h ('k') | chrome/browser/ui/webui/options/import_data_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698