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

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

Issue 2791463002: mash: Remove ShelfDelegate; move functions to ShelfModel. (Closed)
Patch Set: Sync and rebase; cleanup. Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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 <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 10
11 #include "ash/ash_export.h" 11 #include "ash/ash_export.h"
12 #include "ash/public/cpp/app_launch_id.h"
12 #include "ash/public/cpp/shelf_item.h" 13 #include "ash/public/cpp/shelf_item.h"
13 #include "ash/public/interfaces/shelf.mojom.h" 14 #include "ash/public/interfaces/shelf.mojom.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/observer_list.h" 16 #include "base/observer_list.h"
16 17
17 namespace ash { 18 namespace ash {
18 19
19 class ShelfItemDelegate; 20 class ShelfItemDelegate;
20 class ShelfModelObserver; 21 class ShelfModelObserver;
21 22
22 // Model used for shelf items. Owns ShelfItemDelegates but does not create them. 23 // Model used for shelf items. Owns ShelfItemDelegates but does not create them.
23 class ASH_EXPORT ShelfModel { 24 class ASH_EXPORT ShelfModel {
24 public: 25 public:
25 ShelfModel(); 26 ShelfModel();
26 ~ShelfModel(); 27 ~ShelfModel();
27 28
29 // Get the shelf ID from an application ID. Returns kInvalidShelfID if the
30 // app id is unknown, or has no associated ShelfID.
31 ShelfID GetShelfIDForAppID(const std::string& app_id);
32
33 // Get the shelf ID from an application ID and a launch ID.
34 // The launch ID can be passed to an app when launched in order to support
35 // multiple shelf items per app. This id is used together with the app_id to
36 // uniquely identify each shelf item that has the same app_id.
37 // For example, a single virtualization app might want to show different
38 // shelf icons for different remote apps. Returns kInvalidShelfID if the app
39 // id is unknown or has no associated ShelfID.
40 ShelfID GetShelfIDForAppIDAndLaunchID(const std::string& app_id,
41 const std::string& launch_id);
42
43 // Get the application ID for a given shelf ID. Returns an empty string for
44 // an unknown or invalid ShelfID.
45 const std::string& GetAppIDForShelfID(ShelfID id);
46
47 // Pins an app with |app_id| to shelf. A running instance will get pinned.
48 // In case there is no running instance a new shelf item is created and
49 // pinned.
50 void PinAppWithID(const std::string& app_id);
51
52 // Check if the app with |app_id_| is pinned to the shelf.
53 bool IsAppPinned(const std::string& app_id);
54
55 // Unpins app item with |app_id|.
56 void UnpinAppWithID(const std::string& app_id);
57
28 // Cleans up the ShelfItemDelegates. 58 // Cleans up the ShelfItemDelegates.
29 void DestroyItemDelegates(); 59 void DestroyItemDelegates();
30 60
31 // Adds a new item to the model. Returns the resulting index. 61 // Adds a new item to the model. Returns the resulting index.
32 int Add(const ShelfItem& item); 62 int Add(const ShelfItem& item);
33 63
34 // Adds the item. |index| is the requested insertion index, which may be 64 // Adds the item. |index| is the requested insertion index, which may be
35 // modified to meet type-based ordering. Returns the actual insertion index. 65 // modified to meet type-based ordering. Returns the actual insertion index.
36 int AddAt(int index, const ShelfItem& item); 66 int AddAt(int index, const ShelfItem& item);
37 67
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 130
101 std::map<ShelfID, std::unique_ptr<ShelfItemDelegate>> 131 std::map<ShelfID, std::unique_ptr<ShelfItemDelegate>>
102 id_to_item_delegate_map_; 132 id_to_item_delegate_map_;
103 133
104 DISALLOW_COPY_AND_ASSIGN(ShelfModel); 134 DISALLOW_COPY_AND_ASSIGN(ShelfModel);
105 }; 135 };
106 136
107 } // namespace ash 137 } // namespace ash
108 138
109 #endif // ASH_SHELF_SHELF_MODEL_H_ 139 #endif // ASH_SHELF_SHELF_MODEL_H_
OLDNEW
« no previous file with comments | « ash/shelf/shelf_delegate.h ('k') | ash/shelf/shelf_model.cc » ('j') | ash/shelf/shelf_model.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698