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

Side by Side Diff: ash/shelf/shelf_model.h

Issue 71653003: ash: Rename LauncherModel to ShelfModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: chrome changes Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/shelf/overflow_button.h ('k') | ash/shelf/shelf_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_LAUNCHER_LAUNCHER_MODEL_H_ 5 #ifndef ASH_SHELF_SHELF_MODEL_H_
6 #define ASH_LAUNCHER_LAUNCHER_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/launcher/launcher_types.h" 9 #include "ash/launcher/launcher_types.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 12
13 namespace ash { 13 namespace ash {
14 14
15 class ShelfModelObserver; 15 class ShelfModelObserver;
16 16
17 // Model used by ShelfView. 17 // Model used by ShelfView.
18 class ASH_EXPORT LauncherModel { 18 class ASH_EXPORT ShelfModel {
19 public: 19 public:
20 enum Status { 20 enum Status {
21 STATUS_NORMAL, 21 STATUS_NORMAL,
22 // A status that indicates apps are syncing/loading. 22 // A status that indicates apps are syncing/loading.
23 STATUS_LOADING, 23 STATUS_LOADING,
24 }; 24 };
25 25
26 LauncherModel(); 26 ShelfModel();
27 ~LauncherModel(); 27 ~ShelfModel();
28 28
29 // Adds a new item to the model. Returns the resulting index. 29 // Adds a new item to the model. Returns the resulting index.
30 int Add(const LauncherItem& item); 30 int Add(const LauncherItem& item);
31 31
32 // Adds the item. |index| is the requested insertion index, which may be 32 // Adds the item. |index| is the requested insertion index, which may be
33 // modified to meet type-based ordering. Returns the actual insertion index. 33 // modified to meet type-based ordering. Returns the actual insertion index.
34 int AddAt(int index, const LauncherItem& item); 34 int AddAt(int index, const LauncherItem& item);
35 35
36 // Removes the item at |index|. 36 // Removes the item at |index|.
37 void RemoveItemAt(int index); 37 void RemoveItemAt(int index);
38 38
39 // Moves the item at |index| to |target_index|. |target_index| is in terms 39 // Moves the item at |index| to |target_index|. |target_index| is in terms
40 // of the model *after* the item at |index| is removed. 40 // of the model *after* the item at |index| is removed.
41 void Move(int index, int target_index); 41 void Move(int index, int target_index);
42 42
43 // Resets the item at the specified index. The item maintains its existing 43 // Resets the item at the specified index. The item maintains its existing
44 // id and type. 44 // id and type.
45 void Set(int index, const LauncherItem& item); 45 void Set(int index, const LauncherItem& item);
46 46
47 // Returns the index of the item by id. 47 // Returns the index of the item by id.
48 int ItemIndexByID(LauncherID id) const; 48 int ItemIndexByID(LauncherID id) const;
49 49
50 // Returns the index of the first panel or the index where the first panel 50 // Returns the index of the first panel or the index where the first panel
51 // would go if there are no panels. 51 // would go if there are no panels.
52 int FirstPanelIndex() const; 52 int FirstPanelIndex() const;
53 53
54 // Returns the id assigned to the next item added. 54 // Returns the id assigned to the next item added.
55 LauncherID next_id() const { return next_id_; } 55 LauncherID next_id() const { return next_id_; }
56 56
57 // Returns a reserved id which will not be used by the |LauncherModel|. 57 // Returns a reserved id which will not be used by the |ShelfModel|.
58 LauncherID reserve_external_id() { return next_id_++; } 58 LauncherID reserve_external_id() { return next_id_++; }
59 59
60 // Returns an iterator into items() for the item with the specified id, or 60 // Returns an iterator into items() for the item with the specified id, or
61 // items().end() if there is no item with the specified id. 61 // items().end() if there is no item with the specified id.
62 LauncherItems::const_iterator ItemByID(LauncherID id) const; 62 LauncherItems::const_iterator ItemByID(LauncherID id) const;
63 63
64 const LauncherItems& items() const { return items_; } 64 const LauncherItems& items() const { return items_; }
65 int item_count() const { return static_cast<int>(items_.size()); } 65 int item_count() const { return static_cast<int>(items_.size()); }
66 66
67 void SetStatus(Status status); 67 void SetStatus(Status status);
68 Status status() const { return status_; } 68 Status status() const { return status_; }
69 69
70 void AddObserver(ShelfModelObserver* observer); 70 void AddObserver(ShelfModelObserver* observer);
71 void RemoveObserver(ShelfModelObserver* observer); 71 void RemoveObserver(ShelfModelObserver* observer);
72 72
73 private: 73 private:
74 // Makes sure |index| is in line with the type-based order of items. If that 74 // Makes sure |index| is in line with the type-based order of items. If that
75 // is not the case, adjusts index by shifting it to the valid range and 75 // is not the case, adjusts index by shifting it to the valid range and
76 // returns the new value. 76 // returns the new value.
77 int ValidateInsertionIndex(LauncherItemType type, int index) const; 77 int ValidateInsertionIndex(LauncherItemType type, int index) const;
78 78
79 // ID assigned to the next item. 79 // ID assigned to the next item.
80 LauncherID next_id_; 80 LauncherID next_id_;
81 81
82 LauncherItems items_; 82 LauncherItems items_;
83 Status status_; 83 Status status_;
84 ObserverList<ShelfModelObserver> observers_; 84 ObserverList<ShelfModelObserver> observers_;
85 85
86 DISALLOW_COPY_AND_ASSIGN(LauncherModel); 86 DISALLOW_COPY_AND_ASSIGN(ShelfModel);
87 }; 87 };
88 88
89 } // namespace ash 89 } // namespace ash
90 90
91 #endif // ASH_LAUNCHER_LAUNCHER_MODEL_H_ 91 #endif // ASH_SHELF_SHELF_MODEL_H_
OLDNEW
« no previous file with comments | « ash/shelf/overflow_button.h ('k') | ash/shelf/shelf_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698