Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / app_list / cocoa / apps_search_results_model_bridge.h
blob0fe8478954424960555652ea6b6fe10bcbf7568a
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_COCOA_APPS_SEARCH_RESULTS_MODEL_BRIDGE_H_
6 #define UI_APP_LIST_COCOA_APPS_SEARCH_RESULTS_MODEL_BRIDGE_H_
8 #include "base/mac/scoped_nsobject.h"
9 #include "base/memory/scoped_vector.h"
10 #include "ui/base/models/list_model_observer.h"
12 @class NSMenu;
13 @class AppsSearchResultsController;
15 namespace app_list {
17 // Bridge observing the ListModel representing search results in the app list,
18 // and updating the NSTableView where they are displayed.
19 class AppsSearchResultsModelBridge : public ui::ListModelObserver {
20 public:
21 explicit AppsSearchResultsModelBridge(
22 AppsSearchResultsController* results_controller);
23 ~AppsSearchResultsModelBridge() override;
25 // Returns the context menu for the item at |index| in the search results
26 // model. A menu will be generated if it hasn't been previously requested.
27 NSMenu* MenuForItem(size_t index);
29 private:
30 // Lightweight observer to react to icon updates on individual results.
31 class ItemObserver;
33 void UpdateItemObservers();
34 void ReloadDataForItems(size_t start, size_t count) const;
36 // Overridden from ui::ListModelObserver:
37 void ListItemsAdded(size_t start, size_t count) override;
38 void ListItemsRemoved(size_t start, size_t count) override;
39 void ListItemMoved(size_t index, size_t target_index) override;
40 void ListItemsChanged(size_t start, size_t count) override;
42 AppsSearchResultsController* parent_; // Weak. Owns us.
43 ScopedVector<ItemObserver> item_observers_;
45 DISALLOW_COPY_AND_ASSIGN(AppsSearchResultsModelBridge);
48 } // namespace app_list
50 #endif // UI_APP_LIST_COCOA_APPS_SEARCH_RESULTS_MODEL_BRIDGE_H_