| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef UI_APP_LIST_COCOA_APPS_SEARCH_RESULTS_MODEL_BRIDGE_H_ | |
| 6 #define UI_APP_LIST_COCOA_APPS_SEARCH_RESULTS_MODEL_BRIDGE_H_ | |
| 7 | |
| 8 #include <stddef.h> | |
| 9 | |
| 10 #include "base/mac/scoped_nsobject.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/scoped_vector.h" | |
| 13 #include "ui/base/models/list_model_observer.h" | |
| 14 | |
| 15 @class NSMenu; | |
| 16 @class AppsSearchResultsController; | |
| 17 | |
| 18 namespace app_list { | |
| 19 | |
| 20 // Bridge observing the ListModel representing search results in the app list, | |
| 21 // and updating the NSTableView where they are displayed. | |
| 22 class AppsSearchResultsModelBridge : public ui::ListModelObserver { | |
| 23 public: | |
| 24 explicit AppsSearchResultsModelBridge( | |
| 25 AppsSearchResultsController* results_controller); | |
| 26 ~AppsSearchResultsModelBridge() override; | |
| 27 | |
| 28 // Returns the context menu for the item at |index| in the search results | |
| 29 // model. A menu will be generated if it hasn't been previously requested. | |
| 30 NSMenu* MenuForItem(size_t index); | |
| 31 | |
| 32 private: | |
| 33 // Lightweight observer to react to icon updates on individual results. | |
| 34 class ItemObserver; | |
| 35 | |
| 36 void UpdateItemObservers(); | |
| 37 void ReloadDataForItems(size_t start, size_t count) const; | |
| 38 | |
| 39 // Overridden from ui::ListModelObserver: | |
| 40 void ListItemsAdded(size_t start, size_t count) override; | |
| 41 void ListItemsRemoved(size_t start, size_t count) override; | |
| 42 void ListItemMoved(size_t index, size_t target_index) override; | |
| 43 void ListItemsChanged(size_t start, size_t count) override; | |
| 44 | |
| 45 AppsSearchResultsController* parent_; // Weak. Owns us. | |
| 46 ScopedVector<ItemObserver> item_observers_; | |
| 47 | |
| 48 DISALLOW_COPY_AND_ASSIGN(AppsSearchResultsModelBridge); | |
| 49 }; | |
| 50 | |
| 51 } // namespace app_list | |
| 52 | |
| 53 #endif // UI_APP_LIST_COCOA_APPS_SEARCH_RESULTS_MODEL_BRIDGE_H_ | |
| OLD | NEW |