Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ash / shelf / shelf_item_delegate_manager.h
blobef11f6859765b6078b7d4042126e235e6555062e
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
3 // found in the LICENSE file.
5 #ifndef ASH_SHELF_SHELF_ITEM_DELEGATE_MANAGER_H_
6 #define ASH_SHELF_SHELF_ITEM_DELEGATE_MANAGER_H_
8 #include <map>
10 #include "ash/ash_export.h"
11 #include "ash/shelf/shelf_item_types.h"
12 #include "ash/shelf/shelf_model_observer.h"
13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h"
16 namespace ash {
17 class ShelfItemDelegate;
18 class ShelfModel;
20 namespace test {
21 class ShelfItemDelegateManagerTestAPI;
24 // ShelfItemDelegateManager manages the set of ShelfItemDelegates for the
25 // launcher. ShelfItemDelegateManager does not create ShelfItemDelegates,
26 // rather it is expected that someone else invokes SetShelfItemDelegate
27 // appropriately. On the other hand, ShelfItemDelegateManager destroys
28 // ShelfItemDelegates when the corresponding item from the model is removed.
29 class ASH_EXPORT ShelfItemDelegateManager : public ShelfModelObserver {
30 public:
31 explicit ShelfItemDelegateManager(ShelfModel* model);
32 virtual ~ShelfItemDelegateManager();
34 // Set |item_delegate| for |id| and take an ownership.
35 void SetShelfItemDelegate(ShelfID id,
36 scoped_ptr<ShelfItemDelegate> item_delegate);
38 // Returns ShelfItemDelegate for |item_type|. Always returns non-NULL.
39 ShelfItemDelegate* GetShelfItemDelegate(ShelfID id);
41 // ShelfModelObserver overrides:
42 virtual void ShelfItemAdded(int model_index) OVERRIDE;
43 virtual void ShelfItemRemoved(int index, ShelfID id) OVERRIDE;
44 virtual void ShelfItemMoved(int start_index, int targetindex) OVERRIDE;
45 virtual void ShelfItemChanged(int index,
46 const ShelfItem& old_item) OVERRIDE;
47 virtual void ShelfStatusChanged() OVERRIDE;
49 private:
50 friend class test::ShelfItemDelegateManagerTestAPI;
52 typedef std::map<ShelfID, ShelfItemDelegate*> ShelfIDToItemDelegateMap;
54 // Remove and destroy ShelfItemDelegate for |id|.
55 void RemoveShelfItemDelegate(ShelfID id);
57 // Owned by Shell.
58 ShelfModel* model_;
60 ShelfIDToItemDelegateMap id_to_item_delegate_map_;
62 DISALLOW_COPY_AND_ASSIGN(ShelfItemDelegateManager);
65 } // namespace ash
67 #endif // ASH_SHELF_SHELF_ITEM_DELEGATE_MANAGER_H_