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 "athena/content/public/app_content_delegate.h" | |
6 | |
7 #include "content/public/browser/render_view_host.h" | |
8 #include "content/public/browser/site_instance.h" | |
9 #include "content/public/browser/web_contents.h" | |
10 #include "extensions/browser/api/app_runtime/app_runtime_api.h" | |
11 #include "extensions/browser/extension_registry.h" | |
12 #include "extensions/common/constants.h" | |
13 | |
14 namespace athena { | |
15 | |
oshima
2014/08/18 23:14:02
How about separating this as impl class (AppConten
Mr4D (OOO till 08-26)
2014/08/20 14:34:39
Done. (earlier already)
| |
16 bool AppContentDelegate::UnloadApplication( | |
17 const std::string& app_id, | |
18 content::BrowserContext* browser_context) { | |
19 // TODO(skuhne): Use the extension system to unload | |
20 // (|ExtensionService::TerminateExtension|) once it becomes available in | |
21 // Athena. | |
22 return false; | |
23 } | |
24 | |
25 bool AppContentDelegate::RestartApplication( | |
26 const std::string& app_id, | |
27 content::BrowserContext* browser_context) { | |
28 // TODO(skuhne): As soon as the ExtensionSystem can be used, we should use the | |
29 // proper commands here for restarting. | |
30 const extensions::Extension* extension = | |
31 extensions::ExtensionRegistry::Get(browser_context)->GetExtensionById( | |
32 app_id, extensions::ExtensionRegistry::EVERYTHING); | |
33 DCHECK(extension); | |
34 extensions::AppRuntimeEventRouter::DispatchOnLaunchedEvent(browser_context, | |
35 extension); | |
36 return true; | |
37 } | |
38 | |
39 // Get the extension Id from a given |web_contents|. | |
40 std::string AppContentDelegate::GetExtensionID( | |
41 content::WebContents* web_contents) { | |
42 content::RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); | |
43 // This works for both apps and extensions because the site has been | |
44 // normalized to the extension URL for hosted apps. | |
45 content::SiteInstance* site_instance = render_view_host->GetSiteInstance(); | |
46 if (!site_instance) | |
47 return std::string(); | |
48 | |
49 const GURL& site_url = site_instance->GetSiteURL(); | |
50 | |
51 if (!site_url.SchemeIs(extensions::kExtensionScheme)) | |
52 return std::string(); | |
53 | |
54 return site_url.host(); | |
55 } | |
56 | |
57 } // namespace athena | |
OLD | NEW |