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" | |
8 #include "athena/activity/public/activity_manager.h" | |
7 #include "athena/extensions/chrome/athena_apps_client.h" | 9 #include "athena/extensions/chrome/athena_apps_client.h" |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/strings/utf_string_conversions.h" | |
9 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_util.h" | 13 #include "chrome/browser/extensions/extension_util.h" |
11 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/extensions/application_launch.h" | 15 #include "chrome/browser/ui/extensions/application_launch.h" |
16 #include "chrome/browser/web_applications/web_app.h" | |
13 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 17 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
14 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
15 #include "extensions/browser/extension_system.h" | 19 #include "extensions/browser/extension_system.h" |
16 #include "extensions/common/constants.h" | 20 #include "extensions/common/constants.h" |
17 #include "extensions/common/extension_set.h" | 21 #include "extensions/common/extension_set.h" |
18 #include "extensions/common/extension_urls.h" | 22 #include "extensions/common/extension_urls.h" |
19 #include "net/base/url_util.h" | 23 #include "net/base/url_util.h" |
20 | 24 |
21 namespace athena { | 25 namespace athena { |
22 namespace { | 26 namespace { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 std::string source_value = | 68 std::string source_value = |
65 std::string(extension_urls::kLaunchSourceAppList); | 69 std::string(extension_urls::kLaunchSourceAppList); |
66 // Set an override URL to include the source. | 70 // Set an override URL to include the source. |
67 GURL extension_url = | 71 GURL extension_url = |
68 extensions::AppLaunchInfo::GetFullLaunchURL(extension); | 72 extensions::AppLaunchInfo::GetFullLaunchURL(extension); |
69 params.override_url = net::AppendQueryParameter( | 73 params.override_url = net::AppendQueryParameter( |
70 extension_url, extension_urls::kWebstoreSourceField, source_value); | 74 extension_url, extension_urls::kWebstoreSourceField, source_value); |
71 } | 75 } |
72 params.container = extensions::LAUNCH_CONTAINER_WINDOW; | 76 params.container = extensions::LAUNCH_CONTAINER_WINDOW; |
73 | 77 |
74 OpenApplication(params); | 78 // V2 apps |
79 if (CanLaunchViaEvent(extension)) { | |
80 OpenApplication(params); | |
81 return true; | |
82 } | |
83 LaunchV1App(params, extension); | |
75 return true; | 84 return true; |
76 } | 85 } |
86 | |
77 virtual bool UnloadApp(const std::string& app_id) OVERRIDE { | 87 virtual bool UnloadApp(const std::string& app_id) OVERRIDE { |
78 // TODO(skuhne): Implement using extension service. | 88 // TODO(skuhne): Implement using extension service. |
79 return false; | 89 return false; |
80 } | 90 } |
81 | 91 |
92 void LaunchV1App(const AppLaunchParams& params, | |
93 const extensions::Extension* extension) { | |
94 // TODO(oshima): Just activate if the app is already running. | |
95 const GURL url_input = params.override_url; | |
96 | |
97 DCHECK(!url_input.is_empty() || extension); | |
98 GURL url = UrlForExtension(extension, url_input); | |
99 std::string app_name = extension | |
Jun Mukai
2014/09/04 21:47:12
LaunchApp early-exits if |extension| is NULL, whic
oshima
2014/09/04 22:13:55
You're right. Removed NULL condition.
| |
100 ? extension->name() | |
101 : web_app::GenerateApplicationNameFromURL(url); | |
102 athena::ActivityManager::Get()->AddActivity( | |
103 athena::ActivityFactory::Get()->CreateWebActivity( | |
104 GetBrowserContext(), base::UTF8ToUTF16(app_name), url)); | |
105 } | |
106 | |
82 // ExtensionService for the browser context this is created for. | 107 // ExtensionService for the browser context this is created for. |
83 ExtensionService* extension_service_; | 108 ExtensionService* extension_service_; |
84 | 109 |
85 // Installed extensions. | 110 // Installed extensions. |
86 extensions::ExtensionSet extensions_; | 111 extensions::ExtensionSet extensions_; |
87 | 112 |
88 AthenaAppsClient apps_client_; | 113 AthenaAppsClient apps_client_; |
89 | 114 |
90 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsDelegate); | 115 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsDelegate); |
91 }; | 116 }; |
92 | 117 |
93 } // namespace | 118 } // namespace |
94 | 119 |
95 // static | 120 // static |
96 void ExtensionsDelegate::CreateExtensionsDelegateForChrome( | 121 void ExtensionsDelegate::CreateExtensionsDelegateForChrome( |
97 content::BrowserContext* context) { | 122 content::BrowserContext* context) { |
98 new ChromeExtensionsDelegate(context); | 123 new ChromeExtensionsDelegate(context); |
99 } | 124 } |
100 | 125 |
101 } // namespace athena | 126 } // namespace athena |
OLD | NEW |