Report errors from ChromiumEnv::GetChildren in Posix.
[chromium-blink-merge.git] / apps / app_shim / app_shim_handler_mac.h
blob2e7318107dcfe9b45ac1ad44e7b85170f1f13ee2
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.
5 #ifndef APPS_APP_SHIM_APP_SHIM_HANDLER_MAC_H_
6 #define APPS_APP_SHIM_APP_SHIM_HANDLER_MAC_H_
8 #include <string>
9 #include <vector>
11 #include "apps/app_shim/app_shim_launch.h"
12 #include "base/files/file_path.h"
14 class Profile;
16 namespace apps {
18 // Registrar, and interface for services that can handle interactions with OSX
19 // shim processes.
20 class AppShimHandler {
21 public:
22 class Host {
23 public:
24 // Invoked when the app is successfully launched.
25 virtual void OnAppLaunchComplete(AppShimLaunchResult result) = 0;
26 // Invoked when the app is closed in the browser process.
27 virtual void OnAppClosed() = 0;
28 // Invoked when the app should be hidden.
29 virtual void OnAppHide() = 0;
30 // Invoked when the app is requesting user attention.
31 virtual void OnAppRequestUserAttention() = 0;
33 // Allows the handler to determine which app this host corresponds to.
34 virtual base::FilePath GetProfilePath() const = 0;
35 virtual std::string GetAppId() const = 0;
37 protected:
38 virtual ~Host() {}
41 // Register a handler for an |app_mode_id|.
42 static void RegisterHandler(const std::string& app_mode_id,
43 AppShimHandler* handler);
45 // Remove a handler for an |app_mode_id|.
46 static void RemoveHandler(const std::string& app_mode_id);
48 // Returns the handler registered for the given |app_mode_id|. If there is
49 // none registered, it returns the default handler or NULL if there is no
50 // default handler.
51 static AppShimHandler* GetForAppMode(const std::string& app_mode_id);
53 // Sets the default handler to return when there is no app-specific handler.
54 // Setting this to NULL removes the default handler.
55 static void SetDefaultHandler(AppShimHandler* handler);
57 // Terminate Chrome if a browser window has never been opened, there are no
58 // shell windows, and the app list is not visible.
59 static void MaybeTerminate();
61 // Invoked by the shim host when the shim process is launched. The handler
62 // must call OnAppLaunchComplete to inform the shim of the result.
63 // |launch_type| indicates the type of launch.
64 // |files|, if non-empty, holds an array of files paths given as arguments, or
65 // dragged onto the app bundle or dock icon.
66 virtual void OnShimLaunch(Host* host,
67 AppShimLaunchType launch_type,
68 const std::vector<base::FilePath>& files) = 0;
70 // Invoked by the shim host when the connection to the shim process is closed.
71 virtual void OnShimClose(Host* host) = 0;
73 // Invoked by the shim host when the shim process receives a focus event.
74 // |files|, if non-empty, holds an array of files dragged onto the app bundle
75 // or dock icon.
76 virtual void OnShimFocus(Host* host,
77 AppShimFocusType focus_type,
78 const std::vector<base::FilePath>& files) = 0;
80 // Invoked by the shim host when the shim process is hidden or shown.
81 virtual void OnShimSetHidden(Host* host, bool hidden) = 0;
83 // Invoked by the shim host when the shim process receives a quit event.
84 virtual void OnShimQuit(Host* host) = 0;
86 protected:
87 AppShimHandler() {}
88 virtual ~AppShimHandler() {}
91 } // namespace apps
93 #endif // APPS_APP_SHIM_APP_SHIM_HANDLER_MAC_H_