shelf_types.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. // Copyright (c) 2012 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. #ifndef ASH_PUBLIC_CPP_SHELF_TYPES_H_
  5. #define ASH_PUBLIC_CPP_SHELF_TYPES_H_
  6. #include <cstdint>
  7. #include <ostream>
  8. #include <string>
  9. #include "ash/public/cpp/ash_public_export.h"
  10. namespace ash {
  11. enum class ShelfAlignment {
  12. kBottom,
  13. kLeft,
  14. kRight,
  15. // Top has never been supported.
  16. // The locked alignment is set temporarily and not saved to preferences.
  17. kBottomLocked,
  18. };
  19. enum class HotseatState {
  20. // Hotseat is shown off screen.
  21. kHidden,
  22. // Hotseat is shown within the shelf in clamshell mode.
  23. kShownClamshell,
  24. // Hotseat is shown in the tablet mode home launcher's shelf.
  25. // Compared to kShownClamshell state, in this state, the shelf background is
  26. // not visible behind the hotseat (shelf itself is transparent on the home
  27. // screen). The hotseat also differs in size, and its bounds are moved
  28. // slightly up to leave more space between the hotseat background and the
  29. // bottom of the screen.
  30. kShownHomeLauncher,
  31. // Hotseat is shown above the shelf.
  32. kExtended,
  33. // No value,
  34. kNone
  35. };
  36. // Defines the density of hotseat. Hotseat is "denser" if it can accommodate
  37. // more shelf buttons without scrolling for the given available space.
  38. enum class HotseatDensity { kNormal, kSemiDense, kDense };
  39. enum class ShelfAutoHideBehavior {
  40. kAlways, // Always auto-hide.
  41. kNever, // Never auto-hide.
  42. kAlwaysHidden, // Always hide.
  43. };
  44. enum ShelfAutoHideState {
  45. SHELF_AUTO_HIDE_SHOWN,
  46. SHELF_AUTO_HIDE_HIDDEN,
  47. };
  48. ASH_PUBLIC_EXPORT std::ostream& operator<<(std::ostream& out,
  49. ShelfAutoHideState state);
  50. enum ShelfVisibilityState {
  51. // Always visible.
  52. SHELF_VISIBLE,
  53. // A couple of pixels are reserved at the bottom for the shelf.
  54. SHELF_AUTO_HIDE,
  55. // Nothing is shown. Used for fullscreen windows.
  56. SHELF_HIDDEN,
  57. };
  58. enum class ShelfBackgroundType {
  59. // The default transparent background.
  60. kDefaultBg,
  61. // The background when a window is maximized or two windows are maximized
  62. // for a split view.
  63. kMaximized,
  64. // The background when the app list is visible in clamshell mode.
  65. kAppList,
  66. // The background when the app list is visible in tablet mode.
  67. kHomeLauncher,
  68. // The background when a maximized window exists or two windows are maximized
  69. // for a split view, and the app list is visible. If the app list were not
  70. // visible, the shelf would be in ShelfBackgroundType::kMaximized state.
  71. kMaximizedWithAppList,
  72. // The background when OOBE is active.
  73. kOobe,
  74. // The background when login/lock/user-add is active.
  75. kLogin,
  76. // The background when login/lock/user-add is active and the wallpaper is not
  77. // blurred.
  78. kLoginNonBlurredWallpaper,
  79. // The background when overview is active.
  80. kOverview,
  81. // The background for the in-app shelf in tablet mode.
  82. kInApp,
  83. };
  84. ASH_PUBLIC_EXPORT std::ostream& operator<<(std::ostream& out,
  85. ShelfBackgroundType type);
  86. // Source of the launch or activation request, for tracking.
  87. enum ShelfLaunchSource {
  88. // The item was launched from an unknown source.
  89. LAUNCH_FROM_UNKNOWN,
  90. // The item was launched from a generic app list view.
  91. LAUNCH_FROM_APP_LIST,
  92. // The item was launched from an app list search view.
  93. LAUNCH_FROM_APP_LIST_SEARCH,
  94. // The item was launched from an app list search Recommendation.
  95. LAUNCH_FROM_APP_LIST_RECOMMENDATION,
  96. // The item was launched from the shelf itself.
  97. LAUNCH_FROM_SHELF,
  98. // The item was launched internally, for example from test.
  99. LAUNCH_FROM_INTERNAL,
  100. };
  101. // The actions that may be performed when a shelf item is selected.
  102. enum ShelfAction {
  103. // No action was taken.
  104. SHELF_ACTION_NONE,
  105. // A new window was created.
  106. SHELF_ACTION_NEW_WINDOW_CREATED,
  107. // An existing inactive window was activated.
  108. SHELF_ACTION_WINDOW_ACTIVATED,
  109. // The currently active window was minimized.
  110. SHELF_ACTION_WINDOW_MINIMIZED,
  111. // The app list launcher menu was shown.
  112. SHELF_ACTION_APP_LIST_SHOWN,
  113. // The app list launcher menu was dismissed.
  114. SHELF_ACTION_APP_LIST_DISMISSED,
  115. // The back action was performed on the app list.
  116. SHELF_ACTION_APP_LIST_BACK,
  117. };
  118. // The type of a shelf item.
  119. enum ShelfItemType {
  120. // Represents a pinned shortcut to an app, the app may be running or not.
  121. TYPE_PINNED_APP,
  122. // The browser shortcut button, the browser may be running or not.
  123. TYPE_BROWSER_SHORTCUT,
  124. // Represents an unpinned running app window. Supports these app types:
  125. // - Extension "V1" (legacy packaged and hosted) apps,
  126. // - Extension "V2" (platform) apps,
  127. // - ARC (App Runtime for Chrome - Android Play Store) apps.
  128. // - Lacros.
  129. TYPE_APP,
  130. // Similar to TYPE_BROWSER_SHORTCUT, but not pinned.
  131. // This is for the Lacros migration.
  132. // After Lacros is completely made, TYPE_BROWSER_SHORTCUT and
  133. // TYPE_UNPINNED_BROWSER_SHORTCUT will be removed, eventually.
  134. TYPE_UNPINNED_BROWSER_SHORTCUT,
  135. // Represents an open dialog.
  136. TYPE_DIALOG,
  137. // Default value.
  138. TYPE_UNDEFINED,
  139. };
  140. // Returns true if |type| is a valid ShelfItemType.
  141. ASH_PUBLIC_EXPORT bool IsValidShelfItemType(int64_t type);
  142. // Returns true if |type| is a pinned type (i.e. not a running app or dialog).
  143. ASH_PUBLIC_EXPORT bool IsPinnedShelfItemType(ShelfItemType type);
  144. // Returns true if types |a| and |b| have the same pin state, i.e. if they
  145. // are both pinned apps (or a browser shortcut which is always pinned) or both
  146. // unpinned apps. Returns false if either a or b aren't an app type.
  147. ASH_PUBLIC_EXPORT bool SamePinState(ShelfItemType a, ShelfItemType b);
  148. // Represents the status of applications in the shelf.
  149. enum ShelfItemStatus {
  150. // A closed shelf item, i.e. has no live instance.
  151. STATUS_CLOSED,
  152. // A shelf item that has live instance.
  153. STATUS_RUNNING,
  154. // A shelf item that needs user's attention.
  155. STATUS_ATTENTION,
  156. };
  157. // Represents the app status in the shelf or app_list.
  158. enum AppStatus {
  159. // The app is ready.
  160. kReady,
  161. // The app is blocked.
  162. kBlocked,
  163. // The app is paused.
  164. kPaused,
  165. };
  166. // A unique shelf item id composed of an |app_id| and a |launch_id|.
  167. // |app_id| is the non-empty application id associated with a set of windows.
  168. // |launch_id| is passed on app launch, to support multiple shelf items per app.
  169. // As an example, a remote desktop client may want each remote application to
  170. // have its own icon.
  171. struct ASH_PUBLIC_EXPORT ShelfID {
  172. explicit ShelfID(const std::string& app_id = std::string(),
  173. const std::string& launch_id = std::string());
  174. ~ShelfID();
  175. ShelfID(const ShelfID& other);
  176. ShelfID(ShelfID&& other);
  177. ShelfID& operator=(const ShelfID& other);
  178. bool operator==(const ShelfID& other) const;
  179. bool operator!=(const ShelfID& other) const;
  180. bool operator<(const ShelfID& other) const;
  181. // Returns true if both the application id and launch id are empty.
  182. // This is often used to determine if the id is invalid.
  183. bool IsNull() const;
  184. // Functions to [de]serialize ids as a string for window property usage, etc.
  185. // Serialization appends ids with a delimeter that must not be used in ids.
  186. // Deserialization returns an empty/null/default id for a null string input.
  187. std::string Serialize() const;
  188. static ShelfID Deserialize(const std::string* string);
  189. // The application id associated with a set of windows.
  190. std::string app_id;
  191. // An id passed on app launch, to support multiple shelf items per app.
  192. std::string launch_id;
  193. };
  194. ASH_PUBLIC_EXPORT std::ostream& operator<<(std::ostream& o, const ShelfID& id);
  195. } // namespace ash
  196. #endif // ASH_PUBLIC_CPP_SHELF_TYPES_H_