| 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/extensions/chrome/athena_chrome_app_window_client.h" | 7 #include "athena/extensions/chrome/athena_chrome_app_window_client.h" |
| 9 #include "athena/extensions/chrome/athena_extension_install_ui.h" | 8 #include "athena/extensions/chrome/athena_extension_install_ui.h" |
| 10 #include "base/macros.h" | 9 #include "base/macros.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/browser/extensions/extension_util.h" | 12 #include "chrome/browser/extensions/extension_util.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/extensions/application_launch.h" | 14 #include "chrome/browser/ui/extensions/application_launch.h" |
| 16 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 15 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 17 #include "extensions/browser/extension_registry.h" | 16 #include "extensions/browser/extension_registry.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 std::string source_value = | 68 std::string source_value = |
| 70 std::string(extension_urls::kLaunchSourceAppList); | 69 std::string(extension_urls::kLaunchSourceAppList); |
| 71 // Set an override URL to include the source. | 70 // Set an override URL to include the source. |
| 72 GURL extension_url = | 71 GURL extension_url = |
| 73 extensions::AppLaunchInfo::GetFullLaunchURL(extension); | 72 extensions::AppLaunchInfo::GetFullLaunchURL(extension); |
| 74 params.override_url = net::AppendQueryParameter( | 73 params.override_url = net::AppendQueryParameter( |
| 75 extension_url, extension_urls::kWebstoreSourceField, source_value); | 74 extension_url, extension_urls::kWebstoreSourceField, source_value); |
| 76 } | 75 } |
| 77 params.container = extensions::LAUNCH_CONTAINER_WINDOW; | 76 params.container = extensions::LAUNCH_CONTAINER_WINDOW; |
| 78 | 77 |
| 79 // V2 apps | 78 OpenApplication(params); |
| 80 if (CanLaunchViaEvent(extension)) { | |
| 81 OpenApplication(params); | |
| 82 return true; | |
| 83 } | |
| 84 LaunchV1App(params, extension); | |
| 85 return true; | 79 return true; |
| 86 } | 80 } |
| 87 | 81 |
| 88 virtual bool UnloadApp(const std::string& app_id) override { | 82 virtual bool UnloadApp(const std::string& app_id) override { |
| 89 // TODO(skuhne): Implement using extension service. | 83 // TODO(skuhne): Implement using extension service. |
| 90 return false; | 84 return false; |
| 91 } | 85 } |
| 92 | 86 |
| 93 virtual scoped_ptr<extensions::ExtensionInstallUI> CreateExtensionInstallUI() | 87 virtual scoped_ptr<extensions::ExtensionInstallUI> CreateExtensionInstallUI() |
| 94 override { | 88 override { |
| 95 return scoped_ptr<extensions::ExtensionInstallUI>( | 89 return scoped_ptr<extensions::ExtensionInstallUI>( |
| 96 new AthenaExtensionInstallUI()); | 90 new AthenaExtensionInstallUI()); |
| 97 } | 91 } |
| 98 | 92 |
| 99 void LaunchV1App(const AppLaunchParams& params, | |
| 100 const extensions::Extension* extension) { | |
| 101 // TODO(oshima): Just activate if the app is already running. | |
| 102 const GURL url_input = params.override_url; | |
| 103 | |
| 104 DCHECK(!url_input.is_empty() || extension); | |
| 105 GURL url = UrlForExtension(extension, url_input); | |
| 106 athena::ActivityFactory::Get()->CreateWebActivity( | |
| 107 GetBrowserContext(), base::UTF8ToUTF16(extension->name()), url); | |
| 108 } | |
| 109 | |
| 110 // ExtensionService for the browser context this is created for. | 93 // ExtensionService for the browser context this is created for. |
| 111 ExtensionService* extension_service_; | 94 ExtensionService* extension_service_; |
| 112 | 95 |
| 113 // Installed extensions. | 96 // Installed extensions. |
| 114 extensions::ExtensionSet extensions_; | 97 extensions::ExtensionSet extensions_; |
| 115 | 98 |
| 116 AthenaChromeAppWindowClient app_window_client_; | 99 AthenaChromeAppWindowClient app_window_client_; |
| 117 | 100 |
| 118 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsDelegate); | 101 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsDelegate); |
| 119 }; | 102 }; |
| 120 | 103 |
| 121 } // namespace | 104 } // namespace |
| 122 | 105 |
| 123 // static | 106 // static |
| 124 void ExtensionsDelegate::CreateExtensionsDelegate( | 107 void ExtensionsDelegate::CreateExtensionsDelegate( |
| 125 content::BrowserContext* context) { | 108 content::BrowserContext* context) { |
| 126 new ChromeExtensionsDelegate(context); | 109 new ChromeExtensionsDelegate(context); |
| 127 } | 110 } |
| 128 | 111 |
| 129 } // namespace athena | 112 } // namespace athena |
| OLD | NEW |