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

Unified Diff: chrome/browser/ui/athena/extensions/application_launch_web_app_athena.cc

Issue 635233008: Make management.launchApp() work for hosted apps on Athena (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webstore_dialogs_athena
Patch Set: Created 6 years, 2 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
Index: chrome/browser/ui/athena/extensions/application_launch_web_app_athena.cc
diff --git a/chrome/browser/ui/athena/extensions/application_launch_web_app_athena.cc b/chrome/browser/ui/athena/extensions/application_launch_web_app_athena.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ce37f08ae0035194770f7e3d2749f9f4642e0160
--- /dev/null
+++ b/chrome/browser/ui/athena/extensions/application_launch_web_app_athena.cc
@@ -0,0 +1,52 @@
+// 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 "chrome/browser/ui/extensions/application_launch_web_app.h"
+
+#include <string>
+
+#include "athena/activity/public/activity.h"
+#include "athena/activity/public/activity_factory.h"
+#include "base/strings/utf_string_conversions.h"
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/web_contents.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/common/extension.h"
+
+namespace {
+
+const extensions::Extension* GetExtension(const AppLaunchParams& params) {
+ if (params.extension_id.empty())
+ return NULL;
+
+ using extensions::ExtensionRegistry;
+ ExtensionRegistry* registry = ExtensionRegistry::Get(params.profile);
+ return registry->GetExtensionById(params.extension_id,
+ ExtensionRegistry::ENABLED |
+ ExtensionRegistry::DISABLED |
+ ExtensionRegistry::TERMINATED);
+}
+
+} // namespace
+
+content::WebContents* OpenWebAppWindow(const AppLaunchParams& params,
+ const GURL& url) {
+ const extensions::Extension* extension = GetExtension(params);
+ athena::Activity* activity =
+ athena::ActivityFactory::Get()->CreateWebActivity(
+ params.profile, base::UTF8ToUTF16(extension->name()), url);
+ athena::Activity::Show(activity);
+
+ // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial
+ // focus explicitly.
oshima 2014/10/17 19:49:02 just curious. is this comment still valid?
pkotwicz 2014/10/20 19:37:43 I am not sure if the comment is still valid. I che
+ content::WebContents* web_contents = activity->GetWebContents();
+ web_contents->SetInitialFocus();
+ return web_contents;
+}
+
+content::WebContents* OpenWebAppTab(const AppLaunchParams& params,
+ const GURL& url) {
oshima 2014/10/17 19:49:02 nit: indent
+ // There are no tabbed windows in Athena. Open a new window instead.
+ return OpenWebAppWindow(params, url);
+}

Powered by Google App Engine
This is Rietveld 408576698