OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/external_process_importer_client.h" | 5 #include "chrome/browser/importer/external_process_importer_client.h" |
6 | 6 |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/importer/external_process_importer_host.h" | 8 #include "chrome/browser/importer/external_process_importer_host.h" |
9 #include "chrome/browser/importer/importer_bridge.h" | 9 #include "chrome/browser/importer/importer_bridge.h" |
10 #include "chrome/browser/importer/importer_host.h" | 10 #include "chrome/browser/importer/importer_host.h" |
11 #include "chrome/browser/search_engines/template_url.h" | 11 #include "chrome/browser/search_engines/template_url.h" |
12 #include "chrome/browser/search_engines/template_url_model.h" | 12 #include "chrome/browser/search_engines/template_url_model.h" |
13 #include "content/browser/browser_thread.h" | 13 #include "content/browser/browser_thread.h" |
14 | 14 |
15 ExternalProcessImporterClient::ExternalProcessImporterClient( | 15 ExternalProcessImporterClient::ExternalProcessImporterClient( |
16 ExternalProcessImporterHost* importer_host, | 16 ExternalProcessImporterHost* importer_host, |
17 const importer::ProfileInfo& profile_info, | 17 const importer::ProfileInfo& profile_info, |
18 uint16 items, | 18 uint16 items, |
19 InProcessImporterBridge* bridge, | 19 InProcessImporterBridge* bridge, |
20 bool import_to_bookmark_bar) | 20 bool import_to_bookmark_bar) |
21 : bookmarks_options_(0), | 21 : bookmarks_options_(0), |
22 total_bookmarks_count_(0), | 22 total_bookmarks_count_(0), |
23 total_history_rows_count_(0), | 23 total_history_rows_count_(0), |
24 total_fav_icons_count_(0), | 24 total_favicons_count_(0), |
25 process_importer_host_(importer_host), | 25 process_importer_host_(importer_host), |
26 profile_import_process_host_(NULL), | 26 profile_import_process_host_(NULL), |
27 profile_info_(profile_info), | 27 profile_info_(profile_info), |
28 items_(items), | 28 items_(items), |
29 import_to_bookmark_bar_(import_to_bookmark_bar), | 29 import_to_bookmark_bar_(import_to_bookmark_bar), |
30 bridge_(bridge), | 30 bridge_(bridge), |
31 cancelled_(false) { | 31 cancelled_(false) { |
32 bridge_->AddRef(); | 32 bridge_->AddRef(); |
33 process_importer_host_->NotifyImportStarted(); | 33 process_importer_host_->NotifyImportStarted(); |
34 } | 34 } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // total_bookmarks_count_: | 185 // total_bookmarks_count_: |
186 bookmarks_.insert(bookmarks_.end(), bookmarks_group.begin(), | 186 bookmarks_.insert(bookmarks_.end(), bookmarks_group.begin(), |
187 bookmarks_group.end()); | 187 bookmarks_group.end()); |
188 if (bookmarks_.size() == total_bookmarks_count_) { | 188 if (bookmarks_.size() == total_bookmarks_count_) { |
189 bridge_->AddBookmarkEntries(bookmarks_, bookmarks_first_folder_name_, | 189 bridge_->AddBookmarkEntries(bookmarks_, bookmarks_first_folder_name_, |
190 bookmarks_options_); | 190 bookmarks_options_); |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 void ExternalProcessImporterClient::OnFavIconsImportStart( | 194 void ExternalProcessImporterClient::OnFavIconsImportStart( |
195 size_t total_fav_icons_count) { | 195 size_t total_favicons_count) { |
196 if (cancelled_) | 196 if (cancelled_) |
197 return; | 197 return; |
198 | 198 |
199 total_fav_icons_count_ = total_fav_icons_count; | 199 total_favicons_count_ = total_favicons_count; |
200 fav_icons_.reserve(total_fav_icons_count); | 200 favicons_.reserve(total_favicons_count); |
201 } | 201 } |
202 | 202 |
203 void ExternalProcessImporterClient::OnFavIconsImportGroup( | 203 void ExternalProcessImporterClient::OnFavIconsImportGroup( |
204 const std::vector<history::ImportedFavIconUsage>& fav_icons_group) { | 204 const std::vector<history::ImportedFavIconUsage>& favicons_group) { |
205 if (cancelled_) | 205 if (cancelled_) |
206 return; | 206 return; |
207 | 207 |
208 fav_icons_.insert(fav_icons_.end(), fav_icons_group.begin(), | 208 favicons_.insert(favicons_.end(), favicons_group.begin(), |
209 fav_icons_group.end()); | 209 favicons_group.end()); |
210 if (fav_icons_.size() == total_fav_icons_count_) | 210 if (favicons_.size() == total_favicons_count_) |
211 bridge_->SetFavicons(fav_icons_); | 211 bridge_->SetFavicons(favicons_); |
212 } | 212 } |
213 | 213 |
214 void ExternalProcessImporterClient::OnPasswordFormImportReady( | 214 void ExternalProcessImporterClient::OnPasswordFormImportReady( |
215 const webkit_glue::PasswordForm& form) { | 215 const webkit_glue::PasswordForm& form) { |
216 if (cancelled_) | 216 if (cancelled_) |
217 return; | 217 return; |
218 | 218 |
219 bridge_->SetPasswordForm(form); | 219 bridge_->SetPasswordForm(form); |
220 } | 220 } |
221 | 221 |
222 void ExternalProcessImporterClient::OnKeywordsImportReady( | 222 void ExternalProcessImporterClient::OnKeywordsImportReady( |
223 const std::vector<TemplateURL>& template_urls, | 223 const std::vector<TemplateURL>& template_urls, |
224 int default_keyword_index, bool unique_on_host_and_path) { | 224 int default_keyword_index, bool unique_on_host_and_path) { |
225 if (cancelled_) | 225 if (cancelled_) |
226 return; | 226 return; |
227 | 227 |
228 std::vector<TemplateURL*> template_url_vec; | 228 std::vector<TemplateURL*> template_url_vec; |
229 template_url_vec.reserve(template_urls.size()); | 229 template_url_vec.reserve(template_urls.size()); |
230 std::vector<TemplateURL>::const_iterator iter; | 230 std::vector<TemplateURL>::const_iterator iter; |
231 for (iter = template_urls.begin(); | 231 for (iter = template_urls.begin(); |
232 iter != template_urls.end(); | 232 iter != template_urls.end(); |
233 ++iter) { | 233 ++iter) { |
234 template_url_vec.push_back(new TemplateURL(*iter)); | 234 template_url_vec.push_back(new TemplateURL(*iter)); |
235 } | 235 } |
236 bridge_->SetKeywords(template_url_vec, default_keyword_index, | 236 bridge_->SetKeywords(template_url_vec, default_keyword_index, |
237 unique_on_host_and_path); | 237 unique_on_host_and_path); |
238 } | 238 } |
OLD | NEW |