| Index: ash/common/shelf/shelf_model.h
|
| diff --git a/ash/common/shelf/shelf_model.h b/ash/common/shelf/shelf_model.h
|
| index deeffac9d7ad21ff4202b904aa8d875ac74ce3f2..112f0b42905a22f063f94c4749aa6cb9ab47ec36 100644
|
| --- a/ash/common/shelf/shelf_model.h
|
| +++ b/ash/common/shelf/shelf_model.h
|
| @@ -5,6 +5,9 @@
|
| #ifndef ASH_COMMON_SHELF_SHELF_MODEL_H_
|
| #define ASH_COMMON_SHELF_SHELF_MODEL_H_
|
|
|
| +#include <map>
|
| +#include <memory>
|
| +
|
| #include "ash/ash_export.h"
|
| #include "ash/common/shelf/shelf_item_types.h"
|
| #include "base/macros.h"
|
| @@ -12,9 +15,11 @@
|
|
|
| namespace ash {
|
|
|
| +class ShelfItemDelegate;
|
| class ShelfModelObserver;
|
|
|
| -// Model used by ShelfView.
|
| +// Model used for shelf items. Owns ShelfItemDelegates, but does not create
|
| +// them.
|
| class ASH_EXPORT ShelfModel {
|
| public:
|
| enum Status {
|
| @@ -26,6 +31,9 @@ class ASH_EXPORT ShelfModel {
|
| ShelfModel();
|
| ~ShelfModel();
|
|
|
| + // Cleans up the ShelfItemDelegates.
|
| + void DestroyItemDelegates();
|
| +
|
| // Adds a new item to the model. Returns the resulting index.
|
| int Add(const ShelfItem& item);
|
|
|
| @@ -77,6 +85,13 @@ class ASH_EXPORT ShelfModel {
|
| void set_status(Status status) { status_ = status; }
|
| Status status() const { return status_; }
|
|
|
| + // Set |item_delegate| for |id| and takes ownership.
|
| + void SetShelfItemDelegate(ShelfID id,
|
| + std::unique_ptr<ShelfItemDelegate> item_delegate);
|
| +
|
| + // Returns ShelfItemDelegate for |id|, or null if none exists.
|
| + ShelfItemDelegate* GetShelfItemDelegate(ShelfID id);
|
| +
|
| void AddObserver(ShelfModelObserver* observer);
|
| void RemoveObserver(ShelfModelObserver* observer);
|
|
|
| @@ -86,6 +101,9 @@ class ASH_EXPORT ShelfModel {
|
| // returns the new value.
|
| int ValidateInsertionIndex(ShelfItemType type, int index) const;
|
|
|
| + // Remove and destroy ShelfItemDelegate for |id|.
|
| + void RemoveShelfItemDelegate(ShelfID id);
|
| +
|
| // ID assigned to the next item.
|
| ShelfID next_id_;
|
|
|
| @@ -93,6 +111,9 @@ class ASH_EXPORT ShelfModel {
|
| Status status_;
|
| base::ObserverList<ShelfModelObserver> observers_;
|
|
|
| + std::map<ShelfID, std::unique_ptr<ShelfItemDelegate>>
|
| + id_to_item_delegate_map_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(ShelfModel);
|
| };
|
|
|
|
|