Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ui / app_list / views / search_result_list_view.h
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
5 #ifndef UI_APP_LIST_VIEWS_SEARCH_RESULT_LIST_VIEW_H_
6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_LIST_VIEW_H_
7
8 #include "base/basictypes.h"
9 #include "base/memory/weak_ptr.h"
10 #include "ui/app_list/views/search_result_container_view.h"
11 #include "ui/gfx/animation/animation_delegate.h"
12 #include "ui/views/view.h"
13
14 namespace gfx {
15 class LinearAnimation;
16 }
17
18 namespace app_list {
19 namespace test {
20 class SearchResultListViewTest;
21 }
22
23 class AppListViewDelegate;
24 class SearchResultListViewDelegate;
25 class SearchResultView;
26
27 // SearchResultListView displays SearchResultList with a list of
28 // SearchResultView.
29 class APP_LIST_EXPORT SearchResultListView : public gfx::AnimationDelegate,
30                                              public SearchResultContainerView {
31  public:
32   SearchResultListView(SearchResultListViewDelegate* delegate,
33                        AppListViewDelegate* view_delegate);
34   ~SearchResultListView() override;
35
36   void SetSelectedIndex(int selected_index);
37
38   void UpdateAutoLaunchState();
39
40   bool IsResultViewSelected(const SearchResultView* result_view) const;
41
42   void SearchResultActivated(SearchResultView* view, int event_flags);
43
44   void SearchResultActionActivated(SearchResultView* view,
45                                    size_t action_index,
46                                    int event_flags);
47
48   void OnSearchResultInstalled(SearchResultView* view);
49
50   void OnSearchResultUninstalled(SearchResultView* view);
51
52   // Overridden from views::View:
53   bool OnKeyPressed(const ui::KeyEvent& event) override;
54   gfx::Size GetPreferredSize() const override;
55
56   // Overridden from ui::ListModelObserver:
57   void ListItemsRemoved(size_t start, size_t count) override;
58
59   // Overridden from SearchResultContainerView:
60   void Update() override;
61
62  private:
63   friend class test::SearchResultListViewTest;
64
65   // Updates the auto launch states.
66   void SetAutoLaunchTimeout(const base::TimeDelta& timeout);
67   void CancelAutoLaunchTimeout();
68
69   // Helper function to get SearchResultView at given |index|.
70   SearchResultView* GetResultViewAt(int index);
71
72   // Forcibly auto-launch for test if it is in auto-launching state.
73   void ForceAutoLaunchForTest();
74
75   // Overridden from views::View:
76   void Layout() override;
77   int GetHeightForWidth(int w) const override;
78   void VisibilityChanged(views::View* starting_from, bool is_visible) override;
79
80   // Overridden from gfx::AnimationDelegate:
81   void AnimationEnded(const gfx::Animation* animation) override;
82   void AnimationProgressed(const gfx::Animation* animation) override;
83
84   SearchResultListViewDelegate* delegate_;  // Not owned.
85   AppListViewDelegate* view_delegate_;  // Not owned.
86
87   views::View* results_container_;
88   views::View* auto_launch_indicator_;
89   scoped_ptr<gfx::LinearAnimation> auto_launch_animation_;
90
91   int last_visible_index_;
92   int selected_index_;
93
94   DISALLOW_COPY_AND_ASSIGN(SearchResultListView);
95 };
96
97 }  // namespace app_list
98
99 #endif  // UI_APP_LIST_VIEWS_SEARCH_RESULT_LIST_VIEW_H_