| 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 ExtensionsDelegate* instance = NULL; | |
| 14 | |
| 15 class ShellExtensionsDelegate : public ExtensionsDelegate { | 13 class ShellExtensionsDelegate : public ExtensionsDelegate { |
| 16 public: | 14 public: |
| 17 explicit ShellExtensionsDelegate(content::BrowserContext* context) | 15 explicit ShellExtensionsDelegate(content::BrowserContext* context) |
| 18 : context_(context), | 16 : context_(context), |
| 19 extension_system_(static_cast<extensions::ShellExtensionSystem*>( | 17 extension_system_(static_cast<extensions::ShellExtensionSystem*>( |
| 20 extensions::ExtensionSystem::Get(context))) {} | 18 extensions::ExtensionSystem::Get(context))) {} |
| 21 | 19 |
| 22 virtual ~ShellExtensionsDelegate() {} | 20 virtual ~ShellExtensionsDelegate() {} |
| 23 | 21 |
| 24 private: | 22 private: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 38 | 36 |
| 39 content::BrowserContext* context_; | 37 content::BrowserContext* context_; |
| 40 extensions::ShellExtensionSystem* extension_system_; | 38 extensions::ShellExtensionSystem* extension_system_; |
| 41 extensions::ExtensionSet shell_extensions_; | 39 extensions::ExtensionSet shell_extensions_; |
| 42 | 40 |
| 43 DISALLOW_COPY_AND_ASSIGN(ShellExtensionsDelegate); | 41 DISALLOW_COPY_AND_ASSIGN(ShellExtensionsDelegate); |
| 44 }; | 42 }; |
| 45 | 43 |
| 46 } // namespace | 44 } // namespace |
| 47 | 45 |
| 48 ExtensionsDelegate::ExtensionsDelegate() { | |
| 49 DCHECK(!instance); | |
| 50 instance = this; | |
| 51 } | |
| 52 | |
| 53 ExtensionsDelegate::~ExtensionsDelegate() { | |
| 54 DCHECK(instance); | |
| 55 instance = NULL; | |
| 56 } | |
| 57 | |
| 58 // static | |
| 59 ExtensionsDelegate* ExtensionsDelegate::Get(content::BrowserContext* context) { | |
| 60 DCHECK(instance); | |
| 61 DCHECK_EQ(context, instance->GetBrowserContext()); | |
| 62 return instance; | |
| 63 } | |
| 64 | |
| 65 // static | 46 // static |
| 66 void ExtensionsDelegate::CreateExtensionsDelegateForShell( | 47 void ExtensionsDelegate::CreateExtensionsDelegateForShell( |
| 67 content::BrowserContext* context) { | 48 content::BrowserContext* context) { |
| 68 new ShellExtensionsDelegate(context); | 49 new ShellExtensionsDelegate(context); |
| 69 } | 50 } |
| 70 | 51 |
| 71 // static | |
| 72 void ExtensionsDelegate::Shutdown() { | |
| 73 DCHECK(instance); | |
| 74 delete instance; | |
| 75 } | |
| 76 | |
| 77 } // namespace athena | 52 } // namespace athena |
| OLD | NEW |