| 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 | 6 |
| 7 #include "athena/extensions/shell/athena_shell_app_window_client.h" | 7 #include "athena/extensions/shell/athena_shell_app_window_client.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "extensions/browser/extension_registry.h" | 9 #include "extensions/browser/extension_registry.h" |
| 10 #include "extensions/browser/install/extension_install_ui.h" | 10 #include "extensions/browser/install/extension_install_ui.h" |
| 11 #include "extensions/common/extension_set.h" | 11 #include "extensions/common/extension_set.h" |
| 12 #include "extensions/shell/browser/shell_extension_system.h" | 12 #include "extensions/shell/browser/shell_extension_system.h" |
| 13 | 13 |
| 14 namespace athena { | 14 namespace athena { |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 class ShellExtensionsDelegate : public ExtensionsDelegate { | 17 class ShellExtensionsDelegate : public ExtensionsDelegate { |
| 18 public: | 18 public: |
| 19 explicit ShellExtensionsDelegate(content::BrowserContext* context) | 19 explicit ShellExtensionsDelegate(content::BrowserContext* context) |
| 20 : context_(context), | 20 : context_(context), |
| 21 extension_system_(static_cast<extensions::ShellExtensionSystem*>( | 21 extension_system_(static_cast<extensions::ShellExtensionSystem*>( |
| 22 extensions::ExtensionSystem::Get(context))) { | 22 extensions::ExtensionSystem::Get(context))) { |
| 23 extensions::AppWindowClient::Set(&app_window_client_); | 23 extensions::AppWindowClient::Set(&app_window_client_); |
| 24 } | 24 } |
| 25 | 25 |
| 26 virtual ~ShellExtensionsDelegate() { | 26 ~ShellExtensionsDelegate() override { |
| 27 extensions::AppWindowClient::Set(nullptr); | 27 extensions::AppWindowClient::Set(nullptr); |
| 28 } | 28 } |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 // ExtensionsDelegate: | 31 // ExtensionsDelegate: |
| 32 virtual content::BrowserContext* GetBrowserContext() const override { | 32 content::BrowserContext* GetBrowserContext() const override { |
| 33 return context_; | 33 return context_; |
| 34 } | 34 } |
| 35 virtual const extensions::ExtensionSet& GetInstalledExtensions() override { | 35 |
| 36 const extensions::ExtensionSet& GetInstalledExtensions() override { |
| 36 return extensions::ExtensionRegistry::Get(context_)->enabled_extensions(); | 37 return extensions::ExtensionRegistry::Get(context_)->enabled_extensions(); |
| 37 } | 38 } |
| 38 virtual bool LaunchApp(const std::string& app_id) override { | 39 bool LaunchApp(const std::string& app_id) override { |
| 39 extension_system_->LaunchApp(app_id); | 40 extension_system_->LaunchApp(app_id); |
| 40 return true; | 41 return true; |
| 41 } | 42 } |
| 42 | 43 |
| 43 virtual bool UnloadApp(const std::string& app_id) override { return false; } | 44 bool UnloadApp(const std::string& app_id) override { return false; } |
| 44 | 45 |
| 45 virtual scoped_ptr<extensions::ExtensionInstallUI> CreateExtensionInstallUI() | 46 scoped_ptr<extensions::ExtensionInstallUI> CreateExtensionInstallUI() |
| 46 override { | 47 override { |
| 47 return scoped_ptr<extensions::ExtensionInstallUI>(); | 48 return scoped_ptr<extensions::ExtensionInstallUI>(); |
| 48 } | 49 } |
| 49 | 50 |
| 50 content::BrowserContext* context_; | 51 content::BrowserContext* context_; |
| 51 extensions::ShellExtensionSystem* extension_system_; | 52 extensions::ShellExtensionSystem* extension_system_; |
| 52 | 53 |
| 53 AthenaShellAppWindowClient app_window_client_; | 54 AthenaShellAppWindowClient app_window_client_; |
| 54 | 55 |
| 55 DISALLOW_COPY_AND_ASSIGN(ShellExtensionsDelegate); | 56 DISALLOW_COPY_AND_ASSIGN(ShellExtensionsDelegate); |
| 56 }; | 57 }; |
| 57 | 58 |
| 58 } // namespace | 59 } // namespace |
| 59 | 60 |
| 60 // static | 61 // static |
| 61 void ExtensionsDelegate::CreateExtensionsDelegate( | 62 void ExtensionsDelegate::CreateExtensionsDelegate( |
| 62 content::BrowserContext* context) { | 63 content::BrowserContext* context) { |
| 63 new ShellExtensionsDelegate(context); | 64 new ShellExtensionsDelegate(context); |
| 64 } | 65 } |
| 65 | 66 |
| 66 } // namespace athena | 67 } // namespace athena |
| OLD | NEW |