OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/extensions/application_launch_web_app.h" | |
6 | |
7 #include <string> | |
8 | |
9 #include "athena/activity/public/activity.h" | |
10 #include "athena/activity/public/activity_factory.h" | |
11 #include "base/strings/utf_string_conversions.h" | |
12 #include "chrome/browser/profiles/profile.h" | |
13 #include "content/public/browser/web_contents.h" | |
14 #include "extensions/browser/extension_registry.h" | |
15 #include "extensions/common/extension.h" | |
16 | |
17 namespace { | |
18 | |
19 const extensions::Extension* GetExtension(const AppLaunchParams& params) { | |
20 if (params.extension_id.empty()) | |
21 return NULL; | |
22 | |
23 using extensions::ExtensionRegistry; | |
24 ExtensionRegistry* registry = ExtensionRegistry::Get(params.profile); | |
25 return registry->GetExtensionById(params.extension_id, | |
26 ExtensionRegistry::ENABLED | | |
27 ExtensionRegistry::DISABLED | | |
28 ExtensionRegistry::TERMINATED); | |
29 } | |
30 | |
31 } // namespace | |
32 | |
33 content::WebContents* OpenWebAppWindow(const AppLaunchParams& params, | |
34 const GURL& url) { | |
35 const extensions::Extension* extension = GetExtension(params); | |
36 athena::Activity* activity = | |
37 athena::ActivityFactory::Get()->CreateWebActivity( | |
38 params.profile, base::UTF8ToUTF16(extension->name()), url); | |
39 athena::Activity::Show(activity); | |
40 | |
41 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial | |
42 // 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
| |
43 content::WebContents* web_contents = activity->GetWebContents(); | |
44 web_contents->SetInitialFocus(); | |
45 return web_contents; | |
46 } | |
47 | |
48 content::WebContents* OpenWebAppTab(const AppLaunchParams& params, | |
49 const GURL& url) { | |
oshima
2014/10/17 19:49:02
nit: indent
| |
50 // There are no tabbed windows in Athena. Open a new window instead. | |
51 return OpenWebAppWindow(params, url); | |
52 } | |
OLD | NEW |