app_list_view.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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_APP_LIST_VIEWS_APP_LIST_VIEW_H_
  5. #define ASH_APP_LIST_VIEWS_APP_LIST_VIEW_H_
  6. #include <memory>
  7. #include <string>
  8. #include <vector>
  9. #include "ash/app_list/app_list_metrics.h"
  10. #include "ash/app_list/app_list_view_delegate.h"
  11. #include "ash/ash_export.h"
  12. #include "ash/public/cpp/app_list/app_list_types.h"
  13. #include "ash/public/cpp/metrics_util.h"
  14. #include "base/callback.h"
  15. #include "base/gtest_prod_util.h"
  16. #include "base/time/time.h"
  17. #include "build/build_config.h"
  18. #include "third_party/abseil-cpp/absl/types/optional.h"
  19. #include "ui/aura/window_observer.h"
  20. #include "ui/compositor/presentation_time_recorder.h"
  21. #include "ui/events/event.h"
  22. #include "ui/gfx/color_palette.h"
  23. #include "ui/views/widget/widget.h"
  24. #include "ui/views/widget/widget_delegate.h"
  25. namespace aura {
  26. class Window;
  27. }
  28. namespace display {
  29. class Display;
  30. }
  31. namespace ui {
  32. class ImplicitAnimationObserver;
  33. } // namespace ui
  34. namespace ash {
  35. class AppListA11yAnnouncer;
  36. class AppsContainerView;
  37. class ApplicationDragAndDropHost;
  38. class AppListBackgroundShieldView;
  39. class AppListMainView;
  40. class AppsGridView;
  41. class PagedAppsGridView;
  42. class PaginationModel;
  43. class SearchBoxView;
  44. class StateTransitionNotifier;
  45. FORWARD_DECLARE_TEST(AppListControllerImplTest,
  46. CheckAppListViewBoundsWhenVKeyboardEnabled);
  47. FORWARD_DECLARE_TEST(AppListControllerImplTest,
  48. CheckAppListViewBoundsWhenDismissVKeyboard);
  49. FORWARD_DECLARE_TEST(AppListControllerImplMetricsTest,
  50. PresentationTimeRecordedForDragInTabletMode);
  51. // The fraction of app list height that the app list must be released at in
  52. // order to transition to the next state.
  53. constexpr int kAppListThresholdDenominator = 3;
  54. // AppListView is the top-level view and controller of app list UI. It creates
  55. // and hosts a AppsGridView and passes AppListModel to it for display.
  56. // TODO(newcomer|weidongg): Organize the cc file to match the order of
  57. // definitions in this header.
  58. class ASH_EXPORT AppListView : public views::WidgetDelegateView,
  59. public aura::WindowObserver {
  60. public:
  61. class TestApi {
  62. public:
  63. explicit TestApi(AppListView* view);
  64. TestApi(const TestApi&) = delete;
  65. TestApi& operator=(const TestApi&) = delete;
  66. ~TestApi();
  67. PagedAppsGridView* GetRootAppsGridView();
  68. private:
  69. AppListView* const view_;
  70. };
  71. class ASH_EXPORT ScopedAccessibilityAnnouncementLock {
  72. public:
  73. explicit ScopedAccessibilityAnnouncementLock(AppListView* view)
  74. : view_(view) {
  75. ++view_->accessibility_event_disablers_;
  76. }
  77. ~ScopedAccessibilityAnnouncementLock() {
  78. --view_->accessibility_event_disablers_;
  79. }
  80. private:
  81. AppListView* const view_;
  82. };
  83. // Used to prevent the app list contents from being reset when the app list
  84. // shows. Only one instance can exist at a time. This class is useful when:
  85. // (1) the app list close animation is reversed, and
  86. // (2) the contents before the close animation starts should be kept.
  87. class ScopedContentsResetDisabler {
  88. public:
  89. explicit ScopedContentsResetDisabler(AppListView* view);
  90. ScopedContentsResetDisabler(const ScopedContentsResetDisabler&) = delete;
  91. ScopedContentsResetDisabler& operator=(const ScopedContentsResetDisabler&) =
  92. delete;
  93. ~ScopedContentsResetDisabler();
  94. private:
  95. AppListView* const view_;
  96. };
  97. // Number of the size of shelf. Used to determine the opacity of items in the
  98. // app list during dragging.
  99. static constexpr float kNumOfShelfSize = 2.0;
  100. // The opacity of the app list background.
  101. static constexpr float kAppListOpacity = 0.95;
  102. // The opacity of the app list background with blur.
  103. static constexpr float kAppListOpacityWithBlur = 0.8;
  104. // The preferred blend alpha with wallpaper color for background.
  105. static constexpr int kAppListColorDarkenAlpha = 178;
  106. // The duration the AppListView ignores scroll events which could transition
  107. // its state.
  108. static constexpr int kScrollIgnoreTimeMs = 500;
  109. // The snapping threshold for dragging app list from shelf in tablet mode,
  110. // measured in DIPs.
  111. static constexpr int kDragSnapToFullscreenThreshold = 320;
  112. // The snapping thresholds for dragging app list from shelf in laptop mode,
  113. // measured in DIPs.
  114. static constexpr int kDragSnapToClosedThreshold = 120;
  115. static constexpr int kDragSnapToPeekingThreshold = 561;
  116. // The velocity the app list must be dragged from the shelf in order to
  117. // transition to the next state, measured in DIPs/event.
  118. static constexpr int kDragVelocityFromShelfThreshold = 120;
  119. // The velocity the app list must be dragged in order to transition to the
  120. // next state, measured in DIPs/event.
  121. static constexpr int kDragVelocityThreshold = 6;
  122. // The animation duration for app list movement.
  123. static constexpr int kAppListAnimationDurationMs = 200;
  124. static constexpr int kAppListAnimationDurationFromFullscreenMs = 250;
  125. // The scroll offset in order to transition from PEEKING to FULLSCREEN
  126. static constexpr int kAppListMinScrollToSwitchStates = 20;
  127. // Does not take ownership of |delegate|.
  128. explicit AppListView(AppListViewDelegate* delegate);
  129. AppListView(const AppListView&) = delete;
  130. AppListView& operator=(const AppListView&) = delete;
  131. ~AppListView() override;
  132. // Used for testing, allows the page reset timer to be fired immediately
  133. // after starting.
  134. static void SetSkipPageResetTimerForTesting(bool enabled);
  135. // Returns the app list transition progress value associated with a app list
  136. // view state. This matches the values GetAppListTransitionProgress() is
  137. // expected to return when app list view is exactly in the provided state.
  138. static float GetTransitionProgressForState(AppListViewState state);
  139. // Initializes the view, only done once per session.
  140. void InitView(gfx::NativeView parent);
  141. // Initializes the contents of the view.
  142. void InitContents();
  143. // Initializes this view's widget.
  144. void InitWidget(gfx::NativeView parent);
  145. // Initializes the SearchBox's widget.
  146. void InitChildWidget();
  147. // Sets the state of all child views to be re-shown, then shows the view.
  148. // |preferred_state| - The initial app list view state. It may be overridden
  149. // depending on device state. For example, peeking state is not supported in
  150. // tablet mode, or for side shelf.
  151. void Show(AppListViewState preferred_state, bool is_side_shelf);
  152. // If |drag_and_drop_host| is not nullptr it will be called upon drag and drop
  153. // operations outside the application list. This has to be called after
  154. // Initialize was called since the app list object needs to exist so that
  155. // it can set the host.
  156. void SetDragAndDropHostOfCurrentAppList(
  157. ApplicationDragAndDropHost* drag_and_drop_host);
  158. // Dismisses the UI, cleans up and sets the state to CLOSED.
  159. void Dismiss();
  160. // Resets the child views before showing the AppListView.
  161. void ResetForShow();
  162. // Closes opened folder or search result page if they are opened.
  163. void CloseOpenedPage();
  164. // If a folder is open, close it. Returns whether an opened folder was closed.
  165. bool HandleCloseOpenFolder();
  166. // If a search box is open, close it. Returns whether an open search box was
  167. // closed.
  168. bool HandleCloseOpenSearchBox();
  169. // Performs the 'back' action for the active page.
  170. bool Back();
  171. // views::View:
  172. void OnPaint(gfx::Canvas* canvas) override;
  173. const char* GetClassName() const override;
  174. bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
  175. void Layout() override;
  176. void OnThemeChanged() override;
  177. // ui::EventHandler:
  178. void OnKeyEvent(ui::KeyEvent* event) override;
  179. void OnScrollEvent(ui::ScrollEvent* event) override;
  180. void OnMouseEvent(ui::MouseEvent* event) override;
  181. void OnGestureEvent(ui::GestureEvent* event) override;
  182. // Called when tablet mode starts and ends.
  183. void OnTabletModeChanged(bool started);
  184. // Called when the wallpaper colors change.
  185. void OnWallpaperColorsChanged();
  186. // Handles scroll events from various sources.
  187. bool HandleScroll(const gfx::Point& location,
  188. const gfx::Vector2d& offset,
  189. ui::EventType type);
  190. // Changes the app list state.
  191. void SetState(AppListViewState new_state);
  192. // Changes the app list state depending on the current |app_list_state_| and
  193. // whether the search box is empty.
  194. void SetStateFromSearchBoxView(bool search_box_is_empty,
  195. bool triggered_by_contents_change);
  196. // Updates y position and opacity of app list during dragging.
  197. void UpdateYPositionAndOpacity(float y_position_in_screen,
  198. float background_opacity);
  199. // Offsets the y position of the app list (above the screen)
  200. void OffsetYPositionOfAppList(int offset);
  201. // Update Y position and opacity of this view's child views during dragging.
  202. void UpdateChildViewsYPositionAndOpacity();
  203. // The search box cannot actively listen to all key events. To control and
  204. // input into the search box when it does not have focus, we need to redirect
  205. // necessary key events to the search box.
  206. void RedirectKeyEventToSearchBox(ui::KeyEvent* event);
  207. // Called when on-screen keyboard's visibility is changed.
  208. void OnScreenKeyboardShown(bool shown);
  209. // Called when parent window's bounds is changed.
  210. void OnParentWindowBoundsChanged();
  211. // If the on-screen keyboard is shown, hide it. Return whether keyboard was
  212. // hidden
  213. bool CloseKeyboardIfVisible();
  214. // Sets |is_in_drag_| and updates the visibility of app list items.
  215. void SetIsInDrag(bool is_in_drag);
  216. // Home launcher can become the focused window without being reset when all
  217. // open windows are closed in tablet mode. Ensures that correct initial view
  218. // is focused in this case.
  219. void OnHomeLauncherGainingFocusWithoutAnimation();
  220. // Ensures that apps grid pagination model has selected the initial page.
  221. void SelectInitialAppsPage();
  222. // Gets the PaginationModel owned by this view's apps grid.
  223. PaginationModel* GetAppsPaginationModel();
  224. // Gets the content bounds of the app info dialog of the app list in the
  225. // screen coordinates.
  226. gfx::Rect GetAppInfoDialogBounds() const;
  227. // Gets current screen bottom.
  228. int GetScreenBottom() const;
  229. // Returns current app list height above display bottom.
  230. int GetCurrentAppListHeight() const;
  231. // Flags that can be passed to GetAppListTransitionProgress(). For more
  232. // details, see GetAppListTransitionProgress() documentation.
  233. static constexpr int kProgressFlagNone = 0;
  234. static constexpr int kProgressFlagSearchResults = 1;
  235. static constexpr int kProgressFlagWithTransform = 1 << 1;
  236. // The progress of app list height transitioning from closed to fullscreen
  237. // state. [0.0, 1.0] means the progress between closed and peeking state,
  238. // while [1.0, 2.0] means the progress between peeking and fullscreen state.
  239. //
  240. // By default, this calculates progress for drag operation while app list
  241. // is AppListState::kApps state, relative to the current app list view bounds.
  242. // The |flags| argument can be used to amend this behavior:
  243. // * Use |kProgressFlagNone| for default behavior.
  244. // * If |kProgressFlagSearchResult| flag is set, the progress will be
  245. // calculated using kHalf state height as baseline. This should be used
  246. // when calculating contents layout for search results state.
  247. // * If |kProgressFlagWithTransform| is set, the progress will be calculated
  248. // for the app list height offset by the current app list view transform.
  249. // This should be used when setting up transform animations for views
  250. // whose bounds depend on the app list height - in particular when the
  251. // animation is implemented by setting up target bounds first, and then
  252. // animating view layer transform from one that matches current bounds to
  253. // an identity transform. This flag is needed to properly calculate the
  254. // initial animation transform.
  255. float GetAppListTransitionProgress(int flags) const;
  256. // Returns the expected app list view height (measured from the screen bottom)
  257. // in the provided state.
  258. int GetHeightForState(AppListViewState state) const;
  259. // Returns the height of app list in fullscreen state.
  260. int GetFullscreenStateHeight() const;
  261. // Calculates and returns the app list view state after dragging from shelf
  262. // ends.
  263. AppListViewState CalculateStateAfterShelfDrag(
  264. const ui::LocatedEvent& event_in_screen,
  265. float launcher_above_shelf_bottom_amount) const;
  266. // Returns a animation metrics reporting callback for state transition.
  267. metrics_util::SmoothnessCallback GetStateTransitionMetricsReportCallback();
  268. // Called when drag in tablet mode starts/proceeds/ends.
  269. void OnHomeLauncherDragStart();
  270. void OnHomeLauncherDragInProgress();
  271. void OnHomeLauncherDragEnd();
  272. // Resets the animation metrics reporter for state transition.
  273. void ResetTransitionMetricsReporter();
  274. // WindowObserver overrides:
  275. void OnWindowDestroying(aura::Window* window) override;
  276. void OnWindowBoundsChanged(aura::Window* window,
  277. const gfx::Rect& old_bounds,
  278. const gfx::Rect& new_bounds,
  279. ui::PropertyChangeReason reason) override;
  280. void OnTabletModeAnimationTransitionNotified(
  281. TabletModeAnimationTransition animation_transition);
  282. // Called at the end of dragging AppList from Shelf.
  283. void EndDragFromShelf(AppListViewState app_list_state);
  284. // Moves the AppListView off screen and calls a layout if needed.
  285. void OnBoundsAnimationCompleted(AppListViewState target_state);
  286. gfx::NativeView parent_window() const { return parent_window_; }
  287. AppListViewState app_list_state() const { return app_list_state_; }
  288. SearchBoxView* search_box_view() const { return search_box_view_; }
  289. AppListMainView* app_list_main_view() const { return app_list_main_view_; }
  290. AppListA11yAnnouncer* a11y_announcer() { return a11y_announcer_.get(); }
  291. bool is_fullscreen() const {
  292. return app_list_state_ == AppListViewState::kFullscreenAllApps ||
  293. app_list_state_ == AppListViewState::kFullscreenSearch;
  294. }
  295. bool is_tablet_mode() const { return delegate_->IsInTabletMode(); }
  296. bool is_side_shelf() const { return is_side_shelf_; }
  297. void SetShelfHasRoundedCorners(bool shelf_has_rounded_corners);
  298. bool shelf_has_rounded_corners() const { return shelf_has_rounded_corners_; }
  299. bool is_in_drag() const { return is_in_drag_; }
  300. void set_onscreen_keyboard_shown(bool onscreen_keyboard_shown) {
  301. onscreen_keyboard_shown_ = onscreen_keyboard_shown;
  302. }
  303. views::View* GetAppListBackgroundShieldForTest();
  304. SkColor GetAppListBackgroundShieldColorForTest();
  305. // Returns true if the Embedded Assistant UI is currently being shown.
  306. bool IsShowingEmbeddedAssistantUI() const;
  307. // Returns true if a folder is being renamed.
  308. bool IsFolderBeingRenamed();
  309. // Starts or stops a timer which will reset the app list to the initial apps
  310. // page. Called when the app list's visibility changes.
  311. void UpdatePageResetTimer(bool app_list_visibility);
  312. // Updates the title of the window that contains the launcher.
  313. void UpdateWindowTitle();
  314. // Called when app list visibility changed.
  315. void OnAppListVisibilityWillChange(bool visible);
  316. void OnAppListVisibilityChanged(bool shown);
  317. private:
  318. FRIEND_TEST_ALL_PREFIXES(AppListControllerImplTest,
  319. CheckAppListViewBoundsWhenVKeyboardEnabled);
  320. FRIEND_TEST_ALL_PREFIXES(AppListControllerImplTest,
  321. CheckAppListViewBoundsWhenDismissVKeyboard);
  322. FRIEND_TEST_ALL_PREFIXES(AppListControllerImplMetricsTest,
  323. PresentationTimeRecordedForDragInTabletMode);
  324. class StateAnimationMetricsReporter;
  325. // Returns insets that should be added to app list content to avoid overlap
  326. // with the shelf.
  327. gfx::Insets GetMainViewInsetsForShelf() const;
  328. // Updates the widget to be shown.
  329. void UpdateWidget();
  330. // Closes the AppListView when a click or tap event propogates to the
  331. // AppListView.
  332. void HandleClickOrTap(ui::LocatedEvent* event);
  333. // Initializes |initial_drag_point_|.
  334. void StartDrag(const gfx::PointF& location_in_root);
  335. // Updates the bounds of the widget while maintaining the relative position
  336. // of the top of the widget and the gesture.
  337. void UpdateDrag(const gfx::PointF& location_in_root);
  338. // Handles app list state transfers. If the drag was fast enough, ignore the
  339. // release position and snap to the next state.
  340. void EndDrag(const gfx::PointF& location_in_root);
  341. // Set child views for |target_state|.
  342. void SetChildViewsForStateTransition(AppListViewState target_state);
  343. // Converts |state| to the fullscreen equivalent.
  344. void ConvertAppListStateToFullscreenEquivalent(AppListViewState* state);
  345. // Gets the animation duration that transition to |taget_state| should have.
  346. base::TimeDelta GetStateTransitionAnimationDuration(
  347. AppListViewState target_state);
  348. // Kicks off the proper animation for the state change. If an animation is
  349. // in progress it will be interrupted.
  350. void StartAnimationForState(AppListViewState new_state);
  351. void MaybeIncreasePrivacyInfoRowShownCounts(AppListViewState new_state);
  352. // Applies a bounds animation on this views layer.
  353. void ApplyBoundsAnimation(AppListViewState target_state,
  354. base::TimeDelta duration_ms);
  355. // Records the state transition for UMA.
  356. void RecordStateTransitionForUma(AppListViewState new_state);
  357. // Creates an Accessibility Event if the state transition warrants one.
  358. void MaybeCreateAccessibilityEvent(AppListViewState new_state);
  359. // Ensures that the app list widget bounds are set to the preferred bounds for
  360. // the current app list view state - intended to be called when the
  361. // display bounds available to the app list view change.
  362. void EnsureWidgetBoundsMatchCurrentState();
  363. // Returns the remaining vertical distance for the bounds movement
  364. // animation.
  365. int GetRemainingBoundsAnimationDistance() const;
  366. // Gets the display nearest to the parent window.
  367. display::Display GetDisplayNearestView() const;
  368. // Gets the apps container view owned by this view.
  369. AppsContainerView* GetAppsContainerView();
  370. // Gets the root apps grid view owned by this view.
  371. PagedAppsGridView* GetRootAppsGridView();
  372. // Gets the apps grid view within the folder view owned by this view.
  373. AppsGridView* GetFolderAppsGridView();
  374. // Gets the AppListStateTransitionSource for |app_list_state_| to
  375. // |target_state|. If we are not interested in recording a state transition
  376. // (ie. PEEKING->PEEKING) then return kMaxAppListStateTransition. If this is
  377. // modified, histograms will be affected.
  378. AppListStateTransitionSource GetAppListStateTransitionSource(
  379. AppListViewState target_state) const;
  380. // Overridden from views::WidgetDelegateView:
  381. views::View* GetInitiallyFocusedView() override;
  382. // Gets app list background opacity during dragging.
  383. float GetAppListBackgroundOpacityDuringDragging();
  384. const std::vector<SkColor>& GetWallpaperProminentColors();
  385. void SetBackgroundShieldColor();
  386. // Returns true if scroll events should be ignored.
  387. bool ShouldIgnoreScrollEvents();
  388. // Returns true if we should dismiss app list. We use the |location|,
  389. // |offset|, and |type| of the scroll event. |is_in_vertical_bounds| indicates
  390. // whether the event took place within the vertical bounds of the apps grid,
  391. // since this affects dismissal behavior.
  392. bool ShouldScrollDismissAppList(const gfx::Point& location,
  393. const gfx::Vector2d& offset,
  394. ui::EventType type,
  395. bool is_in_vertical_bounds);
  396. // Returns preferred y of fullscreen widget bounds in parent window for the
  397. // specified state.
  398. int GetPreferredWidgetYForState(AppListViewState state) const;
  399. // Returns preferred fullscreen widget bounds in parent window for the
  400. // specified state. Note that this function should only be called after the
  401. // widget is initialized.
  402. gfx::Rect GetPreferredWidgetBoundsForState(AppListViewState state);
  403. // Updates y position of |app_list_background_shield_| based on the
  404. // |state| and |is_in_drag_|.
  405. void UpdateAppListBackgroundYPosition(AppListViewState state);
  406. // Reset the subpixel position offset of the |layer| so that it's DP origin
  407. // is snapped.
  408. void ResetSubpixelPositionOffset(ui::Layer* layer);
  409. AppListViewDelegate* const delegate_;
  410. // Keeps track of the number of locks that prevent the app list view
  411. // from creating app list transition accessibility events. This is used to
  412. // prevent A11Y announcements when showing the assistant UI.
  413. int accessibility_event_disablers_ = 0;
  414. AppListMainView* app_list_main_view_ = nullptr;
  415. gfx::NativeView parent_window_ = nullptr;
  416. SearchBoxView* search_box_view_ = nullptr; // Owned by views hierarchy.
  417. // Owned by the app list's widget. Used to show the darkened AppList
  418. // background.
  419. AppListBackgroundShieldView* app_list_background_shield_ = nullptr;
  420. // The time the AppListView was requested to be shown. Used for metrics.
  421. absl::optional<base::Time> time_shown_;
  422. // Whether the shelf is oriented on the side.
  423. bool is_side_shelf_ = false;
  424. // Whether the shelf has rounded corners.
  425. bool shelf_has_rounded_corners_ = false;
  426. // True if the user is in the process of gesture-dragging on opened app list,
  427. // or dragging the app list from shelf.
  428. bool is_in_drag_ = false;
  429. // Whether the view is being built.
  430. bool is_building_ = false;
  431. // The opacity of app list background during dragging. This ensures a gradual
  432. // opacity shift from the shelf opacity while dragging to show the AppListView
  433. // from the shelf.
  434. float background_opacity_in_drag_ = 0.f;
  435. // The location of initial gesture event in root window coordinates.
  436. gfx::PointF initial_drag_point_;
  437. // The offset to the widget from dragging location.
  438. float drag_offset_;
  439. // The location of the initial mouse event in root window coordinates.
  440. gfx::PointF initial_mouse_drag_point_;
  441. // The velocity of the gesture event.
  442. float last_fling_velocity_ = 0;
  443. // Whether the background blur is enabled.
  444. const bool is_background_blur_enabled_;
  445. // The state of the app list, controlled via SetState().
  446. AppListViewState app_list_state_ = AppListViewState::kClosed;
  447. // Set to target app list state while `SetState()` is being handled.
  448. AppListViewState target_app_list_state_ = AppListViewState::kClosed;
  449. // The timestamp when the ongoing animation ends.
  450. base::TimeTicks animation_end_timestamp_;
  451. // An observer to notify AppListView of bounds animation completion.
  452. std::unique_ptr<StateTransitionNotifier> state_transition_notifier_;
  453. // Metric reporter for state change animations.
  454. const std::unique_ptr<StateAnimationMetricsReporter>
  455. state_animation_metrics_reporter_;
  456. // Whether the on-screen keyboard is shown.
  457. bool onscreen_keyboard_shown_ = false;
  458. // Whether the app list has been translated up to ensure app list folder
  459. // view header is visible when onscreen keyboard is shown.
  460. bool offset_to_show_folder_with_onscreen_keyboard_ = false;
  461. // Used for announcing accessibility alerts.
  462. std::unique_ptr<AppListA11yAnnouncer> a11y_announcer_;
  463. // If true, the contents view is not reset when showing the app list.
  464. bool disable_contents_reset_when_showing_ = false;
  465. // Records the presentation time for app launcher dragging.
  466. std::unique_ptr<ui::PresentationTimeRecorder> presentation_time_recorder_;
  467. // A timer which will reset the app list to the initial page. This timer only
  468. // goes off when the app list is not visible after a set amount of time.
  469. base::OneShotTimer page_reset_timer_;
  470. // Used to cancel in progress `SetState()` request if `SetState()` gets called
  471. // again. Updating children state during app list view state update may cause
  472. // `SetState()` to get called again - for example, if exiting search results
  473. // page causes virtual keyboard to get hidden, and work area bounds available
  474. // to the app list change.
  475. // When calling methods that may cause nested `SetState()` call, `SetState()`
  476. // will bind a weak ptr to this factory, and it will bail out early if it
  477. // detects that `SetState()` got called again (in which case the weak ptr will
  478. // be invalidated).
  479. base::WeakPtrFactory<AppListView> set_state_weak_factory_{this};
  480. };
  481. } // namespace ash
  482. #endif // ASH_APP_LIST_VIEWS_APP_LIST_VIEW_H_