Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 } | 120 } |
| 121 | 121 |
| 122 void ExtensionsService::Init() { | 122 void ExtensionsService::Init() { |
| 123 DCHECK(!ready_); | 123 DCHECK(!ready_); |
| 124 DCHECK_EQ(extensions_.size(), 0u); | 124 DCHECK_EQ(extensions_.size(), 0u); |
| 125 | 125 |
| 126 // Hack: we need to ensure the ResourceDispatcherHost is ready before we load | 126 // Hack: we need to ensure the ResourceDispatcherHost is ready before we load |
| 127 // the first extension, because its members listen for loaded notifications. | 127 // the first extension, because its members listen for loaded notifications. |
| 128 g_browser_process->resource_dispatcher_host(); | 128 g_browser_process->resource_dispatcher_host(); |
| 129 | 129 |
| 130 // Start up the extension event routers. | |
| 131 ExtensionBrowserEventRouter::GetInstance()->Init(); | |
| 132 | |
| 133 LoadAllExtensions(); | 130 LoadAllExtensions(); |
| 134 | 131 |
| 135 // TODO(erikkay) this should probably be deferred to a future point | 132 // TODO(erikkay) this should probably be deferred to a future point |
| 136 // rather than running immediately at startup. | 133 // rather than running immediately at startup. |
| 137 CheckForExternalUpdates(); | 134 CheckForExternalUpdates(); |
| 138 | 135 |
| 139 // TODO(erikkay) this should probably be deferred as well. | 136 // TODO(erikkay) this should probably be deferred as well. |
| 140 GarbageCollectExtensions(); | 137 GarbageCollectExtensions(); |
| 141 } | 138 } |
| 142 | 139 |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 NotificationType::EXTENSION_OVERINSTALL_ERROR, | 498 NotificationType::EXTENSION_OVERINSTALL_ERROR, |
| 502 false); | 499 false); |
| 503 return; | 500 return; |
| 504 } | 501 } |
| 505 } | 502 } |
| 506 | 503 |
| 507 switch (extension_prefs_->GetExtensionState(extension->id())) { | 504 switch (extension_prefs_->GetExtensionState(extension->id())) { |
| 508 case Extension::ENABLED: | 505 case Extension::ENABLED: |
| 509 extensions_.push_back(scoped_extension.release()); | 506 extensions_.push_back(scoped_extension.release()); |
| 510 | 507 |
| 508 // We delay starting up the browser event router until at least one | |
| 509 // extension that needs it is loaded. | |
| 510 if (extension->HasApiPermission(Extension::kTabPermission)) { | |
| 511 ExtensionBrowserEventRouter::GetInstance()->Init(); | |
|
Evan Martin
2009/10/29 01:56:29
Are you certain there's no other way for this to b
Aaron Boodman
2009/10/29 04:03:25
I don't understand.
rafaelw
2009/10/29 04:08:46
Don't need braces
On 2009/10/29 01:56:29, Evan Ma
| |
| 512 } | |
| 513 | |
| 511 if (extension->location() != Extension::LOAD) | 514 if (extension->location() != Extension::LOAD) |
| 512 extension_prefs_->MigrateToPrefs(extension); | 515 extension_prefs_->MigrateToPrefs(extension); |
| 513 | 516 |
| 514 NotifyExtensionLoaded(extension); | 517 NotifyExtensionLoaded(extension); |
| 515 | 518 |
| 516 if (extension->IsTheme() && extension->location() == Extension::LOAD) { | 519 if (extension->IsTheme() && extension->location() == Extension::LOAD) { |
| 517 NotificationService::current()->Notify( | 520 NotificationService::current()->Notify( |
| 518 NotificationType::THEME_INSTALLED, | 521 NotificationType::THEME_INSTALLED, |
| 519 Source<ExtensionsService>(this), | 522 Source<ExtensionsService>(this), |
| 520 Details<Extension>(extension)); | 523 Details<Extension>(extension)); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 812 linked_ptr<ExternalExtensionProvider>(test_provider); | 815 linked_ptr<ExternalExtensionProvider>(test_provider); |
| 813 } | 816 } |
| 814 | 817 |
| 815 void ExtensionsServiceBackend::OnExternalExtensionFound( | 818 void ExtensionsServiceBackend::OnExternalExtensionFound( |
| 816 const std::string& id, const Version* version, const FilePath& path, | 819 const std::string& id, const Version* version, const FilePath& path, |
| 817 Extension::Location location) { | 820 Extension::Location location) { |
| 818 frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(frontend_, | 821 frontend_loop_->PostTask(FROM_HERE, NewRunnableMethod(frontend_, |
| 819 &ExtensionsService::OnExternalExtensionFound, id, version->GetString(), | 822 &ExtensionsService::OnExternalExtensionFound, id, version->GetString(), |
| 820 path, location)); | 823 path, location)); |
| 821 } | 824 } |
| OLD | NEW |