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_apps_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 apps_client_(context) { | 21 app_window_client_(context) { |
22 extensions::AppsClient::Set(&apps_client_); | 22 extensions::AppWindowClient::Set(&app_window_client_); |
23 } | 23 } |
24 | 24 |
25 virtual ~ShellExtensionsDelegate() { extensions::AppsClient::Set(NULL); } | 25 virtual ~ShellExtensionsDelegate() { extensions::AppWindowClient::Set(NULL); } |
26 | 26 |
27 private: | 27 private: |
28 // ExtensionsDelegate: | 28 // ExtensionsDelegate: |
29 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE { | 29 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE { |
30 return context_; | 30 return context_; |
31 } | 31 } |
32 virtual const extensions::ExtensionSet& GetInstalledExtensions() OVERRIDE { | 32 virtual const extensions::ExtensionSet& GetInstalledExtensions() OVERRIDE { |
33 shell_extensions_.Clear(); | 33 shell_extensions_.Clear(); |
34 if (extension_system_->extension().get()) | 34 if (extension_system_->extension().get()) |
35 shell_extensions_.Insert(extension_system_->extension()); | 35 shell_extensions_.Insert(extension_system_->extension()); |
36 return shell_extensions_; | 36 return shell_extensions_; |
37 } | 37 } |
38 virtual bool LaunchApp(const std::string& app_id) OVERRIDE { | 38 virtual bool LaunchApp(const std::string& app_id) OVERRIDE { |
39 extension_system_->LaunchApp(); | 39 extension_system_->LaunchApp(); |
40 return true; | 40 return true; |
41 } | 41 } |
42 | 42 |
43 virtual bool UnloadApp(const std::string& app_id) OVERRIDE { return false; } | 43 virtual bool UnloadApp(const std::string& app_id) OVERRIDE { return false; } |
44 | 44 |
45 content::BrowserContext* context_; | 45 content::BrowserContext* context_; |
46 extensions::ShellExtensionSystem* extension_system_; | 46 extensions::ShellExtensionSystem* extension_system_; |
47 extensions::ExtensionSet shell_extensions_; | 47 extensions::ExtensionSet shell_extensions_; |
48 | 48 |
49 AthenaShellAppsClient apps_client_; | 49 AthenaShellAppWindowClient app_window_client_; |
50 | 50 |
51 DISALLOW_COPY_AND_ASSIGN(ShellExtensionsDelegate); | 51 DISALLOW_COPY_AND_ASSIGN(ShellExtensionsDelegate); |
52 }; | 52 }; |
53 | 53 |
54 } // namespace | 54 } // namespace |
55 | 55 |
56 // static | 56 // static |
57 void ExtensionsDelegate::CreateExtensionsDelegateForShell( | 57 void ExtensionsDelegate::CreateExtensionsDelegateForShell( |
58 content::BrowserContext* context) { | 58 content::BrowserContext* context) { |
59 new ShellExtensionsDelegate(context); | 59 new ShellExtensionsDelegate(context); |
60 } | 60 } |
61 | 61 |
62 } // namespace athena | 62 } // namespace athena |
OLD | NEW |