Chromium Code Reviews| 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_APP_SHIM_HANDLER_MAC_H_ | 5 #ifndef APPS_APP_SHIM_APP_SHIM_HANDLER_MAC_H_ |
| 6 #define APPS_APP_SHIM_APP_SHIM_HANDLER_MAC_H_ | 6 #define APPS_APP_SHIM_APP_SHIM_HANDLER_MAC_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 class Profile; | |
| 11 | |
| 10 namespace apps { | 12 namespace apps { |
| 11 | 13 |
| 12 // Registrar, and interface for services that can handle interactions with OSX | 14 // Registrar, and interface for services that can handle interactions with OSX |
| 13 // shim processes. | 15 // shim processes. |
| 14 class AppShimHandler { | 16 class AppShimHandler { |
| 15 public: | 17 public: |
| 16 class Host { | 18 class Host { |
| 17 public: | 19 public: |
| 18 // Invoked when the app is closed in the browser process. | 20 // Invoked when the app is closed in the browser process. |
| 19 virtual void OnAppClosed() = 0; | 21 virtual void OnAppClosed() = 0; |
| 20 | 22 |
| 23 // Allows the handler to determine which app this host corresponds to. | |
| 24 virtual Profile* profile() const = 0; | |
|
tapted
2013/05/21 06:15:37
Since there is no corresponding data member at thi
jackhou1
2013/05/22 23:54:44
Done.
| |
| 25 virtual const std::string& app_id() const = 0; | |
|
tapted
2013/05/21 06:15:37
nit: Maybe drop the reference and just return std:
jackhou1
2013/05/22 23:54:44
Done.
| |
| 26 | |
| 21 protected: | 27 protected: |
| 22 virtual ~Host() {} | 28 virtual ~Host() {} |
| 23 }; | 29 }; |
| 24 | 30 |
| 25 // Register a handler for an |app_mode_id|. | 31 // Register a handler for an |app_mode_id|. |
| 26 static void RegisterHandler(const std::string& app_mode_id, | 32 static void RegisterHandler(const std::string& app_mode_id, |
| 27 AppShimHandler* handler); | 33 AppShimHandler* handler); |
| 28 | 34 |
| 29 // Remove a handler for an |app_mode_id|. | 35 // Remove a handler for an |app_mode_id|. |
| 30 static void RemoveHandler(const std::string& app_mode_id); | 36 static void RemoveHandler(const std::string& app_mode_id); |
| 31 | 37 |
| 32 // Returns the handler registered for the given |app_mode_id|, or NULL if none | 38 // Returns the handler registered for the given |app_mode_id|, or the default |
| 33 // is registered. | 39 // handler if none is registered, or NULL if there is no default handler. |
|
tapted
2013/05/21 06:15:37
nit: comment reads a bit funny. Maybe just drop th
jackhou1
2013/05/22 23:54:44
Done.
| |
| 34 static AppShimHandler* GetForAppMode(const std::string& app_mode_id); | 40 static AppShimHandler* GetForAppMode(const std::string& app_mode_id); |
| 35 | 41 |
| 42 // Sets the default handler to return when there is no app-specific handler. | |
| 43 // Setting this to NULL removes the default handler. | |
| 44 static void SetDefaultHandler(AppShimHandler* handler); | |
| 45 | |
| 36 // Invoked by the shim host when the shim process is launched. The handler | 46 // Invoked by the shim host when the shim process is launched. The handler |
| 37 // must return true if successful, or false to indicate back to the shim | 47 // must return true if successful, or false to indicate back to the shim |
| 38 // process that it should close. | 48 // process that it should close. |
| 39 virtual bool OnShimLaunch(Host* host) = 0; | 49 virtual bool OnShimLaunch(Host* host) = 0; |
| 40 | 50 |
| 41 // Invoked by the shim host when the connection to the shim process is closed. | 51 // Invoked by the shim host when the connection to the shim process is closed. |
| 42 virtual void OnShimClose(Host* host) = 0; | 52 virtual void OnShimClose(Host* host) = 0; |
| 43 | 53 |
| 44 // Invoked by the shim host when the shim process receives a focus event. | 54 // Invoked by the shim host when the shim process receives a focus event. |
| 45 virtual void OnShimFocus(Host* host) = 0; | 55 virtual void OnShimFocus(Host* host) = 0; |
| 46 | 56 |
| 47 protected: | 57 protected: |
| 48 AppShimHandler() {} | 58 AppShimHandler() {} |
| 49 virtual ~AppShimHandler() {} | 59 virtual ~AppShimHandler() {} |
| 50 }; | 60 }; |
| 51 | 61 |
| 52 } // namespace apps | 62 } // namespace apps |
| 53 | 63 |
| 54 #endif // APPS_APP_SHIM_APP_SHIM_HANDLER_MAC_H_ | 64 #endif // APPS_APP_SHIM_APP_SHIM_HANDLER_MAC_H_ |
| OLD | NEW |