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

Unified Diff: chrome/browser/profiles/profile_impl.cc

Issue 7867044: PART1: Initiated the SignedSettings refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments and issues. Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
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.
//

Powered by Google App Engine
This is Rietveld 408576698