OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extensions_service.h" | 5 #include "chrome/browser/extensions/extensions_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 ExtensionCookiesEventRouter::GetInstance()->Init(); | 600 ExtensionCookiesEventRouter::GetInstance()->Init(); |
601 ExtensionManagementEventRouter::GetInstance()->Init(); | 601 ExtensionManagementEventRouter::GetInstance()->Init(); |
602 ExtensionProcessesEventRouter::GetInstance()->ObserveProfile(profile_); | 602 ExtensionProcessesEventRouter::GetInstance()->ObserveProfile(profile_); |
603 ExtensionWebNavigationEventRouter::GetInstance()->Init(); | 603 ExtensionWebNavigationEventRouter::GetInstance()->Init(); |
604 event_routers_initialized_ = true; | 604 event_routers_initialized_ = true; |
605 } | 605 } |
606 | 606 |
607 void ExtensionsService::Init() { | 607 void ExtensionsService::Init() { |
608 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 608 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
609 | 609 |
610 DCHECK(!ready_); | 610 DCHECK(!ready_); // Can't redo init. |
611 DCHECK_EQ(extensions_.size(), 0u); | 611 DCHECK_EQ(extensions_.size(), 0u); |
612 | 612 |
613 // Hack: we need to ensure the ResourceDispatcherHost is ready before we load | 613 // Hack: we need to ensure the ResourceDispatcherHost is ready before we load |
614 // the first extension, because its members listen for loaded notifications. | 614 // the first extension, because its members listen for loaded notifications. |
615 g_browser_process->resource_dispatcher_host(); | 615 g_browser_process->resource_dispatcher_host(); |
616 | 616 |
617 LoadAllExtensions(); | 617 LoadAllExtensions(); |
618 | 618 |
619 // TODO(erikkay) this should probably be deferred to a future point | 619 // TODO(erikkay) this should probably be deferred to a future point |
620 // rather than running immediately at startup. | 620 // rather than running immediately at startup. |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 | 1476 |
1477 // Also garbage-collect themes. We check |profile_| to be | 1477 // Also garbage-collect themes. We check |profile_| to be |
1478 // defensive; in the future, we may call GarbageCollectExtensions() | 1478 // defensive; in the future, we may call GarbageCollectExtensions() |
1479 // from somewhere other than Init() (e.g., in a timer). | 1479 // from somewhere other than Init() (e.g., in a timer). |
1480 if (profile_) { | 1480 if (profile_) { |
1481 profile_->GetThemeProvider()->RemoveUnusedThemes(); | 1481 profile_->GetThemeProvider()->RemoveUnusedThemes(); |
1482 } | 1482 } |
1483 } | 1483 } |
1484 | 1484 |
1485 void ExtensionsService::OnLoadedInstalledExtensions() { | 1485 void ExtensionsService::OnLoadedInstalledExtensions() { |
1486 ready_ = true; | |
1487 if (updater_.get()) { | 1486 if (updater_.get()) { |
1488 updater_->Start(); | 1487 updater_->Start(); |
1489 } | 1488 } |
| 1489 |
| 1490 ready_ = true; |
1490 NotificationService::current()->Notify( | 1491 NotificationService::current()->Notify( |
1491 NotificationType::EXTENSIONS_READY, | 1492 NotificationType::EXTENSIONS_READY, |
1492 Source<Profile>(profile_), | 1493 Source<Profile>(profile_), |
1493 NotificationService::NoDetails()); | 1494 NotificationService::NoDetails()); |
1494 } | 1495 } |
1495 | 1496 |
1496 void ExtensionsService::OnExtensionLoaded(const Extension* extension, | 1497 void ExtensionsService::OnExtensionLoaded(const Extension* extension, |
1497 bool allow_privilege_increase) { | 1498 bool allow_privilege_increase) { |
1498 // Ensure extension is deleted unless we transfer ownership. | 1499 // Ensure extension is deleted unless we transfer ownership. |
1499 scoped_refptr<const Extension> scoped_extension(extension); | 1500 scoped_refptr<const Extension> scoped_extension(extension); |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 } | 1950 } |
1950 | 1951 |
1951 bool ExtensionsService::IsBeingUpgraded(const Extension* extension) { | 1952 bool ExtensionsService::IsBeingUpgraded(const Extension* extension) { |
1952 return extension_runtime_data_[extension->id()].being_upgraded; | 1953 return extension_runtime_data_[extension->id()].being_upgraded; |
1953 } | 1954 } |
1954 | 1955 |
1955 void ExtensionsService::SetBeingUpgraded(const Extension* extension, | 1956 void ExtensionsService::SetBeingUpgraded(const Extension* extension, |
1956 bool value) { | 1957 bool value) { |
1957 extension_runtime_data_[extension->id()].being_upgraded = value; | 1958 extension_runtime_data_[extension->id()].being_upgraded = value; |
1958 } | 1959 } |
OLD | NEW |