Chromium Code Reviews| 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..a38817d219d9e310fb578403bdb0a71a9c51c0dc |
| --- /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{ |
|
tapted
2013/05/23 07:03:11
nit: space before curly
jackhou1
2013/05/24 00:12:27
Done.
|
| + 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_ |