OLD | NEW |
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_LAUNCHER_LAUNCHER_MODEL_H_ |
6 #define ASH_LAUNCHER_LAUNCHER_MODEL_H_ | 6 #define ASH_LAUNCHER_LAUNCHER_MODEL_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/ash_export.h" | 10 #include "ash/ash_export.h" |
11 #include "ash/launcher/launcher_types.h" | 11 #include "ash/launcher/launcher_types.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 | 13 |
14 namespace aura { | 14 namespace aura { |
15 class Window; | 15 class Window; |
16 } | 16 } |
17 | 17 |
18 namespace ash { | 18 namespace ash { |
19 | 19 |
20 class LauncherModelObserver; | 20 class LauncherModelObserver; |
21 | 21 |
22 // Model used by LauncherView. | 22 // Model used by LauncherView. |
23 class ASH_EXPORT LauncherModel { | 23 class ASH_EXPORT LauncherModel { |
24 public: | 24 public: |
| 25 enum Status { |
| 26 STATUS_NORMAL, |
| 27 // A status that indicates apps are syncing/loading. |
| 28 STATUS_LOADING, |
| 29 }; |
| 30 |
25 LauncherModel(); | 31 LauncherModel(); |
26 ~LauncherModel(); | 32 ~LauncherModel(); |
27 | 33 |
28 // Adds a new item to the model. Returns the resulting index. | 34 // Adds a new item to the model. Returns the resulting index. |
29 int Add(const LauncherItem& item); | 35 int Add(const LauncherItem& item); |
30 | 36 |
31 // Adds the item. |index| is the requested insertion index, which may be | 37 // Adds the item. |index| is the requested insertion index, which may be |
32 // modified to meet type-based ordering. Returns the actual insertion index. | 38 // modified to meet type-based ordering. Returns the actual insertion index. |
33 int AddAt(int index, const LauncherItem& item); | 39 int AddAt(int index, const LauncherItem& item); |
34 | 40 |
(...skipping 14 matching lines...) Expand all Loading... |
49 // Returns the id assigned to the next item added. | 55 // Returns the id assigned to the next item added. |
50 LauncherID next_id() const { return next_id_; } | 56 LauncherID next_id() const { return next_id_; } |
51 | 57 |
52 // Returns an iterator into items() for the item with the specified id, or | 58 // Returns an iterator into items() for the item with the specified id, or |
53 // items().end() if there is no item with the specified id. | 59 // items().end() if there is no item with the specified id. |
54 LauncherItems::const_iterator ItemByID(LauncherID id) const; | 60 LauncherItems::const_iterator ItemByID(LauncherID id) const; |
55 | 61 |
56 const LauncherItems& items() const { return items_; } | 62 const LauncherItems& items() const { return items_; } |
57 int item_count() const { return static_cast<int>(items_.size()); } | 63 int item_count() const { return static_cast<int>(items_.size()); } |
58 | 64 |
| 65 void SetStatus(Status status); |
| 66 Status status() const { return status_; } |
| 67 |
59 void AddObserver(LauncherModelObserver* observer); | 68 void AddObserver(LauncherModelObserver* observer); |
60 void RemoveObserver(LauncherModelObserver* observer); | 69 void RemoveObserver(LauncherModelObserver* observer); |
61 | 70 |
62 private: | 71 private: |
63 // Makes sure |index| is in line with the type-based order of items. If that | 72 // Makes sure |index| is in line with the type-based order of items. If that |
64 // is not the case, adjusts index by shifting it to the valid range and | 73 // is not the case, adjusts index by shifting it to the valid range and |
65 // returns the new value. | 74 // returns the new value. |
66 int ValidateInsertionIndex(LauncherItemType type, int index) const; | 75 int ValidateInsertionIndex(LauncherItemType type, int index) const; |
67 | 76 |
68 // ID assigned to the next item. | 77 // ID assigned to the next item. |
69 LauncherID next_id_; | 78 LauncherID next_id_; |
70 LauncherItems items_; | 79 LauncherItems items_; |
| 80 Status status_; |
71 ObserverList<LauncherModelObserver> observers_; | 81 ObserverList<LauncherModelObserver> observers_; |
72 | 82 |
73 DISALLOW_COPY_AND_ASSIGN(LauncherModel); | 83 DISALLOW_COPY_AND_ASSIGN(LauncherModel); |
74 }; | 84 }; |
75 | 85 |
76 } // namespace ash | 86 } // namespace ash |
77 | 87 |
78 #endif // ASH_LAUNCHER_LAUNCHER_MODEL_H_ | 88 #endif // ASH_LAUNCHER_LAUNCHER_MODEL_H_ |
OLD | NEW |