Add Hide and Show to the app list SearchBoxView.
[chromium-blink-merge.git] / ui / app_list / views / app_list_main_view.h
blob7cfa116e3438d59c195757fa9eca37cb14ae37f1
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
3 // found in the LICENSE file.
5 #ifndef UI_APP_LIST_VIEWS_APP_LIST_MAIN_VIEW_H_
6 #define UI_APP_LIST_VIEWS_APP_LIST_MAIN_VIEW_H_
8 #include <string>
10 #include "base/memory/scoped_vector.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/timer/timer.h"
13 #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/search_box_view_delegate.h"
16 #include "ui/app_list/views/search_result_list_view_delegate.h"
17 #include "ui/views/view.h"
19 namespace views {
20 class Widget;
23 namespace app_list {
25 class AppListItem;
26 class AppListModel;
27 class AppListViewDelegate;
28 class ApplicationDragAndDropHost;
29 class ContentsView;
30 class PaginationModel;
31 class SearchBoxView;
33 // AppListMainView contains the normal view of the app list, which is shown
34 // when the user is signed in.
35 class APP_LIST_EXPORT AppListMainView : public views::View,
36 public AppsGridViewDelegate,
37 public SearchBoxViewDelegate,
38 public SearchResultListViewDelegate {
39 public:
40 // Takes ownership of |delegate|.
41 explicit AppListMainView(AppListViewDelegate* delegate,
42 PaginationModel* pagination_model,
43 gfx::NativeView parent);
44 virtual ~AppListMainView();
46 void ShowAppListWhenReady();
48 void Close();
50 void Prerender();
52 void ModelChanged();
54 SearchBoxView* search_box_view() const { return search_box_view_; }
56 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop
57 // operations outside the application list.
58 void SetDragAndDropHostOfCurrentAppList(
59 ApplicationDragAndDropHost* drag_and_drop_host);
61 ContentsView* contents_view() const { return contents_view_; }
63 private:
64 class IconLoader;
66 void AddContentsView();
68 // Loads icon image for the apps in the selected page of |pagination_model_|.
69 // |parent| is used to determine the image scale factor to use.
70 void PreloadIcons(gfx::NativeView parent);
72 // Invoked when |icon_loading_wait_timer_| fires.
73 void OnIconLoadingWaitTimer();
75 // Invoked from an IconLoader when icon loading is finished.
76 void OnItemIconLoaded(IconLoader* loader);
78 // Overridden from views::View:
79 virtual void ChildVisibilityChanged(views::View* child) OVERRIDE;
81 // Overridden from AppsGridViewDelegate:
82 virtual void ActivateApp(AppListItem* item, int event_flags) OVERRIDE;
83 virtual void GetShortcutPathForApp(
84 const std::string& app_id,
85 const base::Callback<void(const base::FilePath&)>& callback) OVERRIDE;
87 // Overridden from SearchBoxViewDelegate:
88 virtual void QueryChanged(SearchBoxView* sender) OVERRIDE;
90 // Overridden from SearchResultListViewDelegate:
91 virtual void OnResultInstalled(SearchResult* result) OVERRIDE;
92 virtual void OnResultUninstalled(SearchResult* result) OVERRIDE;
94 AppListViewDelegate* delegate_; // Owned by parent view (AppListView).
95 PaginationModel* pagination_model_; // Owned by AppListController.
96 AppListModel* model_; // Unowned; ownership is handled by |delegate_|.
98 SearchBoxView* search_box_view_; // Owned by views hierarchy.
99 ContentsView* contents_view_; // Owned by views hierarchy.
101 // A timer that fires when maximum allowed time to wait for icon loading has
102 // passed.
103 base::OneShotTimer<AppListMainView> icon_loading_wait_timer_;
105 ScopedVector<IconLoader> pending_icon_loaders_;
107 base::WeakPtrFactory<AppListMainView> weak_ptr_factory_;
109 DISALLOW_COPY_AND_ASSIGN(AppListMainView);
112 } // namespace app_list
114 #endif // UI_APP_LIST_VIEWS_APP_LIST_MAIN_VIEW_H_