OLD | NEW |
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/external_process_importer_host.h" | 5 #include "chrome/browser/importer/external_process_importer_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/importer/external_process_importer_client.h" | 10 #include "chrome/browser/importer/external_process_importer_client.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 cancelled_ = true; | 38 cancelled_ = true; |
39 // There is only a |client_| if the import was started. | 39 // There is only a |client_| if the import was started. |
40 if (client_) | 40 if (client_) |
41 client_->Cancel(); | 41 client_->Cancel(); |
42 NotifyImportEnded(); // Tells the observer that we're done, and deletes us. | 42 NotifyImportEnded(); // Tells the observer that we're done, and deletes us. |
43 } | 43 } |
44 | 44 |
45 void ExternalProcessImporterHost::StartImportSettings( | 45 void ExternalProcessImporterHost::StartImportSettings( |
46 const importer::SourceProfile& source_profile, | 46 const importer::SourceProfile& source_profile, |
47 Profile* target_profile, | 47 Profile* target_profile, |
48 uint16 items, | 48 uint16_t items, |
49 ProfileWriter* writer) { | 49 ProfileWriter* writer) { |
50 // We really only support importing from one host at a time. | 50 // We really only support importing from one host at a time. |
51 DCHECK(!profile_); | 51 DCHECK(!profile_); |
52 DCHECK(target_profile); | 52 DCHECK(target_profile); |
53 | 53 |
54 profile_ = target_profile; | 54 profile_ = target_profile; |
55 writer_ = writer; | 55 writer_ = writer; |
56 source_profile_ = source_profile; | 56 source_profile_ = source_profile; |
57 items_ = items; | 57 items_ = items; |
58 | 58 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // show a warning dialog, unless running without UI (in which case the import | 178 // show a warning dialog, unless running without UI (in which case the import |
179 // must be aborted). | 179 // must be aborted). |
180 is_source_readable_ = false; | 180 is_source_readable_ = false; |
181 if (headless_) | 181 if (headless_) |
182 return false; | 182 return false; |
183 | 183 |
184 ShowWarningDialog(); | 184 ShowWarningDialog(); |
185 return true; | 185 return true; |
186 } | 186 } |
187 | 187 |
188 void ExternalProcessImporterHost::CheckForLoadedModels(uint16 items) { | 188 void ExternalProcessImporterHost::CheckForLoadedModels(uint16_t items) { |
189 // A target profile must be loaded by StartImportSettings(). | 189 // A target profile must be loaded by StartImportSettings(). |
190 DCHECK(profile_); | 190 DCHECK(profile_); |
191 | 191 |
192 // BookmarkModel should be loaded before adding IE favorites. So we observe | 192 // BookmarkModel should be loaded before adding IE favorites. So we observe |
193 // the BookmarkModel if needed, and start the task after it has been loaded. | 193 // the BookmarkModel if needed, and start the task after it has been loaded. |
194 if ((items & importer::FAVORITES) && !writer_->BookmarkModelIsLoaded()) { | 194 if ((items & importer::FAVORITES) && !writer_->BookmarkModelIsLoaded()) { |
195 BookmarkModelFactory::GetForProfile(profile_)->AddObserver(this); | 195 BookmarkModelFactory::GetForProfile(profile_)->AddObserver(this); |
196 waiting_for_bookmarkbar_model_ = true; | 196 waiting_for_bookmarkbar_model_ = true; |
197 installed_bookmark_observer_ = true; | 197 installed_bookmark_observer_ = true; |
198 } | 198 } |
199 | 199 |
200 // Observes the TemplateURLService if needed to import search engines from the | 200 // Observes the TemplateURLService if needed to import search engines from the |
201 // other browser. We also check to see if we're importing bookmarks because | 201 // other browser. We also check to see if we're importing bookmarks because |
202 // we can import bookmark keywords from Firefox as search engines. | 202 // we can import bookmark keywords from Firefox as search engines. |
203 if ((items & importer::SEARCH_ENGINES) || (items & importer::FAVORITES)) { | 203 if ((items & importer::SEARCH_ENGINES) || (items & importer::FAVORITES)) { |
204 if (!writer_->TemplateURLServiceIsLoaded()) { | 204 if (!writer_->TemplateURLServiceIsLoaded()) { |
205 TemplateURLService* model = | 205 TemplateURLService* model = |
206 TemplateURLServiceFactory::GetForProfile(profile_); | 206 TemplateURLServiceFactory::GetForProfile(profile_); |
207 template_service_subscription_ = model->RegisterOnLoadedCallback( | 207 template_service_subscription_ = model->RegisterOnLoadedCallback( |
208 base::Bind(&ExternalProcessImporterHost::OnTemplateURLServiceLoaded, | 208 base::Bind(&ExternalProcessImporterHost::OnTemplateURLServiceLoaded, |
209 weak_ptr_factory_.GetWeakPtr())); | 209 weak_ptr_factory_.GetWeakPtr())); |
210 model->Load(); | 210 model->Load(); |
211 } | 211 } |
212 } | 212 } |
213 } | 213 } |
OLD | NEW |