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

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

Issue 6979007: Many fixes to bookmark importing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Happy tests =) Created 9 years, 7 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) 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_host.h" 9 #include "chrome/browser/importer/importer_host.h"
10 #include "chrome/browser/importer/in_process_importer_bridge.h" 10 #include "chrome/browser/importer/in_process_importer_bridge.h"
11 #include "chrome/browser/importer/profile_import_process_host.h" 11 #include "chrome/browser/importer/profile_import_process_host.h"
12 #include "chrome/browser/search_engines/template_url.h" 12 #include "chrome/browser/search_engines/template_url.h"
13 #include "chrome/browser/search_engines/template_url_model.h" 13 #include "chrome/browser/search_engines/template_url_model.h"
14 #include "content/browser/browser_thread.h" 14 #include "content/browser/browser_thread.h"
15 #include "content/browser/renderer_host/resource_dispatcher_host.h" 15 #include "content/browser/renderer_host/resource_dispatcher_host.h"
16 16
17 ExternalProcessImporterClient::ExternalProcessImporterClient( 17 ExternalProcessImporterClient::ExternalProcessImporterClient(
18 ExternalProcessImporterHost* importer_host, 18 ExternalProcessImporterHost* importer_host,
19 const importer::SourceProfile& source_profile, 19 const importer::SourceProfile& source_profile,
20 uint16 items, 20 uint16 items,
21 InProcessImporterBridge* bridge, 21 InProcessImporterBridge* bridge)
22 bool import_to_bookmark_bar) 22 : total_bookmarks_count_(0),
23 : bookmarks_options_(0),
24 total_bookmarks_count_(0),
25 total_history_rows_count_(0), 23 total_history_rows_count_(0),
26 total_favicons_count_(0), 24 total_favicons_count_(0),
27 process_importer_host_(importer_host), 25 process_importer_host_(importer_host),
28 profile_import_process_host_(NULL), 26 profile_import_process_host_(NULL),
29 source_profile_(source_profile), 27 source_profile_(source_profile),
30 items_(items), 28 items_(items),
31 import_to_bookmark_bar_(import_to_bookmark_bar),
32 bridge_(bridge), 29 bridge_(bridge),
33 cancelled_(false) { 30 cancelled_(false) {
34 bridge_->AddRef(); 31 bridge_->AddRef();
35 process_importer_host_->NotifyImportStarted(); 32 process_importer_host_->NotifyImportStarted();
36 } 33 }
37 34
38 ExternalProcessImporterClient::~ExternalProcessImporterClient() { 35 ExternalProcessImporterClient::~ExternalProcessImporterClient() {
39 bridge_->Release(); 36 bridge_->Release();
40 } 37 }
41 38
(...skipping 24 matching lines...) Expand all
66 NewRunnableMethod( 63 NewRunnableMethod(
67 this, 64 this,
68 &ExternalProcessImporterClient::StartProcessOnIOThread, 65 &ExternalProcessImporterClient::StartProcessOnIOThread,
69 thread_id)); 66 thread_id));
70 } 67 }
71 68
72 void ExternalProcessImporterClient::StartProcessOnIOThread( 69 void ExternalProcessImporterClient::StartProcessOnIOThread(
73 BrowserThread::ID thread_id) { 70 BrowserThread::ID thread_id) {
74 profile_import_process_host_ = 71 profile_import_process_host_ =
75 new ProfileImportProcessHost(this, thread_id); 72 new ProfileImportProcessHost(this, thread_id);
76 profile_import_process_host_->StartProfileImportProcess( 73 profile_import_process_host_->StartProfileImportProcess(source_profile_,
77 source_profile_, items_, import_to_bookmark_bar_); 74 items_);
78 } 75 }
79 76
80 void ExternalProcessImporterClient::Cancel() { 77 void ExternalProcessImporterClient::Cancel() {
81 if (cancelled_) 78 if (cancelled_)
82 return; 79 return;
83 80
84 cancelled_ = true; 81 cancelled_ = true;
85 if (profile_import_process_host_) { 82 if (profile_import_process_host_) {
86 BrowserThread::PostTask( 83 BrowserThread::PostTask(
87 BrowserThread::IO, FROM_HERE, 84 BrowserThread::IO, FROM_HERE,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 void ExternalProcessImporterClient::OnHomePageImportReady( 158 void ExternalProcessImporterClient::OnHomePageImportReady(
162 const GURL& home_page) { 159 const GURL& home_page) {
163 if (cancelled_) 160 if (cancelled_)
164 return; 161 return;
165 162
166 bridge_->AddHomePage(home_page); 163 bridge_->AddHomePage(home_page);
167 } 164 }
168 165
169 void ExternalProcessImporterClient::OnBookmarksImportStart( 166 void ExternalProcessImporterClient::OnBookmarksImportStart(
170 const string16& first_folder_name, 167 const string16& first_folder_name,
171 int options,
172 size_t total_bookmarks_count) { 168 size_t total_bookmarks_count) {
173 if (cancelled_) 169 if (cancelled_)
174 return; 170 return;
175 171
176 bookmarks_first_folder_name_ = first_folder_name; 172 bookmarks_first_folder_name_ = first_folder_name;
177 bookmarks_options_ = options;
178 total_bookmarks_count_ = total_bookmarks_count; 173 total_bookmarks_count_ = total_bookmarks_count;
179 bookmarks_.reserve(total_bookmarks_count); 174 bookmarks_.reserve(total_bookmarks_count);
180 } 175 }
181 176
182 void ExternalProcessImporterClient::OnBookmarksImportGroup( 177 void ExternalProcessImporterClient::OnBookmarksImportGroup(
183 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks_group) { 178 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks_group) {
184 if (cancelled_) 179 if (cancelled_)
185 return; 180 return;
186 181
187 // Collect sets of bookmarks from importer process until we have reached 182 // Collect sets of bookmarks from importer process until we have reached
188 // total_bookmarks_count_: 183 // total_bookmarks_count_:
189 bookmarks_.insert(bookmarks_.end(), bookmarks_group.begin(), 184 bookmarks_.insert(bookmarks_.end(), bookmarks_group.begin(),
190 bookmarks_group.end()); 185 bookmarks_group.end());
191 if (bookmarks_.size() == total_bookmarks_count_) { 186 if (bookmarks_.size() == total_bookmarks_count_)
192 bridge_->AddBookmarks(bookmarks_, bookmarks_first_folder_name_, 187 bridge_->AddBookmarks(bookmarks_, bookmarks_first_folder_name_);
193 bookmarks_options_);
194 }
195 } 188 }
196 189
197 void ExternalProcessImporterClient::OnFaviconsImportStart( 190 void ExternalProcessImporterClient::OnFaviconsImportStart(
198 size_t total_favicons_count) { 191 size_t total_favicons_count) {
199 if (cancelled_) 192 if (cancelled_)
200 return; 193 return;
201 194
202 total_favicons_count_ = total_favicons_count; 195 total_favicons_count_ = total_favicons_count;
203 favicons_.reserve(total_favicons_count); 196 favicons_.reserve(total_favicons_count);
204 } 197 }
(...skipping 27 matching lines...) Expand all
232 template_url_vec.reserve(template_urls.size()); 225 template_url_vec.reserve(template_urls.size());
233 std::vector<TemplateURL>::const_iterator iter; 226 std::vector<TemplateURL>::const_iterator iter;
234 for (iter = template_urls.begin(); 227 for (iter = template_urls.begin();
235 iter != template_urls.end(); 228 iter != template_urls.end();
236 ++iter) { 229 ++iter) {
237 template_url_vec.push_back(new TemplateURL(*iter)); 230 template_url_vec.push_back(new TemplateURL(*iter));
238 } 231 }
239 bridge_->SetKeywords(template_url_vec, default_keyword_index, 232 bridge_->SetKeywords(template_url_vec, default_keyword_index,
240 unique_on_host_and_path); 233 unique_on_host_and_path);
241 } 234 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/external_process_importer_client.h ('k') | chrome/browser/importer/external_process_importer_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698