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