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

Unified Diff: athena/content/delegate/app_content_control_delegate_impl.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: Addressed 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 side-by-side diff with in-line comments
Download patch
Index: athena/content/delegate/app_content_control_delegate_impl.cc
diff --git a/athena/content/delegate/app_content_control_delegate_impl.cc b/athena/content/delegate/app_content_control_delegate_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0d5cfdf4193c2a88ed3e3189d13b6fdf7e3f2049
--- /dev/null
+++ b/athena/content/delegate/app_content_control_delegate_impl.cc
@@ -0,0 +1,81 @@
+// 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_control_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 {
+
+class AppContentControlDelegateImpl : public AppContentControlDelegate {
+ public:
+ AppContentControlDelegateImpl() {}
+ virtual ~AppContentControlDelegateImpl() {}
+
oshima 2014/08/19 21:22:25 // AppContentControlDelegate: and private:
Mr4D (OOO till 08-26) 2014/08/20 14:34:40 Comment yes, private no. See above.
+ virtual bool UnloadApplication(
+ const std::string& app_id,
+ content::BrowserContext* browser_context) OVERRIDE;
+ virtual bool RestartApplication(
+ const std::string& app_id,
+ content::BrowserContext* browser_context) OVERRIDE;
+ virtual std::string GetApplicationID(
+ content::WebContents* web_contents) OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AppContentControlDelegateImpl);
+};
+
+bool AppContentControlDelegateImpl::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 AppContentControlDelegateImpl::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 AppContentControlDelegateImpl::GetApplicationID(
+ 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();
+}
+
+// static
+AppContentControlDelegate*
+AppContentControlDelegate::CreateAppContentControlDelegate() {
+ return new AppContentControlDelegateImpl;
+}
+
+} // namespace athena

Powered by Google App Engine
This is Rietveld 408576698