Chromium Code Reviews| Index: athena/content/delegate/app_content_delegate.cc |
| diff --git a/athena/content/delegate/app_content_delegate.cc b/athena/content/delegate/app_content_delegate.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..313ce9ec9a967db0acef32b57ec84d27d19623ec |
| --- /dev/null |
| +++ b/athena/content/delegate/app_content_delegate.cc |
| @@ -0,0 +1,57 @@ |
| +// 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 "athena/content/public/app_content_delegate.h" |
| + |
| +#include "content/public/browser/render_view_host.h" |
| +#include "content/public/browser/site_instance.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "extensions/browser/api/app_runtime/app_runtime_api.h" |
| +#include "extensions/browser/extension_registry.h" |
| +#include "extensions/common/constants.h" |
| + |
| +namespace athena { |
| + |
|
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)
|
| +bool AppContentDelegate::UnloadApplication( |
| + const std::string& app_id, |
| + content::BrowserContext* browser_context) { |
| + // TODO(skuhne): Use the extension system to unload |
| + // (|ExtensionService::TerminateExtension|) once it becomes available in |
| + // Athena. |
| + return false; |
| +} |
| + |
| +bool AppContentDelegate::RestartApplication( |
| + const std::string& app_id, |
| + content::BrowserContext* browser_context) { |
| + // TODO(skuhne): As soon as the ExtensionSystem can be used, we should use the |
| + // proper commands here for restarting. |
| + const extensions::Extension* extension = |
| + extensions::ExtensionRegistry::Get(browser_context)->GetExtensionById( |
| + app_id, extensions::ExtensionRegistry::EVERYTHING); |
| + DCHECK(extension); |
| + extensions::AppRuntimeEventRouter::DispatchOnLaunchedEvent(browser_context, |
| + extension); |
| + return true; |
| +} |
| + |
| +// Get the extension Id from a given |web_contents|. |
| +std::string AppContentDelegate::GetExtensionID( |
| + content::WebContents* web_contents) { |
| + content::RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); |
| + // This works for both apps and extensions because the site has been |
| + // normalized to the extension URL for hosted apps. |
| + content::SiteInstance* site_instance = render_view_host->GetSiteInstance(); |
| + if (!site_instance) |
| + return std::string(); |
| + |
| + const GURL& site_url = site_instance->GetSiteURL(); |
| + |
| + if (!site_url.SchemeIs(extensions::kExtensionScheme)) |
| + return std::string(); |
| + |
| + return site_url.host(); |
| +} |
| + |
| +} // namespace athena |