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/activity/public/activity_factory.h" | 7 #include "athena/activity/public/activity_factory.h" |
8 #include "athena/activity/public/activity_manager.h" | 8 #include "athena/activity/public/activity_manager.h" |
9 #include "athena/extensions/chrome/athena_apps_client.h" | 9 #include "athena/extensions/chrome/athena_chrome_apps_client.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/extension_util.h" | 13 #include "chrome/browser/extensions/extension_util.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/extensions/application_launch.h" | 15 #include "chrome/browser/ui/extensions/application_launch.h" |
16 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 16 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
17 #include "extensions/browser/extension_registry.h" | 17 #include "extensions/browser/extension_registry.h" |
18 #include "extensions/browser/extension_system.h" | 18 #include "extensions/browser/extension_system.h" |
19 #include "extensions/common/constants.h" | 19 #include "extensions/common/constants.h" |
20 #include "extensions/common/extension_set.h" | 20 #include "extensions/common/extension_set.h" |
21 #include "extensions/common/extension_urls.h" | 21 #include "extensions/common/extension_urls.h" |
22 #include "net/base/url_util.h" | 22 #include "net/base/url_util.h" |
23 | 23 |
24 namespace athena { | 24 namespace athena { |
25 namespace { | 25 namespace { |
26 | 26 |
27 class ChromeExtensionsDelegate : public ExtensionsDelegate { | 27 class ChromeExtensionsDelegate : public ExtensionsDelegate { |
28 public: | 28 public: |
29 explicit ChromeExtensionsDelegate(content::BrowserContext* context) | 29 explicit ChromeExtensionsDelegate(content::BrowserContext* context) |
30 : extension_service_( | 30 : extension_service_( |
31 extensions::ExtensionSystem::Get(context)->extension_service()) { | 31 extensions::ExtensionSystem::Get(context)->extension_service()) { |
32 extensions::AppsClient::Set(&apps_client_); | 32 extensions::AppsClient::Set(&apps_client_); |
33 } | 33 } |
34 | 34 |
35 virtual ~ChromeExtensionsDelegate() {} | 35 virtual ~ChromeExtensionsDelegate() { extensions::AppsClient::Set(NULL); } |
36 | 36 |
37 private: | 37 private: |
38 // ExtensionsDelegate: | 38 // ExtensionsDelegate: |
39 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE { | 39 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE { |
40 return extension_service_->GetBrowserContext(); | 40 return extension_service_->GetBrowserContext(); |
41 } | 41 } |
42 virtual const extensions::ExtensionSet& GetInstalledExtensions() OVERRIDE { | 42 virtual const extensions::ExtensionSet& GetInstalledExtensions() OVERRIDE { |
43 return *extension_service_->extensions(); | 43 return *extension_service_->extensions(); |
44 } | 44 } |
45 virtual bool LaunchApp(const std::string& app_id) OVERRIDE { | 45 virtual bool LaunchApp(const std::string& app_id) OVERRIDE { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 athena::ActivityFactory::Get()->CreateWebActivity( | 99 athena::ActivityFactory::Get()->CreateWebActivity( |
100 GetBrowserContext(), base::UTF8ToUTF16(extension->name()), url)); | 100 GetBrowserContext(), base::UTF8ToUTF16(extension->name()), url)); |
101 } | 101 } |
102 | 102 |
103 // ExtensionService for the browser context this is created for. | 103 // ExtensionService for the browser context this is created for. |
104 ExtensionService* extension_service_; | 104 ExtensionService* extension_service_; |
105 | 105 |
106 // Installed extensions. | 106 // Installed extensions. |
107 extensions::ExtensionSet extensions_; | 107 extensions::ExtensionSet extensions_; |
108 | 108 |
109 AthenaAppsClient apps_client_; | 109 AthenaChromeAppsClient apps_client_; |
110 | 110 |
111 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsDelegate); | 111 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsDelegate); |
112 }; | 112 }; |
113 | 113 |
114 } // namespace | 114 } // namespace |
115 | 115 |
116 // static | 116 // static |
117 void ExtensionsDelegate::CreateExtensionsDelegateForChrome( | 117 void ExtensionsDelegate::CreateExtensionsDelegateForChrome( |
118 content::BrowserContext* context) { | 118 content::BrowserContext* context) { |
119 new ChromeExtensionsDelegate(context); | 119 new ChromeExtensionsDelegate(context); |
120 } | 120 } |
121 | 121 |
122 } // namespace athena | 122 } // namespace athena |
OLD | NEW |