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

Side by Side Diff: athena/content/delegate/app_content_delegate.cc

Issue 477523002: Athena: Adding basic resource management framework (un-/re-loading) of V2 applications (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Forgot two files Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698