| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_ | 5 #ifndef APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_ |
| 6 #define APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_ | 6 #define APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "apps/app_shim/app_shim_handler_mac.h" | 11 #include "apps/app_shim/app_shim_handler_mac.h" |
| 12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 14 | 14 |
| 15 class Profile; | 15 class Profile; |
| 16 | 16 |
| 17 namespace extensions { |
| 18 class Extension; |
| 19 } |
| 20 |
| 17 namespace apps { | 21 namespace apps { |
| 18 | 22 |
| 19 // This app shim handler that handles events for app shims that correspond to an | 23 // This app shim handler that handles events for app shims that correspond to an |
| 20 // extension. | 24 // extension. |
| 21 class ExtensionAppShimHandler : public AppShimHandler, | 25 class ExtensionAppShimHandler : public AppShimHandler, |
| 22 public content::NotificationObserver { | 26 public content::NotificationObserver { |
| 23 public: | 27 public: |
| 24 ExtensionAppShimHandler(); | 28 ExtensionAppShimHandler(); |
| 25 virtual ~ExtensionAppShimHandler(); | 29 virtual ~ExtensionAppShimHandler(); |
| 26 | 30 |
| 27 // AppShimHandler overrides: | 31 // AppShimHandler overrides: |
| 28 virtual bool OnShimLaunch(Host* host) OVERRIDE; | 32 virtual bool OnShimLaunch(Host* host, bool launch_now) OVERRIDE; |
| 29 virtual void OnShimClose(Host* host) OVERRIDE; | 33 virtual void OnShimClose(Host* host) OVERRIDE; |
| 30 virtual void OnShimFocus(Host* host) OVERRIDE; | 34 virtual void OnShimFocus(Host* host) OVERRIDE; |
| 31 | 35 |
| 32 protected: | 36 protected: |
| 33 typedef std::map<std::pair<Profile*, std::string>, AppShimHandler::Host*> | 37 typedef std::map<std::pair<Profile*, std::string>, AppShimHandler::Host*> |
| 34 HostMap; | 38 HostMap; |
| 35 | 39 |
| 36 // Exposed for testing. | 40 // Exposed for testing. |
| 37 HostMap& hosts() { return hosts_; } | 41 HostMap& hosts() { return hosts_; } |
| 38 content::NotificationRegistrar& registrar() { return registrar_; } | 42 content::NotificationRegistrar& registrar() { return registrar_; } |
| 39 | 43 |
| 40 private: | 44 private: |
| 41 virtual bool LaunchApp(Profile* profile, const std::string& app_id); | 45 virtual bool LaunchApp(Profile* profile, |
| 46 const std::string& app_id, |
| 47 bool launch_now); |
| 42 | 48 |
| 43 // Listen to the NOTIFICATION_EXTENSION_HOST_DESTROYED message to detect when | 49 // Listen to the NOTIFICATION_EXTENSION_HOST_DESTROYED message to detect when |
| 44 // an app closes. When that happens, call OnAppClosed on the relevant | 50 // an app closes. When that happens, call OnAppClosed on the relevant |
| 45 // AppShimHandler::Host which causes the app shim process to quit. | 51 // AppShimHandler::Host which causes the app shim process to quit. |
| 46 // The host will call OnShimClose on this. | 52 // The host will call OnShimClose on this. |
| 47 virtual void Observe(int type, | 53 virtual void Observe(int type, |
| 48 const content::NotificationSource& source, | 54 const content::NotificationSource& source, |
| 49 const content::NotificationDetails& details) OVERRIDE; | 55 const content::NotificationDetails& details) OVERRIDE; |
| 50 | 56 |
| 57 void StartShim(Profile* profile, const extensions::Extension* extension); |
| 58 |
| 51 void CloseShim(Profile* profile, const std::string& app_id); | 59 void CloseShim(Profile* profile, const std::string& app_id); |
| 52 | 60 |
| 53 HostMap hosts_; | 61 HostMap hosts_; |
| 54 | 62 |
| 55 content::NotificationRegistrar registrar_; | 63 content::NotificationRegistrar registrar_; |
| 56 }; | 64 }; |
| 57 | 65 |
| 58 } // namespace apps | 66 } // namespace apps |
| 59 | 67 |
| 60 #endif // APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_ | 68 #endif // APPS_APP_SHIM_EXTENSION_APP_SHIM_HANDLER_H_ |
| OLD | NEW |