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

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
« no previous file with comments | « chrome/browser/ui/athena/extensions/DEPS ('k') | chrome/browser/ui/extensions/app_launch_params.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f280d551a50d7fba4686e592eab36e0d1a8f0117
--- /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: http://crbug.com/8123 we should not need to set the initial focus
+ // explicitly.
+ content::WebContents* web_contents = activity->GetWebContents();
+ web_contents->SetInitialFocus();
+ return web_contents;
+}
+
+content::WebContents* OpenWebAppTab(const AppLaunchParams& params,
+ const GURL& url) {
+ // There are no tabbed windows in Athena. Open a new window instead.
+ return OpenWebAppWindow(params, url);
+}
« no previous file with comments | « chrome/browser/ui/athena/extensions/DEPS ('k') | chrome/browser/ui/extensions/app_launch_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698