Index: chrome/browser/profiles/profile_impl.cc |
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc |
index be393ae5584660f493534d0b4795260d80a4604d..6adcbe4072c4547252efba75208910331073e868 100644 |
--- a/chrome/browser/profiles/profile_impl.cc |
+++ b/chrome/browser/profiles/profile_impl.cc |
@@ -221,6 +221,47 @@ FilePath GetMediaCachePath(const FilePath& base) { |
return base.Append(chrome::kMediaCacheDirname); |
} |
+void DoInstallDefaultAppsOnUIThread(const FilePath& profile_path, |
Mattias Nissler (ping if slow)
2011/09/26 17:26:37
Unrelated?
pastarmovj
2011/09/29 15:15:03
Yes this is part of a CL that is landed on trunk b
|
+ const std::list<FilePath>& crx_path_list) { |
+ Profile* profile = |
+ g_browser_process->profile_manager()->GetProfileByPath(profile_path); |
+ if (profile) { |
+ ExtensionService* extension_service = profile->GetExtensionService(); |
+ for (std::list<FilePath>::const_iterator iter = crx_path_list.begin(); |
+ iter != crx_path_list.end(); ++iter) { |
+ scoped_refptr<CrxInstaller> crx_installer = |
+ extension_service->MakeCrxInstaller(NULL); |
+ crx_installer->set_allow_silent_install(true); |
+ crx_installer->set_delete_source(false); |
+ crx_installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); |
+ crx_installer->InstallCrx(*iter); |
+ } |
+ } |
+} |
+ |
+void InstallDefaultApps(const FilePath& profile_path) { |
+ FilePath apps_dir; |
+ FilePath file; |
+ std::list<FilePath> crx_path_list; |
+ |
+ if (PathService::Get(chrome::DIR_DEFAULT_APPS, &apps_dir)) { |
+ file_util::FileEnumerator file_enumerator(apps_dir, false, |
+ file_util::FileEnumerator::FILES); |
+ while (!(file = file_enumerator.Next()).value().empty()) { |
+ if (LowerCaseEqualsASCII(file.Extension(), ".crx")) |
+ crx_path_list.push_back(file); |
+ } |
+ } |
+ // No need to post the task if nothing was there to install. |
+ if (!crx_path_list.size()) |
+ return; |
+ |
+ // Finish the install on the UI thread. |
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
+ base::Bind(&DoInstallDefaultAppsOnUIThread, |
+ profile_path, crx_path_list)); |
+} |
+ |
// Simple task to log the size of the current profile. |
class ProfileSizeTask : public Task { |
public: |
@@ -548,7 +589,9 @@ void ProfileImpl::InitExtensions(bool extensions_enabled) { |
// ever, not first run per profile. |
if (FirstRun::IsChromeFirstRun() && |
!LowerCaseEqualsASCII(brand, "ecdb")) { |
- InstallDefaultApps(); |
+ BrowserThread::PostTask( |
+ BrowserThread::FILE, FROM_HERE, |
+ base::Bind(&InstallDefaultApps, GetPath())); |
} |
#endif |
@@ -588,31 +631,6 @@ void ProfileImpl::InitExtensions(bool extensions_enabled) { |
} |
} |
-void ProfileImpl::InstallDefaultApps() { |
- FilePath apps_dir; |
- FilePath file; |
- std::list<FilePath> crx_path_list; |
- |
- if (PathService::Get(chrome::DIR_DEFAULT_APPS, &apps_dir)) { |
- file_util::FileEnumerator file_enumerator(apps_dir, false, |
- file_util::FileEnumerator::FILES); |
- while (!(file = file_enumerator.Next()).value().empty()) { |
- if (LowerCaseEqualsASCII(file.Extension(), ".crx")) |
- crx_path_list.push_back(file); |
- } |
- } |
- |
- for (std::list<FilePath>::iterator iter = crx_path_list.begin(); |
- iter != crx_path_list.end(); ++iter) { |
- scoped_refptr<CrxInstaller> crx_installer = |
- extension_service_->MakeCrxInstaller(NULL); |
- crx_installer->set_allow_silent_install(true); |
- crx_installer->set_delete_source(false); |
- crx_installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); |
- crx_installer->InstallCrx(*iter); |
- } |
-} |
- |
void ProfileImpl::RegisterComponentExtensions() { |
// Register the component extensions. |
// |