summaryrefslogtreecommitdiffstats
path: root/extensions/shell/browser
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/shell/browser')
-rw-r--r--extensions/shell/browser/shell_extension_system.cc32
-rw-r--r--extensions/shell/browser/shell_extension_system.h8
2 files changed, 27 insertions, 13 deletions
diff --git a/extensions/shell/browser/shell_extension_system.cc b/extensions/shell/browser/shell_extension_system.cc
index e5f5a52..8e9c30a 100644
--- a/extensions/shell/browser/shell_extension_system.cc
+++ b/extensions/shell/browser/shell_extension_system.cc
@@ -29,8 +29,7 @@ using content::BrowserThread;
namespace extensions {
ShellExtensionSystem::ShellExtensionSystem(BrowserContext* browser_context)
- : browser_context_(browser_context) {
-}
+ : browser_context_(browser_context), weak_factory_(this) {}
ShellExtensionSystem::~ShellExtensionSystem() {
}
@@ -59,7 +58,11 @@ const Extension* ShellExtensionSystem::LoadApp(const base::FilePath& app_dir) {
ExtensionRegistry::Get(browser_context_)->AddEnabled(extension.get());
- RegisterExtensionWithRequestContexts(extension.get());
+ RegisterExtensionWithRequestContexts(
+ extension.get(),
+ base::Bind(
+ &ShellExtensionSystem::OnExtensionRegisteredWithRequestContexts,
+ weak_factory_.GetWeakPtr(), extension));
content::NotificationService::current()->Notify(
extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
@@ -134,15 +137,13 @@ QuotaService* ShellExtensionSystem::quota_service() {
}
void ShellExtensionSystem::RegisterExtensionWithRequestContexts(
- const Extension* extension) {
- BrowserThread::PostTask(BrowserThread::IO,
- FROM_HERE,
- base::Bind(&InfoMap::AddExtension,
- info_map(),
- make_scoped_refptr(extension),
- base::Time::Now(),
- false,
- false));
+ const Extension* extension,
+ const base::Closure& callback) {
+ BrowserThread::PostTaskAndReply(BrowserThread::IO, FROM_HERE,
+ base::Bind(&InfoMap::AddExtension, info_map(),
+ make_scoped_refptr(extension),
+ base::Time::Now(), false, false),
+ callback);
}
void ShellExtensionSystem::UnregisterExtensionWithRequestContexts(
@@ -163,4 +164,11 @@ scoped_ptr<ExtensionSet> ShellExtensionSystem::GetDependentExtensions(
return make_scoped_ptr(new ExtensionSet());
}
+void ShellExtensionSystem::OnExtensionRegisteredWithRequestContexts(
+ scoped_refptr<Extension> extension) {
+ ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context_);
+ registry->AddReady(extension);
+ registry->TriggerOnReady(extension.get());
+}
+
} // namespace extensions
diff --git a/extensions/shell/browser/shell_extension_system.h b/extensions/shell/browser/shell_extension_system.h
index 2cbdd5f..3fd5d11 100644
--- a/extensions/shell/browser/shell_extension_system.h
+++ b/extensions/shell/browser/shell_extension_system.h
@@ -8,6 +8,7 @@
#include <vector>
#include "base/compiler_specific.h"
+#include "base/memory/weak_ptr.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/one_shot_event.h"
@@ -59,7 +60,8 @@ class ShellExtensionSystem : public ExtensionSystem {
InfoMap* info_map() override;
QuotaService* quota_service() override;
void RegisterExtensionWithRequestContexts(
- const Extension* extension) override;
+ const Extension* extension,
+ const base::Closure& callback) override;
void UnregisterExtensionWithRequestContexts(
const std::string& extension_id,
const UnloadedExtensionInfo::Reason reason) override;
@@ -69,6 +71,8 @@ class ShellExtensionSystem : public ExtensionSystem {
const Extension* extension) override;
private:
+ void OnExtensionRegisteredWithRequestContexts(
+ scoped_refptr<Extension> extension);
content::BrowserContext* browser_context_; // Not owned.
// Data to be accessed on the IO thread. Must outlive process_manager_.
@@ -80,6 +84,8 @@ class ShellExtensionSystem : public ExtensionSystem {
// Signaled when the extension system has completed its startup tasks.
OneShotEvent ready_;
+ base::WeakPtrFactory<ShellExtensionSystem> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(ShellExtensionSystem);
};