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
3 // found in the LICENSE file.
5 #ifndef UI_APP_LIST_VIEWS_SEARCH_RESULT_CONTAINER_VIEW_H_
6 #define UI_APP_LIST_VIEWS_SEARCH_RESULT_CONTAINER_VIEW_H_
8 #include "base/memory/weak_ptr.h"
9 #include "ui/app_list/app_list_model.h"
10 #include "ui/views/view.h"
14 // SearchResultContainerView is a base class that batches updates from a
16 class APP_LIST_EXPORT SearchResultContainerView : public views::View,
17 public ui::ListModelObserver {
19 SearchResultContainerView();
20 ~SearchResultContainerView() override;
22 void SetResults(AppListModel::SearchResults* results);
24 AppListModel::SearchResults* results() { return results_; }
26 // Schedules an Update call using |update_factory_|. Do nothing if there is a
28 void ScheduleUpdate();
30 // Overridden from ui::ListModelObserver:
31 void ListItemsAdded(size_t start, size_t count) override;
32 void ListItemsRemoved(size_t start, size_t count) override;
33 void ListItemMoved(size_t index, size_t target_index) override;
34 void ListItemsChanged(size_t start, size_t count) override;
36 // Updates UI with model.
37 virtual void Update() = 0;
42 AppListModel::SearchResults* results_; // Owned by AppListModel.
44 // The factory that consolidates multiple Update calls into one.
45 base::WeakPtrFactory<SearchResultContainerView> update_factory_;
47 DISALLOW_COPY_AND_ASSIGN(SearchResultContainerView);
50 } // namespace app_list
52 #endif // UI_APP_LIST_VIEWS_SEARCH_RESULT_CONTAINER_VIEW_H_