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/importer_host.h" | 5 #include "chrome/browser/importer/importer_host.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/bookmarks/bookmark_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/importer/firefox_profile_lock.h" | 10 #include "chrome/browser/importer/firefox_profile_lock.h" |
11 #include "chrome/browser/importer/importer.h" | 11 #include "chrome/browser/importer/importer.h" |
12 #include "chrome/browser/importer/importer_lock_dialog.h" | 12 #include "chrome/browser/importer/importer_lock_dialog.h" |
13 #include "chrome/browser/importer/importer_progress_observer.h" | 13 #include "chrome/browser/importer/importer_progress_observer.h" |
14 #include "chrome/browser/importer/importer_type.h" | 14 #include "chrome/browser/importer/importer_type.h" |
15 #include "chrome/browser/importer/in_process_importer_bridge.h" | 15 #include "chrome/browser/importer/in_process_importer_bridge.h" |
16 #include "chrome/browser/importer/toolbar_importer_utils.h" | 16 #include "chrome/browser/importer/toolbar_importer_utils.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/search_engines/template_url.h" | 18 #include "chrome/browser/search_engines/template_url.h" |
19 #include "chrome/browser/search_engines/template_url_service.h" | 19 #include "chrome/browser/search_engines/template_url_service.h" |
20 #include "chrome/browser/search_engines/template_url_service_factory.h" | 20 #include "chrome/browser/search_engines/template_url_service_factory.h" |
21 #include "chrome/browser/ui/browser_list.h" | 21 #include "chrome/browser/ui/browser_list.h" |
| 22 #include "chrome/common/chrome_notification_types.h" |
22 #include "content/browser/browser_thread.h" | 23 #include "content/browser/browser_thread.h" |
23 #include "content/common/notification_source.h" | 24 #include "content/common/notification_source.h" |
24 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
26 | 27 |
27 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
28 // TODO(port): Port this file. | 29 // TODO(port): Port this file. |
29 #include "ui/base/message_box_win.h" | 30 #include "ui/base/message_box_win.h" |
30 #endif | 31 #endif |
31 | 32 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 installed_bookmark_observer_ = true; | 201 installed_bookmark_observer_ = true; |
201 } | 202 } |
202 | 203 |
203 // Observes the TemplateURLService if needed to import search engines from the | 204 // Observes the TemplateURLService if needed to import search engines from the |
204 // other browser. We also check to see if we're importing bookmarks because | 205 // other browser. We also check to see if we're importing bookmarks because |
205 // we can import bookmark keywords from Firefox as search engines. | 206 // we can import bookmark keywords from Firefox as search engines. |
206 if ((items & importer::SEARCH_ENGINES) || (items & importer::FAVORITES)) { | 207 if ((items & importer::SEARCH_ENGINES) || (items & importer::FAVORITES)) { |
207 if (!writer_->TemplateURLServiceIsLoaded()) { | 208 if (!writer_->TemplateURLServiceIsLoaded()) { |
208 TemplateURLService* model = | 209 TemplateURLService* model = |
209 TemplateURLServiceFactory::GetForProfile(profile_); | 210 TemplateURLServiceFactory::GetForProfile(profile_); |
210 registrar_.Add(this, NotificationType::TEMPLATE_URL_SERVICE_LOADED, | 211 registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, |
211 Source<TemplateURLService>(model)); | 212 Source<TemplateURLService>(model)); |
212 model->Load(); | 213 model->Load(); |
213 } | 214 } |
214 } | 215 } |
215 } | 216 } |
216 | 217 |
217 void ImporterHost::InvokeTaskIfDone() { | 218 void ImporterHost::InvokeTaskIfDone() { |
218 if (waiting_for_bookmarkbar_model_ || !registrar_.IsEmpty() || | 219 if (waiting_for_bookmarkbar_model_ || !registrar_.IsEmpty() || |
219 !is_source_readable_) | 220 !is_source_readable_) |
220 return; | 221 return; |
221 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, task_); | 222 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, task_); |
222 } | 223 } |
223 | 224 |
224 void ImporterHost::Loaded(BookmarkModel* model) { | 225 void ImporterHost::Loaded(BookmarkModel* model) { |
225 DCHECK(model->IsLoaded()); | 226 DCHECK(model->IsLoaded()); |
226 model->RemoveObserver(this); | 227 model->RemoveObserver(this); |
227 waiting_for_bookmarkbar_model_ = false; | 228 waiting_for_bookmarkbar_model_ = false; |
228 installed_bookmark_observer_ = false; | 229 installed_bookmark_observer_ = false; |
229 | 230 |
230 InvokeTaskIfDone(); | 231 InvokeTaskIfDone(); |
231 } | 232 } |
232 | 233 |
233 void ImporterHost::BookmarkModelBeingDeleted(BookmarkModel* model) { | 234 void ImporterHost::BookmarkModelBeingDeleted(BookmarkModel* model) { |
234 installed_bookmark_observer_ = false; | 235 installed_bookmark_observer_ = false; |
235 } | 236 } |
236 | 237 |
237 void ImporterHost::BookmarkModelChanged() { | 238 void ImporterHost::BookmarkModelChanged() { |
238 } | 239 } |
239 | 240 |
240 void ImporterHost::Observe(NotificationType type, | 241 void ImporterHost::Observe(int type, |
241 const NotificationSource& source, | 242 const NotificationSource& source, |
242 const NotificationDetails& details) { | 243 const NotificationDetails& details) { |
243 DCHECK(type == NotificationType::TEMPLATE_URL_SERVICE_LOADED); | 244 DCHECK(type == chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED); |
244 registrar_.RemoveAll(); | 245 registrar_.RemoveAll(); |
245 InvokeTaskIfDone(); | 246 InvokeTaskIfDone(); |
246 } | 247 } |
OLD | NEW |