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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 402 |
403 void ExtensionService::Init() { | 403 void ExtensionService::Init() { |
404 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 404 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
405 TRACE_EVENT0("browser,startup", "ExtensionService::Init"); | 405 TRACE_EVENT0("browser,startup", "ExtensionService::Init"); |
406 TRACK_SCOPED_REGION("Startup", "ExtensionService::Init"); | 406 TRACK_SCOPED_REGION("Startup", "ExtensionService::Init"); |
407 SCOPED_UMA_HISTOGRAM_TIMER("Extensions.ExtensionServiceInitTime"); | 407 SCOPED_UMA_HISTOGRAM_TIMER("Extensions.ExtensionServiceInitTime"); |
408 | 408 |
409 DCHECK(!is_ready()); // Can't redo init. | 409 DCHECK(!is_ready()); // Can't redo init. |
410 DCHECK_EQ(registry_->enabled_extensions().size(), 0u); | 410 DCHECK_EQ(registry_->enabled_extensions().size(), 0u); |
411 | 411 |
412 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 412 // LoadAllExtensions() calls OnLoadedInstalledExtensions(). |
413 if (cmd_line->HasSwitch(switches::kInstallEphemeralAppFromWebstore)) { | 413 component_loader_->LoadAll(); |
414 // The sole purpose of this launch is to install a new extension from CWS | 414 extensions::InstalledLoader(this).LoadAllExtensions(); |
415 // and immediately terminate: loading already installed extensions is | |
416 // unnecessary and may interfere with the inline install dialog (e.g. if an | |
417 // extension listens to onStartup and opens a window). | |
418 SetReadyAndNotifyListeners(); | |
419 } else { | |
420 // LoadAllExtensions() calls OnLoadedInstalledExtensions(). | |
421 component_loader_->LoadAll(); | |
422 extensions::InstalledLoader(this).LoadAllExtensions(); | |
423 | 415 |
424 EnabledReloadableExtensions(); | 416 EnabledReloadableExtensions(); |
425 MaybeFinishShutdownDelayed(); | 417 MaybeFinishShutdownDelayed(); |
426 SetReadyAndNotifyListeners(); | 418 SetReadyAndNotifyListeners(); |
427 | 419 |
428 // TODO(erikkay): this should probably be deferred to a future point | 420 // TODO(erikkay): this should probably be deferred to a future point |
429 // rather than running immediately at startup. | 421 // rather than running immediately at startup. |
430 CheckForExternalUpdates(); | 422 CheckForExternalUpdates(); |
431 | 423 |
432 LoadGreylistFromPrefs(); | 424 LoadGreylistFromPrefs(); |
433 } | |
434 } | 425 } |
435 | 426 |
436 void ExtensionService::EnabledReloadableExtensions() { | 427 void ExtensionService::EnabledReloadableExtensions() { |
437 TRACE_EVENT0("browser,startup", | 428 TRACE_EVENT0("browser,startup", |
438 "ExtensionService::EnabledReloadableExtensions"); | 429 "ExtensionService::EnabledReloadableExtensions"); |
439 | 430 |
440 std::vector<std::string> extensions_to_enable; | 431 std::vector<std::string> extensions_to_enable; |
441 const ExtensionSet& disabled_extensions = registry_->disabled_extensions(); | 432 const ExtensionSet& disabled_extensions = registry_->disabled_extensions(); |
442 for (ExtensionSet::const_iterator iter = disabled_extensions.begin(); | 433 for (ExtensionSet::const_iterator iter = disabled_extensions.begin(); |
443 iter != disabled_extensions.end(); ++iter) { | 434 iter != disabled_extensions.end(); ++iter) { |
(...skipping 2142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2586 } | 2577 } |
2587 | 2578 |
2588 void ExtensionService::OnProfileDestructionStarted() { | 2579 void ExtensionService::OnProfileDestructionStarted() { |
2589 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2580 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
2590 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2581 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
2591 it != ids_to_unload.end(); | 2582 it != ids_to_unload.end(); |
2592 ++it) { | 2583 ++it) { |
2593 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2584 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
2594 } | 2585 } |
2595 } | 2586 } |
OLD | NEW |