OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_SHELF_SHELF_MODEL_H_ | 5 #ifndef ASH_SHELF_SHELF_MODEL_H_ |
6 #define ASH_SHELF_SHELF_MODEL_H_ | 6 #define ASH_SHELF_SHELF_MODEL_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/shelf/shelf_item_types.h" | 9 #include "ash/shelf/shelf_item_types.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // Returns a reserved id which will not be used by the |ShelfModel|. | 67 // Returns a reserved id which will not be used by the |ShelfModel|. |
68 ShelfID reserve_external_id() { return next_id_++; } | 68 ShelfID reserve_external_id() { return next_id_++; } |
69 | 69 |
70 // Returns an iterator into items() for the item with the specified id, or | 70 // Returns an iterator into items() for the item with the specified id, or |
71 // items().end() if there is no item with the specified id. | 71 // items().end() if there is no item with the specified id. |
72 ShelfItems::const_iterator ItemByID(ShelfID id) const; | 72 ShelfItems::const_iterator ItemByID(ShelfID id) const; |
73 | 73 |
74 const ShelfItems& items() const { return items_; } | 74 const ShelfItems& items() const { return items_; } |
75 int item_count() const { return static_cast<int>(items_.size()); } | 75 int item_count() const { return static_cast<int>(items_.size()); } |
76 | 76 |
77 void SetStatus(Status status); | 77 void set_status(Status status) { status_ = status; } |
78 Status status() const { return status_; } | 78 Status status() const { return status_; } |
79 | 79 |
80 void AddObserver(ShelfModelObserver* observer); | 80 void AddObserver(ShelfModelObserver* observer); |
81 void RemoveObserver(ShelfModelObserver* observer); | 81 void RemoveObserver(ShelfModelObserver* observer); |
82 | 82 |
83 private: | 83 private: |
84 // Makes sure |index| is in line with the type-based order of items. If that | 84 // Makes sure |index| is in line with the type-based order of items. If that |
85 // is not the case, adjusts index by shifting it to the valid range and | 85 // is not the case, adjusts index by shifting it to the valid range and |
86 // returns the new value. | 86 // returns the new value. |
87 int ValidateInsertionIndex(ShelfItemType type, int index) const; | 87 int ValidateInsertionIndex(ShelfItemType type, int index) const; |
88 | 88 |
89 // ID assigned to the next item. | 89 // ID assigned to the next item. |
90 ShelfID next_id_; | 90 ShelfID next_id_; |
91 | 91 |
92 ShelfItems items_; | 92 ShelfItems items_; |
93 Status status_; | 93 Status status_; |
94 base::ObserverList<ShelfModelObserver> observers_; | 94 base::ObserverList<ShelfModelObserver> observers_; |
95 | 95 |
96 DISALLOW_COPY_AND_ASSIGN(ShelfModel); | 96 DISALLOW_COPY_AND_ASSIGN(ShelfModel); |
97 }; | 97 }; |
98 | 98 |
99 } // namespace ash | 99 } // namespace ash |
100 | 100 |
101 #endif // ASH_SHELF_SHELF_MODEL_H_ | 101 #endif // ASH_SHELF_SHELF_MODEL_H_ |
OLD | NEW |