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/app_list/app_list_model.h"
11 #include "ui/base/models/list_model_observer.h"
18 // Bridge observing the ListModel representing search results in the app list,
19 // and updating the NSTableView where they are displayed.
20 class AppsSearchResultsModelBridge
: public ui::ListModelObserver
{
22 AppsSearchResultsModelBridge(AppListModel::SearchResults
* results_model
,
23 NSTableView
* results_table_view
);
24 virtual ~AppsSearchResultsModelBridge();
26 // Returns the context menu for the item at |index| in the search results
27 // model. A menu will be generated if it hasn't been previously requested.
28 NSMenu
* MenuForItem(size_t index
);
31 // Lightweight observer to react to icon updates on individual results.
34 void UpdateItemObservers();
35 void ReloadDataForItems(size_t start
, size_t count
) const;
37 // Overridden from ui::ListModelObserver:
38 virtual void ListItemsAdded(size_t start
, size_t count
) OVERRIDE
;
39 virtual void ListItemsRemoved(size_t start
, size_t count
) OVERRIDE
;
40 virtual void ListItemMoved(size_t index
, size_t target_index
) OVERRIDE
;
41 virtual void ListItemsChanged(size_t start
, size_t count
) OVERRIDE
;
43 AppListModel::SearchResults
* results_
; // Weak. Owned by AppListModel.
44 base::scoped_nsobject
<NSTableView
> table_view_
;
45 ScopedVector
<ItemObserver
> item_observers_
;
47 DISALLOW_COPY_AND_ASSIGN(AppsSearchResultsModelBridge
);
50 } // namespace app_list
52 #endif // UI_APP_LIST_COCOA_APPS_SEARCH_RESULTS_MODEL_BRIDGE_H_