Index: athena/extensions/extension_delegate_impl.cc |
diff --git a/athena/extensions/extension_delegate_impl.cc b/athena/extensions/extension_delegate_impl.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b59a4d8b4d06cf0a036efff9af69672893f4e817 |
--- /dev/null |
+++ b/athena/extensions/extension_delegate_impl.cc |
@@ -0,0 +1,78 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "athena/extensions/public/extension_delegate.h" |
+#include "base/macros.h" |
+#include "extensions/common/extension_set.h" |
+#include "extensions/shell/browser/shell_extension_system.h" |
+ |
+namespace athena { |
+namespace { |
+ |
+ExtensionDelegate* instance = NULL; |
+ |
+class ShellExtensionDelegate : public ExtensionDelegate { |
+ public: |
+ explicit ShellExtensionDelegate(content::BrowserContext* context) |
+ : context_(context), |
+ extension_system_( |
+ static_cast<extensions::ShellExtensionSystem*>( |
+ extensions::ExtensionSystem::Get(context))) { |
+ if (extension_system_->extension()) |
Yoyo Zhou
2014/08/20 20:37:27
I know in the current implementation the extension
oshima
2014/08/20 21:39:21
Done.
|
+ shell_extensions_.Insert(extension_system_->extension()); |
+ } |
+ virtual ~ShellExtensionDelegate() { |
Yoyo Zhou
2014/08/20 20:37:27
nit: line breaks between function definitions
oshima
2014/08/20 21:39:21
Done.
|
+ } |
+ |
+ private: |
+ // ExtensionDelegate: |
+ virtual content::BrowserContext* GetBrowserContext() const OVERRIDE { |
+ return context_; |
+ } |
+ virtual extensions::ExtensionSet* GetExtensionSet() OVERRIDE { |
+ return &shell_extensions_; |
+ } |
+ virtual void Launch(const std::string& id) OVERRIDE { |
+ extension_system_->LaunchApp(); |
+ } |
+ |
+ content::BrowserContext* context_; |
+ extensions::ShellExtensionSystem* extension_system_; |
+ extensions::ExtensionSet shell_extensions_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ShellExtensionDelegate); |
+}; |
+ |
+} // namespace |
+ |
+ExtensionDelegate::ExtensionDelegate() { |
+ DCHECK(!instance); |
+ instance = this; |
+} |
+ |
+ExtensionDelegate::~ExtensionDelegate() { |
+ DCHECK(instance); |
+ instance = NULL; |
+} |
+ |
+// static |
+ExtensionDelegate* ExtensionDelegate::Get(content::BrowserContext* context) { |
+ DCHECK(instance); |
+ DCHECK_EQ(context, instance->GetBrowserContext()); |
+ return instance; |
+} |
+ |
+// static |
+void ExtensionDelegate::Shutdown() { |
+ DCHECK(instance); |
+ delete instance; |
+} |
+ |
+// static |
+void ExtensionDelegate::InitExtensionDelegateForShell( |
+ content::BrowserContext* context) { |
+ new ShellExtensionDelegate(context); |
+} |
+ |
+} // namespace athena |