Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1823)

Unified Diff: ash/common/shelf/shelf_model.h

Issue 2171813004: mash: Fold ShelfItemDelegateManager into ShelfModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..1dba39a533e18b25c887ac4f0b5d2ff0eb86ba06 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 Shutdown();
msw 2016/07/21 21:30:53 nit: DestroyItemDelegates or similar?
James Cook 2016/07/22 01:20:07 Done.
+
// 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);
};

Powered by Google App Engine
This is Rietveld 408576698