Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Unified Diff: athena/extensions/chrome/extensions_delegate_impl.cc

Issue 514293003: Run athena on chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments, rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « athena/extensions/chrome/athena_apps_client.cc ('k') | athena/extensions/public/extensions_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/extensions/chrome/extensions_delegate_impl.cc
diff --git a/athena/extensions/chrome/extensions_delegate_impl.cc b/athena/extensions/chrome/extensions_delegate_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9313862937ece4f638fb83c8d9ab8d480858a724
--- /dev/null
+++ b/athena/extensions/chrome/extensions_delegate_impl.cc
@@ -0,0 +1,100 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "athena/extensions/public/extensions_delegate.h"
+
+#include "athena/extensions/chrome/athena_apps_client.h"
+#include "base/macros.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_util.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/extensions/application_launch.h"
+#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/extension_system.h"
+#include "extensions/common/extension_set.h"
+#include "extensions/common/extension_urls.h"
+#include "net/base/url_util.h"
+
+namespace athena {
+namespace {
+
+class ChromeExtensionsDelegate : public ExtensionsDelegate {
+ public:
+ explicit ChromeExtensionsDelegate(content::BrowserContext* context)
+ : extension_service_(
+ extensions::ExtensionSystem::Get(context)->extension_service()) {
+ extensions::AppsClient::Set(&apps_client_);
+ }
+
+ virtual ~ChromeExtensionsDelegate() {}
+
+ private:
+ // ExtensionsDelegate:
+ virtual content::BrowserContext* GetBrowserContext() const OVERRIDE {
+ return extension_service_->GetBrowserContext();
+ }
+ virtual const extensions::ExtensionSet& GetInstalledExtensions() OVERRIDE {
+ return *extension_service_->extensions();
+ }
+ virtual bool LaunchApp(const std::string& app_id) OVERRIDE {
+ // Check Running apps
+ content::BrowserContext* context = GetBrowserContext();
+ const extensions::Extension* extension =
+ extensions::ExtensionRegistry::Get(context)->GetExtensionById(
+ app_id, extensions::ExtensionRegistry::EVERYTHING);
+ DCHECK(extension);
+ if (!extension)
+ return false;
+
+ // TODO(oshima): Support installation/enabling process.
+ if (!extensions::util::IsAppLaunchableWithoutEnabling(app_id, context))
+ return false;
+
+ int event_flags = 0;
+ AppLaunchParams params(Profile::FromBrowserContext(context),
+ extension,
+ event_flags,
+ chrome::HOST_DESKTOP_TYPE_ASH);
+ // TODO(oshima): rename HOST_DESTOP_TYPE_ASH to non native desktop.
+
+ if (app_id == extension_misc::kWebStoreAppId) {
+ std::string source_value =
+ std::string(extension_urls::kLaunchSourceAppList);
+ // Set an override URL to include the source.
+ GURL extension_url =
+ extensions::AppLaunchInfo::GetFullLaunchURL(extension);
+ params.override_url = net::AppendQueryParameter(
+ extension_url, extension_urls::kWebstoreSourceField, source_value);
+ }
+ params.container = extensions::LAUNCH_CONTAINER_WINDOW;
+
+ OpenApplication(params);
+ return true;
+ }
+ virtual bool UnloadApp(const std::string& app_id) OVERRIDE {
+ // TODO(skuhne): Implement using extension service.
+ return false;
+ }
+
+ // ExtensionService for the browser context this is created for.
+ ExtensionService* extension_service_;
+
+ // Installed extensions.
+ extensions::ExtensionSet extensions_;
+
+ AthenaAppsClient apps_client_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsDelegate);
+};
+
+} // namespace
+
+// static
+void ExtensionsDelegate::CreateExtensionsDelegateForChrome(
+ content::BrowserContext* context) {
+ new ChromeExtensionsDelegate(context);
+}
+
+} // namespace athena
« no previous file with comments | « athena/extensions/chrome/athena_apps_client.cc ('k') | athena/extensions/public/extensions_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698