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_chrome_apps_client.h" | 9 #include "athena/extensions/chrome/athena_chrome_app_window_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::AppWindowClient::Set(&app_window_client_); |
33 } | 33 } |
34 | 34 |
35 virtual ~ChromeExtensionsDelegate() { extensions::AppsClient::Set(NULL); } | 35 virtual ~ChromeExtensionsDelegate() { |
| 36 extensions::AppWindowClient::Set(NULL); |
| 37 } |
36 | 38 |
37 private: | 39 private: |
38 // ExtensionsDelegate: | 40 // ExtensionsDelegate: |
39 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE { | 41 virtual content::BrowserContext* GetBrowserContext() const OVERRIDE { |
40 return extension_service_->GetBrowserContext(); | 42 return extension_service_->GetBrowserContext(); |
41 } | 43 } |
42 virtual const extensions::ExtensionSet& GetInstalledExtensions() OVERRIDE { | 44 virtual const extensions::ExtensionSet& GetInstalledExtensions() OVERRIDE { |
43 return *extension_service_->extensions(); | 45 return *extension_service_->extensions(); |
44 } | 46 } |
45 virtual bool LaunchApp(const std::string& app_id) OVERRIDE { | 47 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( | 101 athena::ActivityFactory::Get()->CreateWebActivity( |
100 GetBrowserContext(), base::UTF8ToUTF16(extension->name()), url)); | 102 GetBrowserContext(), base::UTF8ToUTF16(extension->name()), url)); |
101 } | 103 } |
102 | 104 |
103 // ExtensionService for the browser context this is created for. | 105 // ExtensionService for the browser context this is created for. |
104 ExtensionService* extension_service_; | 106 ExtensionService* extension_service_; |
105 | 107 |
106 // Installed extensions. | 108 // Installed extensions. |
107 extensions::ExtensionSet extensions_; | 109 extensions::ExtensionSet extensions_; |
108 | 110 |
109 AthenaChromeAppsClient apps_client_; | 111 AthenaChromeAppWindowClient app_window_client_; |
110 | 112 |
111 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsDelegate); | 113 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsDelegate); |
112 }; | 114 }; |
113 | 115 |
114 } // namespace | 116 } // namespace |
115 | 117 |
116 // static | 118 // static |
117 void ExtensionsDelegate::CreateExtensionsDelegateForChrome( | 119 void ExtensionsDelegate::CreateExtensionsDelegateForChrome( |
118 content::BrowserContext* context) { | 120 content::BrowserContext* context) { |
119 new ChromeExtensionsDelegate(context); | 121 new ChromeExtensionsDelegate(context); |
120 } | 122 } |
121 | 123 |
122 } // namespace athena | 124 } // namespace athena |
OLD | NEW |