Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / apps / app_shim / app_shim_handler_mac.h
blob5482ae98ff1e84419bcb01860a81f862989d902a
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 CHROME_BROWSER_APPS_APP_SHIM_APP_SHIM_HANDLER_MAC_H_
6 #define CHROME_BROWSER_APPS_APP_SHIM_APP_SHIM_HANDLER_MAC_H_
8 #include <string>
9 #include <vector>
11 #include "base/files/file_path.h"
12 #include "chrome/common/mac/app_shim_launch.h"
14 namespace apps {
16 // Registrar, and interface for services that can handle interactions with OSX
17 // shim processes.
18 class AppShimHandler {
19 public:
20 class Host {
21 public:
22 // Invoked when the app is successfully launched.
23 virtual void OnAppLaunchComplete(AppShimLaunchResult result) = 0;
24 // Invoked when the app is closed in the browser process.
25 virtual void OnAppClosed() = 0;
26 // Invoked when the app should be hidden.
27 virtual void OnAppHide() = 0;
28 // Invoked when a window becomes visible while the app is hidden. Ensures
29 // the shim's "Hide/Show" state is updated correctly and the app can be
30 // re-hidden.
31 virtual void OnAppUnhideWithoutActivation() = 0;
32 // Invoked when the app is requesting user attention.
33 virtual void OnAppRequestUserAttention(AppShimAttentionType type) = 0;
35 // Allows the handler to determine which app this host corresponds to.
36 virtual base::FilePath GetProfilePath() const = 0;
37 virtual std::string GetAppId() const = 0;
39 protected:
40 virtual ~Host() {}
43 // Register a handler for an |app_mode_id|.
44 static void RegisterHandler(const std::string& app_mode_id,
45 AppShimHandler* handler);
47 // Remove a handler for an |app_mode_id|.
48 static void RemoveHandler(const std::string& app_mode_id);
50 // Returns the handler registered for the given |app_mode_id|. If there is
51 // none registered, it returns the default handler or NULL if there is no
52 // default handler.
53 static AppShimHandler* GetForAppMode(const std::string& app_mode_id);
55 // Sets the default handler to return when there is no app-specific handler.
56 // Setting this to NULL removes the default handler.
57 static void SetDefaultHandler(AppShimHandler* handler);
59 // Terminate Chrome if a browser window has never been opened, there are no
60 // shell windows, and the app list is not visible.
61 static void MaybeTerminate();
63 // Whether browser sessions should be restored right now. This is true if
64 // the browser has been quit but kept alive because Chrome Apps are still
65 // running.
66 static bool ShouldRestoreSession();
68 // Invoked by the shim host when the shim process is launched. The handler
69 // must call OnAppLaunchComplete to inform the shim of the result.
70 // |launch_type| indicates the type of launch.
71 // |files|, if non-empty, holds an array of files paths given as arguments, or
72 // dragged onto the app bundle or dock icon.
73 virtual void OnShimLaunch(Host* host,
74 AppShimLaunchType launch_type,
75 const std::vector<base::FilePath>& files) = 0;
77 // Invoked by the shim host when the connection to the shim process is closed.
78 virtual void OnShimClose(Host* host) = 0;
80 // Invoked by the shim host when the shim process receives a focus event.
81 // |files|, if non-empty, holds an array of files dragged onto the app bundle
82 // or dock icon.
83 virtual void OnShimFocus(Host* host,
84 AppShimFocusType focus_type,
85 const std::vector<base::FilePath>& files) = 0;
87 // Invoked by the shim host when the shim process is hidden or shown.
88 virtual void OnShimSetHidden(Host* host, bool hidden) = 0;
90 // Invoked by the shim host when the shim process receives a quit event.
91 virtual void OnShimQuit(Host* host) = 0;
93 protected:
94 AppShimHandler() {}
95 virtual ~AppShimHandler() {}
98 } // namespace apps
100 #endif // CHROME_BROWSER_APPS_APP_SHIM_APP_SHIM_HANDLER_MAC_H_