| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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_SEARCH_RESULT_CONTAINER_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_SEARCH_RESULT_CONTAINER_VIEW_H_ |
| 6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_CONTAINER_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_CONTAINER_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "ui/app_list/app_list_model.h" | 9 #include "ui/app_list/app_list_model.h" |
| 10 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 void ClearSelectedIndex(); | 33 void ClearSelectedIndex(); |
| 34 | 34 |
| 35 // The currently selected index. Returns -1 on no selection. | 35 // The currently selected index. Returns -1 on no selection. |
| 36 int selected_index() const { return selected_index_; } | 36 int selected_index() const { return selected_index_; } |
| 37 | 37 |
| 38 // Returns whether |index| is a valid index for selection. | 38 // Returns whether |index| is a valid index for selection. |
| 39 bool IsValidSelectionIndex(int index) const; | 39 bool IsValidSelectionIndex(int index) const; |
| 40 | 40 |
| 41 int num_results() const { return num_results_; } | 41 int num_results() const { return num_results_; } |
| 42 | 42 |
| 43 void set_container_score(double score) { container_score_ = score; } |
| 44 double container_score() const { return container_score_; } |
| 45 |
| 43 // Schedules an Update call using |update_factory_|. Do nothing if there is a | 46 // Schedules an Update call using |update_factory_|. Do nothing if there is a |
| 44 // pending call. | 47 // pending call. |
| 45 void ScheduleUpdate(); | 48 void ScheduleUpdate(); |
| 46 | 49 |
| 47 // Overridden from ui::ListModelObserver: | 50 // Overridden from ui::ListModelObserver: |
| 48 void ListItemsAdded(size_t start, size_t count) override; | 51 void ListItemsAdded(size_t start, size_t count) override; |
| 49 void ListItemsRemoved(size_t start, size_t count) override; | 52 void ListItemsRemoved(size_t start, size_t count) override; |
| 50 void ListItemMoved(size_t index, size_t target_index) override; | 53 void ListItemMoved(size_t index, size_t target_index) override; |
| 51 void ListItemsChanged(size_t start, size_t count) override; | 54 void ListItemsChanged(size_t start, size_t count) override; |
| 52 | 55 |
| 53 // Updates the container for being selected. |from_bottom| is true if the view | 56 // Updates the container for being selected. |from_bottom| is true if the view |
| 54 // was entered into from a selected view below it; false if entered into from | 57 // was entered into from a selected view below it; false if entered into from |
| 55 // above. | 58 // above. |
| 56 virtual void OnContainerSelected(bool from_bottom) = 0; | 59 virtual void OnContainerSelected(bool from_bottom) = 0; |
| 57 | 60 |
| 58 private: | 61 private: |
| 59 // Updates UI with model. Returns the number of visible results. | 62 // Updates UI with model. Returns the number of visible results. |
| 60 virtual int Update() = 0; | 63 virtual int Update() = 0; |
| 61 | 64 |
| 62 // Updates UI for a change in the selected index. | 65 // Updates UI for a change in the selected index. |
| 63 virtual void UpdateSelectedIndex(int old_selected, int new_selected) = 0; | 66 virtual void UpdateSelectedIndex(int old_selected, int new_selected) = 0; |
| 64 | 67 |
| 65 // Batching method that actually performs the update and updates layout. | 68 // Batching method that actually performs the update and updates layout. |
| 66 void DoUpdate(); | 69 void DoUpdate(); |
| 67 | 70 |
| 68 int selected_index_; | 71 int selected_index_; |
| 69 int num_results_; | 72 int num_results_; |
| 70 | 73 |
| 74 double container_score_; |
| 75 |
| 71 AppListModel::SearchResults* results_; // Owned by AppListModel. | 76 AppListModel::SearchResults* results_; // Owned by AppListModel. |
| 72 | 77 |
| 73 // The factory that consolidates multiple Update calls into one. | 78 // The factory that consolidates multiple Update calls into one. |
| 74 base::WeakPtrFactory<SearchResultContainerView> update_factory_; | 79 base::WeakPtrFactory<SearchResultContainerView> update_factory_; |
| 75 | 80 |
| 76 DISALLOW_COPY_AND_ASSIGN(SearchResultContainerView); | 81 DISALLOW_COPY_AND_ASSIGN(SearchResultContainerView); |
| 77 }; | 82 }; |
| 78 | 83 |
| 79 } // namespace app_list | 84 } // namespace app_list |
| 80 | 85 |
| 81 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_CONTAINER_VIEW_H_ | 86 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_CONTAINER_VIEW_H_ |
| OLD | NEW |