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

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 11572036: Do not load extension system in the Profile import process. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: resolve possible database conflicts in the browser process Created 8 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/extensions/extension_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <set> 9 #include <set>
10 10
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } 405 }
406 406
407 component_loader_.reset( 407 component_loader_.reset(
408 new extensions::ComponentLoader(this, 408 new extensions::ComponentLoader(this,
409 profile->GetPrefs(), 409 profile->GetPrefs(),
410 g_browser_process->local_state())); 410 g_browser_process->local_state()));
411 411
412 app_notification_manager_->Init(); 412 app_notification_manager_->Init();
413 413
414 if (extensions_enabled_) { 414 if (extensions_enabled_) {
415 if (!command_line->HasSwitch(switches::kImport) && 415 CHECK(!ProfileManager::IsImportProcess(*command_line));
416 !command_line->HasSwitch(switches::kImportFromFile)) { 416 extensions::ExternalProviderImpl::CreateExternalProviders(
417 extensions::ExternalProviderImpl::CreateExternalProviders( 417 this, profile_, &external_extension_providers_);
418 this, profile_, &external_extension_providers_);
419 }
420 } 418 }
421 419
422 // Set this as the ExtensionService for extension sorting to ensure it 420 // Set this as the ExtensionService for extension sorting to ensure it
423 // cause syncs if required. 421 // cause syncs if required.
424 extension_prefs_->extension_sorting()->SetExtensionService(this); 422 extension_prefs_->extension_sorting()->SetExtensionService(this);
425 423
426 #if defined(ENABLE_EXTENSIONS) 424 #if defined(ENABLE_EXTENSIONS)
427 extension_action_storage_manager_.reset( 425 extension_action_storage_manager_.reset(
428 new extensions::ExtensionActionStorageManager(profile_)); 426 new extensions::ExtensionActionStorageManager(profile_));
429 #endif 427 #endif
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 495
498 void ExtensionService::RegisterForImportFinished() { 496 void ExtensionService::RegisterForImportFinished() {
499 if (!registrar_.IsRegistered(this, chrome::NOTIFICATION_IMPORT_FINISHED, 497 if (!registrar_.IsRegistered(this, chrome::NOTIFICATION_IMPORT_FINISHED,
500 content::Source<Profile>(profile_))) { 498 content::Source<Profile>(profile_))) {
501 registrar_.Add(this, chrome::NOTIFICATION_IMPORT_FINISHED, 499 registrar_.Add(this, chrome::NOTIFICATION_IMPORT_FINISHED,
502 content::Source<Profile>(profile_)); 500 content::Source<Profile>(profile_));
503 } 501 }
504 } 502 }
505 503
506 void ExtensionService::InitAfterImport() { 504 void ExtensionService::InitAfterImport() {
505 component_loader_->LoadAllDeferred();
506
507 CheckForExternalUpdates(); 507 CheckForExternalUpdates();
508 508
509 GarbageCollectExtensions(); 509 GarbageCollectExtensions();
510 510
511 // Idempotent, so although there is a possible race if the import 511 // Idempotent, so although there is a possible race if the import
512 // process finished sometime in the middle of ProfileImpl::InitExtensions, 512 // process finished sometime in the middle of ProfileImpl::InitExtensions,
513 // it cannot happen twice. 513 // it cannot happen twice.
514 InitEventRouters(); 514 InitEventRouters();
515 } 515 }
516 516
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 } 584 }
585 return NULL; 585 return NULL;
586 } 586 }
587 587
588 void ExtensionService::Init() { 588 void ExtensionService::Init() {
589 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 589 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
590 590
591 DCHECK(!ready_); // Can't redo init. 591 DCHECK(!ready_); // Can't redo init.
592 DCHECK_EQ(extensions_.size(), 0u); 592 DCHECK_EQ(extensions_.size(), 0u);
593 593
594 CHECK(!ProfileManager::IsImportProcess(*CommandLine::ForCurrentProcess()));
595
594 // TODO(mek): It might be cleaner to do the FinishDelayedInstallInfo stuff 596 // TODO(mek): It might be cleaner to do the FinishDelayedInstallInfo stuff
595 // here instead of in installedloader. 597 // here instead of in installedloader.
596 component_loader_->LoadAll(); 598 if (g_browser_process->profile_manager() &&
597 extensions::InstalledLoader(this).LoadAllExtensions(); 599 g_browser_process->profile_manager()->will_import()) {
600
601 // Defer extensions with background pages, since they may conflict with the
602 // import process.
603 component_loader_->LoadAll(true);
604 extensions::InstalledLoader(this).LoadAllExtensions();
tapted 2012/12/19 13:19:14 a question raised from this line might be, "what a
Yoyo Zhou 2012/12/19 21:50:38 If non-component extensions are not being deferred
tapted 2012/12/19 22:58:24 Done.
605 RegisterForImportFinished();
606 } else {
607 component_loader_->LoadAll(false);
608 extensions::InstalledLoader(this).LoadAllExtensions();
609
610 // TODO(erikkay) this should probably be deferred to a future point
611 // rather than running immediately at startup.
612 CheckForExternalUpdates();
613
614 // TODO(erikkay) this should probably be deferred as well.
615 GarbageCollectExtensions();
616 }
598 617
599 // The Sideload Wipeout effort takes place during load (see above), so once 618 // The Sideload Wipeout effort takes place during load (see above), so once
600 // that is done the flag can be set so that we don't have to check again. 619 // that is done the flag can be set so that we don't have to check again.
601 if (wipeout_is_active_) { 620 if (wipeout_is_active_) {
602 extension_prefs_->SetSideloadWipeoutDone(); 621 extension_prefs_->SetSideloadWipeoutDone();
603 wipeout_is_active_ = false; // Wipeout is only on during load. 622 wipeout_is_active_ = false; // Wipeout is only on during load.
604 } 623 }
605 624
606 // If we are running in the import process, don't bother initializing the
607 // extension service since this can interfere with the main browser process
608 // that is already running an extension service for this profile.
609 // TODO(aa): can we start up even less of ExtensionService?
610 // http://crbug.com/107636
611 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kImport) &&
612 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kImportFromFile)) {
613 if (g_browser_process->profile_manager() &&
614 g_browser_process->profile_manager()->will_import()) {
615 RegisterForImportFinished();
616 } else {
617 // TODO(erikkay) this should probably be deferred to a future point
618 // rather than running immediately at startup.
619 CheckForExternalUpdates();
620
621 // TODO(erikkay) this should probably be deferred as well.
622 GarbageCollectExtensions();
623 }
624 }
625
626 if (extension_prefs_->NeedsStorageGarbageCollection()) { 625 if (extension_prefs_->NeedsStorageGarbageCollection()) {
627 GarbageCollectIsolatedStorage(); 626 GarbageCollectIsolatedStorage();
628 extension_prefs_->SetNeedsStorageGarbageCollection(false); 627 extension_prefs_->SetNeedsStorageGarbageCollection(false);
629 } 628 }
630 } 629 }
631 630
632 bool ExtensionService::UpdateExtension(const std::string& id, 631 bool ExtensionService::UpdateExtension(const std::string& id,
633 const FilePath& extension_path, 632 const FilePath& extension_path,
634 const GURL& download_url, 633 const GURL& download_url,
635 CrxInstaller** out_crx_installer) { 634 CrxInstaller** out_crx_installer) {
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after
2008 terminated_extensions_.Clear(); 2007 terminated_extensions_.Clear();
2009 extension_runtime_data_.clear(); 2008 extension_runtime_data_.clear();
2010 2009
2011 // TODO(erikkay) should there be a notification for this? We can't use 2010 // TODO(erikkay) should there be a notification for this? We can't use
2012 // EXTENSION_UNLOADED since that implies that the extension has been disabled 2011 // EXTENSION_UNLOADED since that implies that the extension has been disabled
2013 // or uninstalled, and UnloadAll is just part of shutdown. 2012 // or uninstalled, and UnloadAll is just part of shutdown.
2014 } 2013 }
2015 2014
2016 void ExtensionService::ReloadExtensions() { 2015 void ExtensionService::ReloadExtensions() {
2017 UnloadAllExtensions(); 2016 UnloadAllExtensions();
2018 component_loader_->LoadAll(); 2017 component_loader_->LoadAll(false);
2019 extensions::InstalledLoader(this).LoadAllExtensions(); 2018 extensions::InstalledLoader(this).LoadAllExtensions();
2020 } 2019 }
2021 2020
2022 void ExtensionService::GarbageCollectExtensions() { 2021 void ExtensionService::GarbageCollectExtensions() {
2023 if (extension_prefs_->pref_service()->ReadOnly()) 2022 if (extension_prefs_->pref_service()->ReadOnly())
2024 return; 2023 return;
2025 2024
2026 if (pending_extension_manager()->HasPendingExtensions()) { 2025 if (pending_extension_manager()->HasPendingExtensions()) {
2027 // Don't garbage collect while there are pending installations, which may 2026 // Don't garbage collect while there are pending installations, which may
2028 // be using the temporary installation directory. Try to garbage collect 2027 // be using the temporary installation directory. Try to garbage collect
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
3149 scoped_refptr<const Extension> extension = GetInstalledExtension(*it); 3148 scoped_refptr<const Extension> extension = GetInstalledExtension(*it);
3150 DCHECK(extension); 3149 DCHECK(extension);
3151 if (!extension) 3150 if (!extension)
3152 continue; 3151 continue;
3153 blacklisted_extensions_.Insert(extension); 3152 blacklisted_extensions_.Insert(extension);
3154 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST); 3153 UnloadExtension(*it, extension_misc::UNLOAD_REASON_BLACKLIST);
3155 } 3154 }
3156 3155
3157 IdentifyAlertableExtensions(); 3156 IdentifyAlertableExtensions();
3158 } 3157 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698