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