| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/extensions/public/extensions_delegate.h" | 5 #include "athena/extensions/public/extensions_delegate.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "extensions/common/extension_set.h" | 7 #include "extensions/common/extension_set.h" |
| 8 #include "extensions/shell/browser/shell_extension_system.h" | 8 #include "extensions/shell/browser/shell_extension_system.h" |
| 9 | 9 |
| 10 namespace athena { | 10 namespace athena { |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 class ShellExtensionsDelegate : public ExtensionsDelegate { | 13 class ShellExtensionsDelegate : public ExtensionsDelegate { |
| 14 public: | 14 public: |
| 15 explicit ShellExtensionsDelegate(content::BrowserContext* context) | 15 explicit ShellExtensionsDelegate(content::BrowserContext* context) |
| 16 : context_(context), | 16 : context_(context), |
| 17 extension_system_(static_cast<extensions::ShellExtensionSystem*>( | 17 extension_system_(static_cast<extensions::ShellExtensionSystem*>( |
| 18 extensions::ExtensionSystem::Get(context))) {} | 18 extensions::ExtensionSystem::Get(context))) {} |
| 19 | 19 |
| 20 virtual ~ShellExtensionsDelegate() {} | 20 virtual ~ShellExtensionsDelegate() {} |
| 21 | 21 |
| 22 private: | 22 private: |
| 23 // ExtensionsDelegate: | 23 // ExtensionsDelegate: |
| 24 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE { | 24 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE { |
| 25 return context_; | 25 return context_; |
| 26 } | 26 } |
| 27 virtual const extensions::ExtensionSet& GetInstalledExtensions() OVERRIDE { | 27 virtual const extensions::ExtensionSet& GetInstalledExtensions() OVERRIDE { |
| 28 shell_extensions_.Clear(); | 28 shell_extensions_.Clear(); |
| 29 if (extension_system_->extension()) | 29 if (extension_system_->extension().get()) |
| 30 shell_extensions_.Insert(extension_system_->extension()); | 30 shell_extensions_.Insert(extension_system_->extension()); |
| 31 return shell_extensions_; | 31 return shell_extensions_; |
| 32 } | 32 } |
| 33 virtual bool LaunchApp(const std::string& app_id) OVERRIDE { | 33 virtual bool LaunchApp(const std::string& app_id) OVERRIDE { |
| 34 extension_system_->LaunchApp(); | 34 extension_system_->LaunchApp(); |
| 35 return true; | 35 return true; |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual bool UnloadApp(const std::string& app_id) OVERRIDE { return false; } | 38 virtual bool UnloadApp(const std::string& app_id) OVERRIDE { return false; } |
| 39 | 39 |
| 40 content::BrowserContext* context_; | 40 content::BrowserContext* context_; |
| 41 extensions::ShellExtensionSystem* extension_system_; | 41 extensions::ShellExtensionSystem* extension_system_; |
| 42 extensions::ExtensionSet shell_extensions_; | 42 extensions::ExtensionSet shell_extensions_; |
| 43 | 43 |
| 44 DISALLOW_COPY_AND_ASSIGN(ShellExtensionsDelegate); | 44 DISALLOW_COPY_AND_ASSIGN(ShellExtensionsDelegate); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 } // namespace | 47 } // namespace |
| 48 | 48 |
| 49 // static | 49 // static |
| 50 void ExtensionsDelegate::CreateExtensionsDelegateForShell( | 50 void ExtensionsDelegate::CreateExtensionsDelegateForShell( |
| 51 content::BrowserContext* context) { | 51 content::BrowserContext* context) { |
| 52 new ShellExtensionsDelegate(context); | 52 new ShellExtensionsDelegate(context); |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace athena | 55 } // namespace athena |
| OLD | NEW |