Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 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 #ifndef APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_ | |
| 6 #define APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "apps/app_shim/app_shim_handler_mac.h" | |
| 12 #include "content/public/browser/notification_observer.h" | |
| 13 #include "content/public/browser/notification_registrar.h" | |
| 14 | |
| 15 class Profile; | |
| 16 | |
| 17 namespace apps { | |
| 18 | |
| 19 // This app shim handler that handles events for app shims that correspond to an | |
| 20 // extension. | |
| 21 class ExtensionAppShimHandler : public AppShimHandler, | |
| 22 public content::NotificationObserver{ | |
|
tapted
2013/05/23 07:03:11
nit: space before curly
jackhou1
2013/05/24 00:12:27
Done.
| |
| 23 public: | |
| 24 ExtensionAppShimHandler(); | |
| 25 virtual ~ExtensionAppShimHandler(); | |
| 26 | |
| 27 // AppShimHandler overrides: | |
| 28 virtual bool OnShimLaunch(Host* host) OVERRIDE; | |
| 29 virtual void OnShimClose(Host* host) OVERRIDE; | |
| 30 virtual void OnShimFocus(Host* host) OVERRIDE; | |
| 31 | |
| 32 protected: | |
| 33 typedef std::map<std::pair<Profile*, std::string>, AppShimHandler::Host*> | |
| 34 HostMap; | |
| 35 | |
| 36 // Exposed for testing. | |
| 37 HostMap& hosts() { return hosts_; } | |
| 38 content::NotificationRegistrar& registrar() { return registrar_; } | |
| 39 | |
| 40 private: | |
| 41 virtual bool LaunchApp(Profile* profile, const std::string& app_id); | |
| 42 | |
| 43 // Listen to the NOTIFICATION_EXTENSION_HOST_DESTROYED message to detect when | |
| 44 // an app closes. When that happens, call OnAppClosed on the relevant | |
| 45 // AppShimHandler::Host which causes the app shim process to quit. | |
| 46 // The host will call OnShimClose on this. | |
| 47 virtual void Observe(int type, | |
| 48 const content::NotificationSource& source, | |
| 49 const content::NotificationDetails& details) OVERRIDE; | |
| 50 | |
| 51 void CloseShim(Profile* profile, const std::string& app_id); | |
| 52 | |
| 53 HostMap hosts_; | |
| 54 | |
| 55 content::NotificationRegistrar registrar_; | |
| 56 }; | |
| 57 | |
| 58 } // namespace apps | |
| 59 | |
| 60 #endif // APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_ | |
| OLD | NEW |