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_APP_SHIM_HANDLER_MAC_H_ 6 #define APPS_APP_SHIM_APP_SHIM_HANDLER_MAC_H_ 7 8 #include <string> 9 10 #include "apps/app_shim/app_shim_launch.h" 11 #include "base/files/file_path.h" 12 13 class Profile; 14 15 namespace apps { 16 17 // Registrar, and interface for services that can handle interactions with OSX 18 // shim processes. 19 class AppShimHandler { 20 public: 21 class Host { 22 public: 23 // Invoked when the app is successfully launched. 24 virtual void OnAppLaunchComplete(AppShimLaunchResult result) = 0; 25 // Invoked when the app is closed in the browser process. 26 virtual void OnAppClosed() = 0; 27 28 // Allows the handler to determine which app this host corresponds to. 29 virtual base::FilePath GetProfilePath() const = 0; 30 virtual std::string GetAppId() const = 0; 31 32 protected: 33 virtual ~Host() {} 34 }; 35 36 // Register a handler for an |app_mode_id|. 37 static void RegisterHandler(const std::string& app_mode_id, 38 AppShimHandler* handler); 39 40 // Remove a handler for an |app_mode_id|. 41 static void RemoveHandler(const std::string& app_mode_id); 42 43 // Returns the handler registered for the given |app_mode_id|. If there is 44 // none registered, it returns the default handler or NULL if there is no 45 // default handler. 46 static AppShimHandler* GetForAppMode(const std::string& app_mode_id); 47 48 // Sets the default handler to return when there is no app-specific handler. 49 // Setting this to NULL removes the default handler. 50 static void SetDefaultHandler(AppShimHandler* handler); 51 52 // Invoked by the shim host when the shim process is launched. The handler 53 // must call OnAppLaunchComplete to inform the shim of the result. 54 // |launch_now| indicates whether to launch the associated app. 55 virtual void OnShimLaunch(Host* host, AppShimLaunchType launch_type) = 0; 56 57 // Invoked by the shim host when the connection to the shim process is closed. 58 virtual void OnShimClose(Host* host) = 0; 59 60 // Invoked by the shim host when the shim process receives a focus event. 61 virtual void OnShimFocus(Host* host, AppShimFocusType focus_type) = 0; 62 63 // Invoked by the shim host when the shim process is hidden or shown. 64 virtual void OnShimSetHidden(Host* host, bool hidden) = 0; 65 66 // Invoked by the shim host when the shim process receives a quit event. 67 virtual void OnShimQuit(Host* host) = 0; 68 69 protected: 70 AppShimHandler() {} 71 virtual ~AppShimHandler() {} 72 }; 73 74 } // namespace apps 75 76 #endif // APPS_APP_SHIM_APP_SHIM_HANDLER_MAC_H_ 77