| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_VIEWS_APP_LIST_MAIN_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_APP_LIST_MAIN_VIEW_H_ |
| 6 #define UI_APP_LIST_VIEWS_APP_LIST_MAIN_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_APP_LIST_MAIN_VIEW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/observer_list.h" |
| 12 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
| 13 #include "ui/app_list/app_list_export.h" | 14 #include "ui/app_list/app_list_export.h" |
| 14 #include "ui/app_list/views/apps_grid_view_delegate.h" | 15 #include "ui/app_list/views/apps_grid_view_delegate.h" |
| 15 #include "ui/app_list/views/search_box_view_delegate.h" | 16 #include "ui/app_list/views/search_box_view_delegate.h" |
| 16 #include "ui/app_list/views/search_result_list_view_delegate.h" | 17 #include "ui/app_list/views/search_result_list_view_delegate.h" |
| 17 #include "ui/views/view.h" | 18 #include "ui/views/view.h" |
| 18 | 19 |
| 19 namespace views { | 20 namespace views { |
| 20 class Widget; | 21 class Widget; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace app_list { | 24 namespace app_list { |
| 24 | 25 |
| 25 class AppListItem; | 26 class AppListItem; |
| 26 class AppListModel; | 27 class AppListModel; |
| 27 class AppListViewDelegate; | 28 class AppListViewDelegate; |
| 28 class ApplicationDragAndDropHost; | 29 class ApplicationDragAndDropHost; |
| 29 class ContentsSwitcherView; | 30 class ContentsSwitcherView; |
| 30 class ContentsView; | 31 class ContentsView; |
| 31 class PaginationModel; | 32 class PaginationModel; |
| 32 class SearchBoxView; | 33 class SearchBoxView; |
| 33 | 34 |
| 35 class AppListMainViewObserver { |
| 36 public: |
| 37 // Invoked after a new contents view is created. |
| 38 virtual void OnContentsViewCreated() {} |
| 39 |
| 40 // Invoked before the contens view is destroyed. |
| 41 virtual void OnContentsViewDestroying() {} |
| 42 |
| 43 protected: |
| 44 virtual ~AppListMainViewObserver() {} |
| 45 }; |
| 46 |
| 34 // AppListMainView contains the normal view of the app list, which is shown | 47 // AppListMainView contains the normal view of the app list, which is shown |
| 35 // when the user is signed in. | 48 // when the user is signed in. |
| 36 class APP_LIST_EXPORT AppListMainView : public views::View, | 49 class APP_LIST_EXPORT AppListMainView : public views::View, |
| 37 public AppsGridViewDelegate, | 50 public AppsGridViewDelegate, |
| 38 public SearchBoxViewDelegate, | 51 public SearchBoxViewDelegate, |
| 39 public SearchResultListViewDelegate { | 52 public SearchResultListViewDelegate { |
| 40 public: | 53 public: |
| 41 // Takes ownership of |delegate|. | 54 // Takes ownership of |delegate|. |
| 42 explicit AppListMainView(AppListViewDelegate* delegate); | 55 explicit AppListMainView(AppListViewDelegate* delegate); |
| 43 ~AppListMainView() override; | 56 ~AppListMainView() override; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 72 return contents_switcher_view_; | 85 return contents_switcher_view_; |
| 73 } | 86 } |
| 74 AppListModel* model() { return model_; } | 87 AppListModel* model() { return model_; } |
| 75 | 88 |
| 76 // Returns true if the app list should be centered and in landscape mode. | 89 // Returns true if the app list should be centered and in landscape mode. |
| 77 bool ShouldCenterWindow() const; | 90 bool ShouldCenterWindow() const; |
| 78 | 91 |
| 79 // Called when the search box's visibility is changed. | 92 // Called when the search box's visibility is changed. |
| 80 void NotifySearchBoxVisibilityChanged(); | 93 void NotifySearchBoxVisibilityChanged(); |
| 81 | 94 |
| 95 void AddObserver(AppListMainViewObserver* observer); |
| 96 void RemoveObserver(AppListMainViewObserver* observer); |
| 97 |
| 82 private: | 98 private: |
| 83 class IconLoader; | 99 class IconLoader; |
| 84 | 100 |
| 85 // Adds the ContentsView and the ContentsSwitcherView. | 101 // Adds the ContentsView and the ContentsSwitcherView. |
| 86 void AddContentsViews(); | 102 void AddContentsViews(); |
| 87 | 103 |
| 88 // Gets the PaginationModel owned by the AppsGridView. | 104 // Gets the PaginationModel owned by the AppsGridView. |
| 89 PaginationModel* GetAppsPaginationModel(); | 105 PaginationModel* GetAppsPaginationModel(); |
| 90 | 106 |
| 91 // Loads icon image for the apps in the selected page of |pagination_model_|. | 107 // Loads icon image for the apps in the selected page of |pagination_model_|. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 ContentsSwitcherView* contents_switcher_view_; | 139 ContentsSwitcherView* contents_switcher_view_; |
| 124 | 140 |
| 125 // A timer that fires when maximum allowed time to wait for icon loading has | 141 // A timer that fires when maximum allowed time to wait for icon loading has |
| 126 // passed. | 142 // passed. |
| 127 base::OneShotTimer<AppListMainView> icon_loading_wait_timer_; | 143 base::OneShotTimer<AppListMainView> icon_loading_wait_timer_; |
| 128 | 144 |
| 129 ScopedVector<IconLoader> pending_icon_loaders_; | 145 ScopedVector<IconLoader> pending_icon_loaders_; |
| 130 | 146 |
| 131 base::WeakPtrFactory<AppListMainView> weak_ptr_factory_; | 147 base::WeakPtrFactory<AppListMainView> weak_ptr_factory_; |
| 132 | 148 |
| 149 ObserverList<AppListMainViewObserver, true> observers_; |
| 150 |
| 133 DISALLOW_COPY_AND_ASSIGN(AppListMainView); | 151 DISALLOW_COPY_AND_ASSIGN(AppListMainView); |
| 134 }; | 152 }; |
| 135 | 153 |
| 136 } // namespace app_list | 154 } // namespace app_list |
| 137 | 155 |
| 138 #endif // UI_APP_LIST_VIEWS_APP_LIST_MAIN_VIEW_H_ | 156 #endif // UI_APP_LIST_VIEWS_APP_LIST_MAIN_VIEW_H_ |
| OLD | NEW |