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

Unified Diff: apps/app_shim/extension_app_shim_handler_mac.h

Issue 15269003: Refactor extension handling code from AppShimHost into ExtensionAppShimHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase Created 7 years, 7 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
« no previous file with comments | « apps/app_shim/app_shim_host_manager_mac.mm ('k') | apps/app_shim/extension_app_shim_handler_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/app_shim/extension_app_shim_handler_mac.h
diff --git a/apps/app_shim/extension_app_shim_handler_mac.h b/apps/app_shim/extension_app_shim_handler_mac.h
new file mode 100644
index 0000000000000000000000000000000000000000..ea9a8c7eeea8eb945dd11429f242b006dd21777b
--- /dev/null
+++ b/apps/app_shim/extension_app_shim_handler_mac.h
@@ -0,0 +1,60 @@
+// Copyright 2013 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.
+
+#ifndef APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_
+#define APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_
+
+#include <map>
+#include <string>
+
+#include "apps/app_shim/app_shim_handler_mac.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+class Profile;
+
+namespace apps {
+
+// This app shim handler that handles events for app shims that correspond to an
+// extension.
+class ExtensionAppShimHandler : public AppShimHandler,
+ public content::NotificationObserver {
+ public:
+ ExtensionAppShimHandler();
+ virtual ~ExtensionAppShimHandler();
+
+ // AppShimHandler overrides:
+ virtual bool OnShimLaunch(Host* host) OVERRIDE;
+ virtual void OnShimClose(Host* host) OVERRIDE;
+ virtual void OnShimFocus(Host* host) OVERRIDE;
+
+ protected:
+ typedef std::map<std::pair<Profile*, std::string>, AppShimHandler::Host*>
+ HostMap;
+
+ // Exposed for testing.
+ HostMap& hosts() { return hosts_; }
+ content::NotificationRegistrar& registrar() { return registrar_; }
+
+ private:
+ virtual bool LaunchApp(Profile* profile, const std::string& app_id);
+
+ // Listen to the NOTIFICATION_EXTENSION_HOST_DESTROYED message to detect when
+ // an app closes. When that happens, call OnAppClosed on the relevant
+ // AppShimHandler::Host which causes the app shim process to quit.
+ // The host will call OnShimClose on this.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ void CloseShim(Profile* profile, const std::string& app_id);
+
+ HostMap hosts_;
+
+ content::NotificationRegistrar registrar_;
+};
+
+} // namespace apps
+
+#endif // APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_
« no previous file with comments | « apps/app_shim/app_shim_host_manager_mac.mm ('k') | apps/app_shim/extension_app_shim_handler_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698