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

Side by Side Diff: ui/app_list/views/app_list_main_view.h

Issue 302803002: Refactor app list so AppsGridView owns the PaginationModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments (tapted and xiyuan). Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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"
(...skipping 21 matching lines...) Expand all
32 32
33 // AppListMainView contains the normal view of the app list, which is shown 33 // AppListMainView contains the normal view of the app list, which is shown
34 // when the user is signed in. 34 // when the user is signed in.
35 class APP_LIST_EXPORT AppListMainView : public views::View, 35 class APP_LIST_EXPORT AppListMainView : public views::View,
36 public AppsGridViewDelegate, 36 public AppsGridViewDelegate,
37 public SearchBoxViewDelegate, 37 public SearchBoxViewDelegate,
38 public SearchResultListViewDelegate { 38 public SearchResultListViewDelegate {
39 public: 39 public:
40 // Takes ownership of |delegate|. 40 // Takes ownership of |delegate|.
41 explicit AppListMainView(AppListViewDelegate* delegate, 41 explicit AppListMainView(AppListViewDelegate* delegate,
42 PaginationModel* pagination_model,
43 gfx::NativeView parent); 42 gfx::NativeView parent);
44 virtual ~AppListMainView(); 43 virtual ~AppListMainView();
45 44
46 void ShowAppListWhenReady(); 45 void ShowAppListWhenReady();
47 46
48 void ResetForShow(); 47 void ResetForShow();
49 48
50 void Close(); 49 void Close();
51 50
52 void Prerender(); 51 void Prerender();
(...skipping 14 matching lines...) Expand all
67 ContentsView* contents_view() const { return contents_view_; } 66 ContentsView* contents_view() const { return contents_view_; }
68 67
69 // Returns true if the app list should be centered and in landscape mode. 68 // Returns true if the app list should be centered and in landscape mode.
70 bool ShouldCenterWindow() const; 69 bool ShouldCenterWindow() const;
71 70
72 private: 71 private:
73 class IconLoader; 72 class IconLoader;
74 73
75 void AddContentsView(); 74 void AddContentsView();
76 75
76 // Gets the PaginationModel owned by the AppsGridView.
77 PaginationModel* GetAppsPaginationModel();
78
77 // Loads icon image for the apps in the selected page of |pagination_model_|. 79 // Loads icon image for the apps in the selected page of |pagination_model_|.
78 // |parent| is used to determine the image scale factor to use. 80 // |parent| is used to determine the image scale factor to use.
79 void PreloadIcons(gfx::NativeView parent); 81 void PreloadIcons(gfx::NativeView parent);
80 82
81 // Invoked when |icon_loading_wait_timer_| fires. 83 // Invoked when |icon_loading_wait_timer_| fires.
82 void OnIconLoadingWaitTimer(); 84 void OnIconLoadingWaitTimer();
83 85
84 // Invoked from an IconLoader when icon loading is finished. 86 // Invoked from an IconLoader when icon loading is finished.
85 void OnItemIconLoaded(IconLoader* loader); 87 void OnItemIconLoaded(IconLoader* loader);
86 88
87 // Overridden from views::View: 89 // Overridden from views::View:
88 virtual void ChildVisibilityChanged(views::View* child) OVERRIDE; 90 virtual void ChildVisibilityChanged(views::View* child) OVERRIDE;
89 91
90 // Overridden from AppsGridViewDelegate: 92 // Overridden from AppsGridViewDelegate:
91 virtual void ActivateApp(AppListItem* item, int event_flags) OVERRIDE; 93 virtual void ActivateApp(AppListItem* item, int event_flags) OVERRIDE;
92 virtual void GetShortcutPathForApp( 94 virtual void GetShortcutPathForApp(
93 const std::string& app_id, 95 const std::string& app_id,
94 const base::Callback<void(const base::FilePath&)>& callback) OVERRIDE; 96 const base::Callback<void(const base::FilePath&)>& callback) OVERRIDE;
95 97
96 // Overridden from SearchBoxViewDelegate: 98 // Overridden from SearchBoxViewDelegate:
97 virtual void QueryChanged(SearchBoxView* sender) OVERRIDE; 99 virtual void QueryChanged(SearchBoxView* sender) OVERRIDE;
98 100
99 // Overridden from SearchResultListViewDelegate: 101 // Overridden from SearchResultListViewDelegate:
100 virtual void OnResultInstalled(SearchResult* result) OVERRIDE; 102 virtual void OnResultInstalled(SearchResult* result) OVERRIDE;
101 virtual void OnResultUninstalled(SearchResult* result) OVERRIDE; 103 virtual void OnResultUninstalled(SearchResult* result) OVERRIDE;
102 104
103 AppListViewDelegate* delegate_; // Owned by parent view (AppListView). 105 AppListViewDelegate* delegate_; // Owned by parent view (AppListView).
104 PaginationModel* pagination_model_; // Owned by AppListController.
105 AppListModel* model_; // Unowned; ownership is handled by |delegate_|. 106 AppListModel* model_; // Unowned; ownership is handled by |delegate_|.
106 107
107 SearchBoxView* search_box_view_; // Owned by views hierarchy. 108 SearchBoxView* search_box_view_; // Owned by views hierarchy.
108 ContentsView* contents_view_; // Owned by views hierarchy. 109 ContentsView* contents_view_; // Owned by views hierarchy.
109 110
110 // A timer that fires when maximum allowed time to wait for icon loading has 111 // A timer that fires when maximum allowed time to wait for icon loading has
111 // passed. 112 // passed.
112 base::OneShotTimer<AppListMainView> icon_loading_wait_timer_; 113 base::OneShotTimer<AppListMainView> icon_loading_wait_timer_;
113 114
114 ScopedVector<IconLoader> pending_icon_loaders_; 115 ScopedVector<IconLoader> pending_icon_loaders_;
115 116
116 base::WeakPtrFactory<AppListMainView> weak_ptr_factory_; 117 base::WeakPtrFactory<AppListMainView> weak_ptr_factory_;
117 118
118 DISALLOW_COPY_AND_ASSIGN(AppListMainView); 119 DISALLOW_COPY_AND_ASSIGN(AppListMainView);
119 }; 120 };
120 121
121 } // namespace app_list 122 } // namespace app_list
122 123
123 #endif // UI_APP_LIST_VIEWS_APP_LIST_MAIN_VIEW_H_ 124 #endif // UI_APP_LIST_VIEWS_APP_LIST_MAIN_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698