| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_bridge.h" | 5 #include "chrome/browser/importer/importer_bridge.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "chrome/browser/chrome_thread.h" |
| 8 #include "chrome/browser/importer/importer.h" | 8 #include "chrome/browser/importer/importer.h" |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include "chrome/browser/password_manager/ie7_password.h" | 10 #include "chrome/browser/password_manager/ie7_password.h" |
| 11 #endif | 11 #endif |
| 12 #include "webkit/glue/password_form.h" | 12 #include "webkit/glue/password_form.h" |
| 13 | 13 |
| 14 InProcessImporterBridge::InProcessImporterBridge(ProfileWriter* writer, | 14 InProcessImporterBridge::InProcessImporterBridge(ProfileWriter* writer, |
| 15 MessageLoop* delegate_loop, | |
| 16 ImporterHost* host) | 15 ImporterHost* host) |
| 17 : ImporterBridge(writer, delegate_loop, host), | 16 : ImporterBridge(writer, host) { |
| 18 main_loop_(MessageLoop::current()), | |
| 19 delegate_loop_(NULL) { | |
| 20 } | 17 } |
| 21 | 18 |
| 22 void InProcessImporterBridge::AddBookmarkEntries( | 19 void InProcessImporterBridge::AddBookmarkEntries( |
| 23 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks, | 20 const std::vector<ProfileWriter::BookmarkEntry>& bookmarks, |
| 24 const std::wstring& first_folder_name, | 21 const std::wstring& first_folder_name, |
| 25 int options) { | 22 int options) { |
| 26 main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, | 23 ChromeThread::PostTask( |
| 27 &ProfileWriter::AddBookmarkEntry, bookmarks, first_folder_name, | 24 ChromeThread::UI, FROM_HERE, |
| 28 options)); | 25 NewRunnableMethod( |
| 26 writer_, &ProfileWriter::AddBookmarkEntry, bookmarks, |
| 27 first_folder_name, options)); |
| 29 } | 28 } |
| 30 | 29 |
| 31 void InProcessImporterBridge::AddHomePage(const GURL &home_page) { | 30 void InProcessImporterBridge::AddHomePage(const GURL &home_page) { |
| 32 main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, | 31 ChromeThread::PostTask( |
| 33 &ProfileWriter::AddHomepage, home_page)); | 32 ChromeThread::UI, FROM_HERE, |
| 33 NewRunnableMethod(writer_, &ProfileWriter::AddHomepage, home_page)); |
| 34 } | 34 } |
| 35 | 35 |
| 36 #if defined(OS_WIN) | 36 #if defined(OS_WIN) |
| 37 void InProcessImporterBridge::AddIE7PasswordInfo( | 37 void InProcessImporterBridge::AddIE7PasswordInfo( |
| 38 const IE7PasswordInfo password_info) { | 38 const IE7PasswordInfo password_info) { |
| 39 main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, | 39 ChromeThread::PostTask( |
| 40 &ProfileWriter::AddIE7PasswordInfo, password_info)); | 40 ChromeThread::UI, FROM_HERE, |
| 41 NewRunnableMethod(writer_, &ProfileWriter::AddIE7PasswordInfo, |
| 42 password_info)); |
| 41 } | 43 } |
| 42 #endif // OS_WIN | 44 #endif // OS_WIN |
| 43 | 45 |
| 44 void InProcessImporterBridge::SetFavIcons( | 46 void InProcessImporterBridge::SetFavIcons( |
| 45 const std::vector<history::ImportedFavIconUsage>& fav_icons) { | 47 const std::vector<history::ImportedFavIconUsage>& fav_icons) { |
| 46 main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, | 48 ChromeThread::PostTask( |
| 47 &ProfileWriter::AddFavicons, fav_icons)); | 49 ChromeThread::UI, FROM_HERE, |
| 50 NewRunnableMethod(writer_, &ProfileWriter::AddFavicons, fav_icons)); |
| 48 } | 51 } |
| 49 | 52 |
| 50 void InProcessImporterBridge::SetHistoryItems( | 53 void InProcessImporterBridge::SetHistoryItems( |
| 51 const std::vector<history::URLRow> &rows) { | 54 const std::vector<history::URLRow> &rows) { |
| 52 main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, | 55 ChromeThread::PostTask( |
| 53 &ProfileWriter::AddHistoryPage, rows)); | 56 ChromeThread::UI, FROM_HERE, |
| 57 NewRunnableMethod(writer_, &ProfileWriter::AddHistoryPage, rows)); |
| 54 } | 58 } |
| 55 | 59 |
| 56 void InProcessImporterBridge::SetKeywords( | 60 void InProcessImporterBridge::SetKeywords( |
| 57 const std::vector<TemplateURL*>& template_urls, | 61 const std::vector<TemplateURL*>& template_urls, |
| 58 int default_keyword_index, | 62 int default_keyword_index, |
| 59 bool unique_on_host_and_path) { | 63 bool unique_on_host_and_path) { |
| 60 main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, | 64 ChromeThread::PostTask( |
| 61 &ProfileWriter::AddKeywords, template_urls, default_keyword_index, | 65 ChromeThread::UI, FROM_HERE, |
| 62 unique_on_host_and_path)); | 66 NewRunnableMethod( |
| 67 writer_, &ProfileWriter::AddKeywords, template_urls, |
| 68 default_keyword_index, unique_on_host_and_path)); |
| 63 } | 69 } |
| 64 | 70 |
| 65 void InProcessImporterBridge::SetPasswordForm( | 71 void InProcessImporterBridge::SetPasswordForm( |
| 66 const webkit_glue::PasswordForm& form) { | 72 const webkit_glue::PasswordForm& form) { |
| 67 main_loop_->PostTask(FROM_HERE, NewRunnableMethod(writer_, | 73 ChromeThread::PostTask( |
| 68 &ProfileWriter::AddPasswordForm, form)); | 74 ChromeThread::UI, FROM_HERE, |
| 75 NewRunnableMethod(writer_, &ProfileWriter::AddPasswordForm, form)); |
| 69 } | 76 } |
| 70 | 77 |
| 71 void InProcessImporterBridge::NotifyItemStarted(ImportItem item) { | 78 void InProcessImporterBridge::NotifyItemStarted(ImportItem item) { |
| 72 main_loop_->PostTask(FROM_HERE, NewRunnableMethod(host_, | 79 ChromeThread::PostTask( |
| 73 &ImporterHost::ImportItemStarted, item)); | 80 ChromeThread::UI, FROM_HERE, |
| 81 NewRunnableMethod(host_, &ImporterHost::ImportItemStarted, item)); |
| 74 } | 82 } |
| 75 | 83 |
| 76 void InProcessImporterBridge::NotifyItemEnded(ImportItem item) { | 84 void InProcessImporterBridge::NotifyItemEnded(ImportItem item) { |
| 77 main_loop_->PostTask(FROM_HERE, NewRunnableMethod(host_, | 85 ChromeThread::PostTask( |
| 78 &ImporterHost::ImportItemEnded, item)); | 86 ChromeThread::UI, FROM_HERE, |
| 87 NewRunnableMethod(host_, &ImporterHost::ImportItemEnded, item)); |
| 79 } | 88 } |
| 80 | 89 |
| 81 void InProcessImporterBridge::NotifyStarted() { | 90 void InProcessImporterBridge::NotifyStarted() { |
| 82 main_loop_->PostTask(FROM_HERE, NewRunnableMethod(host_, | 91 ChromeThread::PostTask( |
| 83 &ImporterHost::ImportStarted)); | 92 ChromeThread::UI, FROM_HERE, |
| 93 NewRunnableMethod(host_, &ImporterHost::ImportStarted)); |
| 84 } | 94 } |
| 85 | 95 |
| 86 void InProcessImporterBridge::NotifyEnded() { | 96 void InProcessImporterBridge::NotifyEnded() { |
| 87 main_loop_->PostTask(FROM_HERE, | 97 ChromeThread::PostTask( |
| 98 ChromeThread::UI, FROM_HERE, |
| 88 NewRunnableMethod(host_, &ImporterHost::ImportEnded)); | 99 NewRunnableMethod(host_, &ImporterHost::ImportEnded)); |
| 89 } | 100 } |
| OLD | NEW |