Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 // profile is in the process of being deleted. | 450 // profile is in the process of being deleted. |
| 451 | 451 |
| 452 extensions::ProviderCollection::const_iterator i; | 452 extensions::ProviderCollection::const_iterator i; |
| 453 for (i = external_extension_providers_.begin(); | 453 for (i = external_extension_providers_.begin(); |
| 454 i != external_extension_providers_.end(); ++i) { | 454 i != external_extension_providers_.end(); ++i) { |
| 455 extensions::ExternalProviderInterface* provider = i->get(); | 455 extensions::ExternalProviderInterface* provider = i->get(); |
| 456 provider->ServiceShutdown(); | 456 provider->ServiceShutdown(); |
| 457 } | 457 } |
| 458 } | 458 } |
| 459 | 459 |
| 460 void ExtensionService::InitEventRoutersAfterImport() { | |
| 461 RegisterForImportFinished(); | |
| 462 } | |
| 463 | |
| 464 void ExtensionService::RegisterForImportFinished() { | |
| 465 if (!registrar_.IsRegistered(this, chrome::NOTIFICATION_IMPORT_FINISHED, | |
| 466 content::Source<Profile>(profile_))) { | |
| 467 registrar_.Add(this, chrome::NOTIFICATION_IMPORT_FINISHED, | |
| 468 content::Source<Profile>(profile_)); | |
| 469 } | |
| 470 } | |
| 471 | |
| 472 void ExtensionService::InitAfterImport() { | |
| 473 startup_metric_utils::ScopedSlowStartupUMA | |
| 474 scoped_timer("Startup.SlowStartupExtensionServiceInitAfterImport"); | |
|
asargent_no_longer_on_chrome
2013/06/19 19:39:05
FYI, the folks working on chrome slow startup may
| |
| 475 component_loader_->LoadAll(); | |
| 476 | |
| 477 CheckForExternalUpdates(); | |
| 478 | |
| 479 GarbageCollectExtensions(); | |
| 480 | |
| 481 // Idempotent, so although there is a possible race if the import | |
| 482 // process finished sometime in the middle of ProfileImpl::InitExtensions, | |
| 483 // it cannot happen twice. | |
| 484 InitEventRouters(); | |
| 485 } | |
| 486 | |
| 487 void ExtensionService::InitEventRouters() { | 460 void ExtensionService::InitEventRouters() { |
| 488 if (event_routers_initialized_) | 461 if (event_routers_initialized_) |
| 489 return; | 462 return; |
| 490 | 463 |
| 491 #if defined(ENABLE_EXTENSIONS) | 464 #if defined(ENABLE_EXTENSIONS) |
| 492 browser_event_router_.reset(new extensions::BrowserEventRouter(profile_)); | 465 browser_event_router_.reset(new extensions::BrowserEventRouter(profile_)); |
| 493 #endif // defined(ENABLE_EXTENSIONS) | 466 #endif // defined(ENABLE_EXTENSIONS) |
| 494 event_routers_initialized_ = true; | 467 event_routers_initialized_ = true; |
| 495 } | 468 } |
| 496 | 469 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 if (cmd_line->HasSwitch(switches::kInstallFromWebstore) || | 525 if (cmd_line->HasSwitch(switches::kInstallFromWebstore) || |
| 553 cmd_line->HasSwitch(switches::kLimitedInstallFromWebstore)) { | 526 cmd_line->HasSwitch(switches::kLimitedInstallFromWebstore)) { |
| 554 // The sole purpose of this launch is to install a new extension from CWS | 527 // The sole purpose of this launch is to install a new extension from CWS |
| 555 // and immediately terminate: loading already installed extensions is | 528 // and immediately terminate: loading already installed extensions is |
| 556 // unnecessary and may interfere with the inline install dialog (e.g. if an | 529 // unnecessary and may interfere with the inline install dialog (e.g. if an |
| 557 // extension listens to onStartup and opens a window). | 530 // extension listens to onStartup and opens a window). |
| 558 SetReadyAndNotifyListeners(); | 531 SetReadyAndNotifyListeners(); |
| 559 } else { | 532 } else { |
| 560 // TODO(mek): It might be cleaner to do the FinishDelayedInstallInfo stuff | 533 // TODO(mek): It might be cleaner to do the FinishDelayedInstallInfo stuff |
| 561 // here instead of in installedloader. | 534 // here instead of in installedloader. |
| 562 if (g_browser_process->profile_manager() && | |
| 563 g_browser_process->profile_manager()->will_import()) { | |
| 564 // Do not load any component extensions, since they may conflict with the | |
| 565 // import process. | |
| 566 | 535 |
| 567 extensions::InstalledLoader(this).LoadAllExtensions(); | 536 // LoadAllExtensions() calls OnLoadedInstalledExtensions(). |
| 568 SetReadyAndNotifyListeners(); | 537 component_loader_->LoadAll(); |
| 569 RegisterForImportFinished(); | 538 extensions::InstalledLoader(this).LoadAllExtensions(); |
| 570 } else { | 539 SetReadyAndNotifyListeners(); |
| 571 // In this case, LoadAllExtensions() calls OnLoadedInstalledExtensions(). | |
| 572 component_loader_->LoadAll(); | |
| 573 extensions::InstalledLoader(this).LoadAllExtensions(); | |
| 574 SetReadyAndNotifyListeners(); | |
| 575 | 540 |
| 576 // TODO(erikkay) this should probably be deferred to a future point | 541 // TODO(erikkay) this should probably be deferred to a future point |
| 577 // rather than running immediately at startup. | 542 // rather than running immediately at startup. |
| 578 CheckForExternalUpdates(); | 543 CheckForExternalUpdates(); |
| 579 | 544 |
| 580 base::MessageLoop::current()->PostDelayedTask( | 545 base::MessageLoop::current()->PostDelayedTask( |
| 581 FROM_HERE, | 546 FROM_HERE, |
| 582 base::Bind(&ExtensionService::GarbageCollectExtensions, AsWeakPtr()), | 547 base::Bind(&ExtensionService::GarbageCollectExtensions, AsWeakPtr()), |
| 583 base::TimeDelta::FromSeconds(kGarbageCollectStartupDelay)); | 548 base::TimeDelta::FromSeconds(kGarbageCollectStartupDelay)); |
| 584 } | |
| 585 | 549 |
| 586 if (extension_prefs_->NeedsStorageGarbageCollection()) { | 550 if (extension_prefs_->NeedsStorageGarbageCollection()) { |
| 587 GarbageCollectIsolatedStorage(); | 551 GarbageCollectIsolatedStorage(); |
| 588 extension_prefs_->SetNeedsStorageGarbageCollection(false); | 552 extension_prefs_->SetNeedsStorageGarbageCollection(false); |
| 589 } | 553 } |
| 590 } | 554 } |
| 591 } | 555 } |
| 592 | 556 |
| 593 bool ExtensionService::UpdateExtension(const std::string& id, | 557 bool ExtensionService::UpdateExtension(const std::string& id, |
| 594 const base::FilePath& extension_path, | 558 const base::FilePath& extension_path, |
| (...skipping 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2635 break; | 2599 break; |
| 2636 | 2600 |
| 2637 process_map_.RemoveAllFromProcess(process->GetID()); | 2601 process_map_.RemoveAllFromProcess(process->GetID()); |
| 2638 BrowserThread::PostTask( | 2602 BrowserThread::PostTask( |
| 2639 BrowserThread::IO, FROM_HERE, | 2603 BrowserThread::IO, FROM_HERE, |
| 2640 base::Bind(&ExtensionInfoMap::UnregisterAllExtensionsInProcess, | 2604 base::Bind(&ExtensionInfoMap::UnregisterAllExtensionsInProcess, |
| 2641 system_->info_map(), | 2605 system_->info_map(), |
| 2642 process->GetID())); | 2606 process->GetID())); |
| 2643 break; | 2607 break; |
| 2644 } | 2608 } |
| 2645 case chrome::NOTIFICATION_IMPORT_FINISHED: { | |
| 2646 InitAfterImport(); | |
| 2647 break; | |
| 2648 } | |
| 2649 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: { | 2609 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: { |
| 2650 extensions::ExtensionHost* host = | 2610 extensions::ExtensionHost* host = |
| 2651 content::Details<extensions::ExtensionHost>(details).ptr(); | 2611 content::Details<extensions::ExtensionHost>(details).ptr(); |
| 2652 std::string extension_id = host->extension_id(); | 2612 std::string extension_id = host->extension_id(); |
| 2653 if (delayed_updates_for_idle_.Contains(extension_id)) { | 2613 if (delayed_updates_for_idle_.Contains(extension_id)) { |
| 2654 // We were waiting for this extension to become idle, it now might have, | 2614 // We were waiting for this extension to become idle, it now might have, |
| 2655 // so maybe finish installation. | 2615 // so maybe finish installation. |
| 2656 base::MessageLoop::current()->PostDelayedTask( | 2616 base::MessageLoop::current()->PostDelayedTask( |
| 2657 FROM_HERE, | 2617 FROM_HERE, |
| 2658 base::Bind(&ExtensionService::MaybeFinishDelayedInstallation, | 2618 base::Bind(&ExtensionService::MaybeFinishDelayedInstallation, |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2915 } | 2875 } |
| 2916 | 2876 |
| 2917 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { | 2877 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { |
| 2918 update_observers_.AddObserver(observer); | 2878 update_observers_.AddObserver(observer); |
| 2919 } | 2879 } |
| 2920 | 2880 |
| 2921 void ExtensionService::RemoveUpdateObserver( | 2881 void ExtensionService::RemoveUpdateObserver( |
| 2922 extensions::UpdateObserver* observer) { | 2882 extensions::UpdateObserver* observer) { |
| 2923 update_observers_.RemoveObserver(observer); | 2883 update_observers_.RemoveObserver(observer); |
| 2924 } | 2884 } |
| OLD | NEW |