Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: ui/app_list/presenter/app_list_presenter_impl.h

Issue 2576913002: Use mojo app list interfaces for mash and classic ash. (Closed)
Patch Set: Fix test name. Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_APP_LIST_PRESENTER_APP_LIST_PRESENTER_IMPL_H_ 5 #ifndef UI_APP_LIST_PRESENTER_APP_LIST_PRESENTER_IMPL_H_
6 #define UI_APP_LIST_PRESENTER_APP_LIST_PRESENTER_IMPL_H_ 6 #define UI_APP_LIST_PRESENTER_APP_LIST_PRESENTER_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "ui/app_list/pagination_model_observer.h" 12 #include "ui/app_list/pagination_model_observer.h"
13 #include "ui/app_list/presenter/app_list_presenter.h" 13 #include "ui/app_list/presenter/app_list_presenter.mojom.h"
14 #include "ui/app_list/presenter/app_list_presenter_delegate.h" 14 #include "ui/app_list/presenter/app_list_presenter_delegate.h"
15 #include "ui/app_list/presenter/app_list_presenter_export.h"
15 #include "ui/aura/client/focus_change_observer.h" 16 #include "ui/aura/client/focus_change_observer.h"
16 #include "ui/aura/window_observer.h" 17 #include "ui/aura/window_observer.h"
17 #include "ui/compositor/layer_animation_observer.h" 18 #include "ui/compositor/layer_animation_observer.h"
18 #include "ui/gfx/geometry/rect.h" 19 #include "ui/gfx/geometry/rect.h"
19 #include "ui/views/widget/widget_observer.h" 20 #include "ui/views/widget/widget_observer.h"
20 21
21 namespace app_list { 22 namespace app_list {
22 class AppListView; 23 class AppListView;
23 class AppListViewDelegate; 24 class AppListViewDelegate;
24 class AppListPresenterDelegateFactory; 25 class AppListPresenterDelegateFactory;
25 26
26 namespace test { 27 namespace test {
27 class AppListPresenterImplTestApi; 28 class AppListPresenterImplTestApi;
28 } 29 }
29 30
30 class AppListViewDelegate; 31 class AppListViewDelegate;
31 32
32 // Manages app list UI. Creates AppListView and schedules showing/hiding 33 // Manages app list UI. Creates AppListView and schedules showing/hiding
33 // animation. While the UI is visible, it monitors things such as app list 34 // animation. While the UI is visible, it monitors things such as app list
34 // activation state to auto dismiss the UI. Delegates the responsibility 35 // activation state to auto dismiss the UI. Delegates the responsibility
35 // for laying out the app list UI to ash::AppListLayoutDelegate. 36 // for laying out the app list UI to ash::AppListLayoutDelegate.
36 class APP_LIST_PRESENTER_EXPORT AppListPresenterImpl 37 class APP_LIST_PRESENTER_EXPORT AppListPresenterImpl
mfomitchev 2016/12/22 03:17:45 If we are getting rid of AppListPresenter interfac
msw 2016/12/22 16:31:52 I totally agree, I'll do that in a followup! It sh
37 : public AppListPresenter, 38 : public aura::client::FocusChangeObserver,
38 public aura::client::FocusChangeObserver,
39 public aura::WindowObserver, 39 public aura::WindowObserver,
40 public ui::ImplicitAnimationObserver, 40 public ui::ImplicitAnimationObserver,
41 public views::WidgetObserver, 41 public views::WidgetObserver,
42 public PaginationModelObserver { 42 public PaginationModelObserver {
43 public: 43 public:
44 explicit AppListPresenterImpl(AppListPresenterDelegateFactory* factory); 44 explicit AppListPresenterImpl(AppListPresenterDelegateFactory* factory);
45 ~AppListPresenterImpl() override; 45 ~AppListPresenterImpl() override;
46 46
47 // Returns app list window or NULL if it is not visible. 47 // Returns app list window or NULL if it is not visible.
48 aura::Window* GetWindow(); 48 aura::Window* GetWindow();
49 49
50 // Returns app list view if one exists, or NULL otherwise. 50 // Returns app list view if one exists, or NULL otherwise.
51 AppListView* GetView() { return view_; } 51 AppListView* GetView() { return view_; }
52 52
53 // AppListPresenter: 53 // Show/hide app list window. The |window| is used to deterime in which
54 void Show(int64_t display_id) override; 54 // display (in which the |window| exists) the app list should be shown.
55 void Dismiss() final; 55 void Show(int64_t display_id);
56 void ToggleAppList(int64_t display_id) override; 56
57 bool IsVisible() const override; 57 // Invoked to dismiss app list. This may leave the view open but hidden from
58 bool GetTargetVisibility() const override; 58 // the user.
59 void Dismiss();
60
61 // Show the app list if it is visible, hide it if it is hidden.
62 void ToggleAppList(int64_t display_id);
63
64 // Returns current visibility of the app list.
65 bool IsVisible() const;
66
67 // Returns target visibility. This may differ from IsVisible() if a visibility
68 // transition is in progress.
69 bool GetTargetVisibility() const;
70
71 // Sets the app list interface pointer; used to report visibility changes.
72 void SetAppList(mojom::AppListPtr app_list);
59 73
60 private: 74 private:
61 friend class test::AppListPresenterImplTestApi; 75 friend class test::AppListPresenterImplTestApi;
62 76
63 // Sets the app list view and attempts to show it. 77 // Sets the app list view and attempts to show it.
64 void SetView(AppListView* view); 78 void SetView(AppListView* view);
65 79
66 // Forgets the view. 80 // Forgets the view.
67 void ResetView(); 81 void ResetView();
68 82
69 // Starts show/hide animation. 83 // Starts show/hide animation.
70 void ScheduleAnimation(); 84 void ScheduleAnimation();
71 85
72 // aura::client::FocusChangeObserver overrides: 86 // aura::client::FocusChangeObserver overrides:
73 void OnWindowFocused(aura::Window* gained_focus, 87 void OnWindowFocused(aura::Window* gained_focus,
74 aura::Window* lost_focus) override; 88 aura::Window* lost_focus) override;
75 89
76 // aura::WindowObserver overrides: 90 // aura::WindowObserver overrides:
77 void OnWindowBoundsChanged(aura::Window* root, 91 void OnWindowBoundsChanged(aura::Window* root,
78 const gfx::Rect& old_bounds, 92 const gfx::Rect& old_bounds,
79 const gfx::Rect& new_bounds) override; 93 const gfx::Rect& new_bounds) override;
80 94
81 // ui::ImplicitAnimationObserver overrides: 95 // ui::ImplicitAnimationObserver overrides:
82 void OnImplicitAnimationsCompleted() override; 96 void OnImplicitAnimationsCompleted() override;
83 97
84 // views::WidgetObserver overrides: 98 // views::WidgetObserver overrides:
85 void OnWidgetDestroying(views::Widget* widget) override; 99 void OnWidgetDestroying(views::Widget* widget) override;
100 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override;
86 101
87 // PaginationModelObserver overrides: 102 // PaginationModelObserver overrides:
88 void TotalPagesChanged() override; 103 void TotalPagesChanged() override;
89 void SelectedPageChanged(int old_selected, int new_selected) override; 104 void SelectedPageChanged(int old_selected, int new_selected) override;
90 void TransitionStarted() override; 105 void TransitionStarted() override;
91 void TransitionChanged() override; 106 void TransitionChanged() override;
92 107
93 // Not owned 108 // Not owned
94 AppListPresenterDelegateFactory* const factory_; 109 AppListPresenterDelegateFactory* const factory_;
95 110
96 // Responsible for laying out the app list UI. 111 // Responsible for laying out the app list UI.
97 std::unique_ptr<AppListPresenterDelegate> presenter_delegate_; 112 std::unique_ptr<AppListPresenterDelegate> presenter_delegate_;
98 113
99 // Whether we should show or hide app list widget. 114 // Whether we should show or hide app list widget.
100 bool is_visible_ = false; 115 bool is_visible_ = false;
101 116
102 // The AppListView this class manages, owned by its widget. 117 // The AppListView this class manages, owned by its widget.
103 AppListView* view_ = nullptr; 118 AppListView* view_ = nullptr;
104 119
105 // The current page of the AppsGridView of |view_|. This is stored outside of 120 // The current page of the AppsGridView of |view_|. This is stored outside of
106 // the view's PaginationModel, so that it persists when the view is destroyed. 121 // the view's PaginationModel, so that it persists when the view is destroyed.
107 int current_apps_page_ = -1; 122 int current_apps_page_ = -1;
108 123
109 // Cached bounds of |view_| for snapping back animation after over-scroll. 124 // Cached bounds of |view_| for snapping back animation after over-scroll.
110 gfx::Rect view_bounds_; 125 gfx::Rect view_bounds_;
111 126
112 // Whether should schedule snap back animation. 127 // Whether should schedule snap back animation.
113 bool should_snap_back_ = false; 128 bool should_snap_back_ = false;
114 129
130 // The app list interface pointer; used for reporting visibility changes.
131 mojom::AppListPtr app_list_;
132
115 DISALLOW_COPY_AND_ASSIGN(AppListPresenterImpl); 133 DISALLOW_COPY_AND_ASSIGN(AppListPresenterImpl);
116 }; 134 };
117 135
118 } // namespace app_list 136 } // namespace app_list
119 137
120 #endif // UI_APP_LIST_PRESENTER_APP_LIST_PRESENTER_IMPL_H_ 138 #endif // UI_APP_LIST_PRESENTER_APP_LIST_PRESENTER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698