| 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/chrome/athena_chrome_app_window_client.h" | 7 #include "athena/extensions/chrome/athena_chrome_app_window_client.h" |
| 8 #include "athena/extensions/chrome/athena_extension_install_ui.h" | 8 #include "athena/extensions/chrome/athena_extension_install_ui.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 class ChromeExtensionsDelegate : public ExtensionsDelegate { | 26 class ChromeExtensionsDelegate : public ExtensionsDelegate { |
| 27 public: | 27 public: |
| 28 explicit ChromeExtensionsDelegate(content::BrowserContext* context) | 28 explicit ChromeExtensionsDelegate(content::BrowserContext* context) |
| 29 : extension_service_( | 29 : extension_service_( |
| 30 extensions::ExtensionSystem::Get(context)->extension_service()) { | 30 extensions::ExtensionSystem::Get(context)->extension_service()) { |
| 31 extensions::AppWindowClient::Set(&app_window_client_); | 31 extensions::AppWindowClient::Set(&app_window_client_); |
| 32 } | 32 } |
| 33 | 33 |
| 34 virtual ~ChromeExtensionsDelegate() { | 34 ~ChromeExtensionsDelegate() override { |
| 35 extensions::AppWindowClient::Set(nullptr); | 35 extensions::AppWindowClient::Set(nullptr); |
| 36 } | 36 } |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 // ExtensionsDelegate: | 39 // ExtensionsDelegate: |
| 40 virtual content::BrowserContext* GetBrowserContext() const override { | 40 content::BrowserContext* GetBrowserContext() const override { |
| 41 return extension_service_->GetBrowserContext(); | 41 return extension_service_->GetBrowserContext(); |
| 42 } | 42 } |
| 43 virtual const extensions::ExtensionSet& GetInstalledExtensions() override { | 43 const extensions::ExtensionSet& GetInstalledExtensions() override { |
| 44 return *extension_service_->extensions(); | 44 return *extension_service_->extensions(); |
| 45 } | 45 } |
| 46 virtual bool LaunchApp(const std::string& app_id) override { | 46 bool LaunchApp(const std::string& app_id) override { |
| 47 // Check Running apps | 47 // Check Running apps |
| 48 content::BrowserContext* context = GetBrowserContext(); | 48 content::BrowserContext* context = GetBrowserContext(); |
| 49 const extensions::Extension* extension = | 49 const extensions::Extension* extension = |
| 50 extensions::ExtensionRegistry::Get(context)->GetExtensionById( | 50 extensions::ExtensionRegistry::Get(context)->GetExtensionById( |
| 51 app_id, extensions::ExtensionRegistry::EVERYTHING); | 51 app_id, extensions::ExtensionRegistry::EVERYTHING); |
| 52 DCHECK(extension); | 52 DCHECK(extension); |
| 53 if (!extension) | 53 if (!extension) |
| 54 return false; | 54 return false; |
| 55 | 55 |
| 56 // TODO(oshima): Support installation/enabling process. | 56 // TODO(oshima): Support installation/enabling process. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 72 extensions::AppLaunchInfo::GetFullLaunchURL(extension); | 72 extensions::AppLaunchInfo::GetFullLaunchURL(extension); |
| 73 params.override_url = net::AppendQueryParameter( | 73 params.override_url = net::AppendQueryParameter( |
| 74 extension_url, extension_urls::kWebstoreSourceField, source_value); | 74 extension_url, extension_urls::kWebstoreSourceField, source_value); |
| 75 } | 75 } |
| 76 params.container = extensions::LAUNCH_CONTAINER_WINDOW; | 76 params.container = extensions::LAUNCH_CONTAINER_WINDOW; |
| 77 | 77 |
| 78 OpenApplication(params); | 78 OpenApplication(params); |
| 79 return true; | 79 return true; |
| 80 } | 80 } |
| 81 | 81 |
| 82 virtual bool UnloadApp(const std::string& app_id) override { | 82 bool UnloadApp(const std::string& app_id) override { |
| 83 // TODO(skuhne): Implement using extension service. | 83 // TODO(skuhne): Implement using extension service. |
| 84 return false; | 84 return false; |
| 85 } | 85 } |
| 86 | 86 |
| 87 virtual scoped_ptr<extensions::ExtensionInstallUI> CreateExtensionInstallUI() | 87 scoped_ptr<extensions::ExtensionInstallUI> CreateExtensionInstallUI() |
| 88 override { | 88 override { |
| 89 return scoped_ptr<extensions::ExtensionInstallUI>( | 89 return scoped_ptr<extensions::ExtensionInstallUI>( |
| 90 new AthenaExtensionInstallUI()); | 90 new AthenaExtensionInstallUI()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 // ExtensionService for the browser context this is created for. | 93 // ExtensionService for the browser context this is created for. |
| 94 ExtensionService* extension_service_; | 94 ExtensionService* extension_service_; |
| 95 | 95 |
| 96 // Installed extensions. | 96 // Installed extensions. |
| 97 extensions::ExtensionSet extensions_; | 97 extensions::ExtensionSet extensions_; |
| 98 | 98 |
| 99 AthenaChromeAppWindowClient app_window_client_; | 99 AthenaChromeAppWindowClient app_window_client_; |
| 100 | 100 |
| 101 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsDelegate); | 101 DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsDelegate); |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 } // namespace | 104 } // namespace |
| 105 | 105 |
| 106 // static | 106 // static |
| 107 void ExtensionsDelegate::CreateExtensionsDelegate( | 107 void ExtensionsDelegate::CreateExtensionsDelegate( |
| 108 content::BrowserContext* context) { | 108 content::BrowserContext* context) { |
| 109 new ChromeExtensionsDelegate(context); | 109 new ChromeExtensionsDelegate(context); |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace athena | 112 } // namespace athena |
| OLD | NEW |