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

Side by Side 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, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/profiles/profile_impl.h" 5 #include "chrome/browser/profiles/profile_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/environment.h" 9 #include "base/environment.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } 214 }
215 215
216 FilePath GetCachePath(const FilePath& base) { 216 FilePath GetCachePath(const FilePath& base) {
217 return base.Append(chrome::kCacheDirname); 217 return base.Append(chrome::kCacheDirname);
218 } 218 }
219 219
220 FilePath GetMediaCachePath(const FilePath& base) { 220 FilePath GetMediaCachePath(const FilePath& base) {
221 return base.Append(chrome::kMediaCacheDirname); 221 return base.Append(chrome::kMediaCacheDirname);
222 } 222 }
223 223
224 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
225 const std::list<FilePath>& crx_path_list) {
226 Profile* profile =
227 g_browser_process->profile_manager()->GetProfileByPath(profile_path);
228 if (profile) {
229 ExtensionService* extension_service = profile->GetExtensionService();
230 for (std::list<FilePath>::const_iterator iter = crx_path_list.begin();
231 iter != crx_path_list.end(); ++iter) {
232 scoped_refptr<CrxInstaller> crx_installer =
233 extension_service->MakeCrxInstaller(NULL);
234 crx_installer->set_allow_silent_install(true);
235 crx_installer->set_delete_source(false);
236 crx_installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE);
237 crx_installer->InstallCrx(*iter);
238 }
239 }
240 }
241
242 void InstallDefaultApps(const FilePath& profile_path) {
243 FilePath apps_dir;
244 FilePath file;
245 std::list<FilePath> crx_path_list;
246
247 if (PathService::Get(chrome::DIR_DEFAULT_APPS, &apps_dir)) {
248 file_util::FileEnumerator file_enumerator(apps_dir, false,
249 file_util::FileEnumerator::FILES);
250 while (!(file = file_enumerator.Next()).value().empty()) {
251 if (LowerCaseEqualsASCII(file.Extension(), ".crx"))
252 crx_path_list.push_back(file);
253 }
254 }
255 // No need to post the task if nothing was there to install.
256 if (!crx_path_list.size())
257 return;
258
259 // Finish the install on the UI thread.
260 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
261 base::Bind(&DoInstallDefaultAppsOnUIThread,
262 profile_path, crx_path_list));
263 }
264
224 // Simple task to log the size of the current profile. 265 // Simple task to log the size of the current profile.
225 class ProfileSizeTask : public Task { 266 class ProfileSizeTask : public Task {
226 public: 267 public:
227 explicit ProfileSizeTask(const FilePath& path) : path_(path) {} 268 explicit ProfileSizeTask(const FilePath& path) : path_(path) {}
228 virtual ~ProfileSizeTask() {} 269 virtual ~ProfileSizeTask() {}
229 270
230 virtual void Run(); 271 virtual void Run();
231 private: 272 private:
232 FilePath path_; 273 FilePath path_;
233 }; 274 };
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 #elif defined(OS_MACOSX) 582 #elif defined(OS_MACOSX)
542 std::string brand = keystone_glue::BrandCode(); 583 std::string brand = keystone_glue::BrandCode();
543 #else 584 #else
544 std::string brand; 585 std::string brand;
545 #endif 586 #endif
546 // TODO(caitkp): when we move to multi-profiles (M16) we will want to change 587 // TODO(caitkp): when we move to multi-profiles (M16) we will want to change
547 // this check, as |FirstRun::IsChromeFirstRun()| checks for the first run 588 // this check, as |FirstRun::IsChromeFirstRun()| checks for the first run
548 // ever, not first run per profile. 589 // ever, not first run per profile.
549 if (FirstRun::IsChromeFirstRun() && 590 if (FirstRun::IsChromeFirstRun() &&
550 !LowerCaseEqualsASCII(brand, "ecdb")) { 591 !LowerCaseEqualsASCII(brand, "ecdb")) {
551 InstallDefaultApps(); 592 BrowserThread::PostTask(
593 BrowserThread::FILE, FROM_HERE,
594 base::Bind(&InstallDefaultApps, GetPath()));
552 } 595 }
553 #endif 596 #endif
554 597
555 extension_service_->Init(); 598 extension_service_->Init();
556 599
557 if (extensions_enabled) { 600 if (extensions_enabled) {
558 // Load any extensions specified with --load-extension. 601 // Load any extensions specified with --load-extension.
559 if (command_line->HasSwitch(switches::kLoadExtension)) { 602 if (command_line->HasSwitch(switches::kLoadExtension)) {
560 FilePath path = command_line->GetSwitchValuePath( 603 FilePath path = command_line->GetSwitchValuePath(
561 switches::kLoadExtension); 604 switches::kLoadExtension);
(...skipping 19 matching lines...) Expand all
581 if (!command_line->HasSwitch(switches::kImport) && 624 if (!command_line->HasSwitch(switches::kImport) &&
582 !command_line->HasSwitch(switches::kImportFromFile)) { 625 !command_line->HasSwitch(switches::kImportFromFile)) {
583 if (g_browser_process->profile_manager()->will_import()) { 626 if (g_browser_process->profile_manager()->will_import()) {
584 extension_service_->InitEventRoutersAfterImport(); 627 extension_service_->InitEventRoutersAfterImport();
585 } else { 628 } else {
586 extension_service_->InitEventRouters(); 629 extension_service_->InitEventRouters();
587 } 630 }
588 } 631 }
589 } 632 }
590 633
591 void ProfileImpl::InstallDefaultApps() {
592 FilePath apps_dir;
593 FilePath file;
594 std::list<FilePath> crx_path_list;
595
596 if (PathService::Get(chrome::DIR_DEFAULT_APPS, &apps_dir)) {
597 file_util::FileEnumerator file_enumerator(apps_dir, false,
598 file_util::FileEnumerator::FILES);
599 while (!(file = file_enumerator.Next()).value().empty()) {
600 if (LowerCaseEqualsASCII(file.Extension(), ".crx"))
601 crx_path_list.push_back(file);
602 }
603 }
604
605 for (std::list<FilePath>::iterator iter = crx_path_list.begin();
606 iter != crx_path_list.end(); ++iter) {
607 scoped_refptr<CrxInstaller> crx_installer =
608 extension_service_->MakeCrxInstaller(NULL);
609 crx_installer->set_allow_silent_install(true);
610 crx_installer->set_delete_source(false);
611 crx_installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE);
612 crx_installer->InstallCrx(*iter);
613 }
614 }
615
616 void ProfileImpl::RegisterComponentExtensions() { 634 void ProfileImpl::RegisterComponentExtensions() {
617 // Register the component extensions. 635 // Register the component extensions.
618 // 636 //
619 // Component extension manifest must contain a 'key' property with a unique 637 // Component extension manifest must contain a 'key' property with a unique
620 // public key, serialized in base64. You can create a suitable value with the 638 // public key, serialized in base64. You can create a suitable value with the
621 // following commands on a unixy system: 639 // following commands on a unixy system:
622 // 640 //
623 // ssh-keygen -t rsa -b 1024 -N '' -f /tmp/key.pem 641 // ssh-keygen -t rsa -b 1024 -N '' -f /tmp/key.pem
624 // openssl rsa -pubout -outform DER < /tmp/key.pem 2>/dev/null | base64 -w 0 642 // openssl rsa -pubout -outform DER < /tmp/key.pem 2>/dev/null | base64 -w 0
625 typedef std::list<std::pair<FilePath::StringType, int> > 643 typedef std::list<std::pair<FilePath::StringType, int> >
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { 1839 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() {
1822 if (!spellcheck_profile_.get()) 1840 if (!spellcheck_profile_.get())
1823 spellcheck_profile_.reset(new SpellCheckProfile()); 1841 spellcheck_profile_.reset(new SpellCheckProfile());
1824 return spellcheck_profile_.get(); 1842 return spellcheck_profile_.get();
1825 } 1843 }
1826 1844
1827 void ProfileImpl::SetDownloadManagerDelegate( 1845 void ProfileImpl::SetDownloadManagerDelegate(
1828 ChromeDownloadManagerDelegate* delegate) { 1846 ChromeDownloadManagerDelegate* delegate) {
1829 download_manager_delegate_ = delegate; 1847 download_manager_delegate_ = delegate;
1830 } 1848 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698