OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_COMMON_SHELF_SHELF_CONTROLLER_H_ | 5 #ifndef ASH_COMMON_SHELF_SHELF_CONTROLLER_H_ |
6 #define ASH_COMMON_SHELF_SHELF_CONTROLLER_H_ | 6 #define ASH_COMMON_SHELF_SHELF_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "ash/common/shelf/shelf_item_types.h" | 11 #include "ash/common/shelf/shelf_item_types.h" |
12 #include "ash/common/shelf/shelf_model.h" | 12 #include "ash/common/shelf/shelf_model.h" |
13 #include "ash/public/cpp/shelf_types.h" | 13 #include "ash/public/cpp/shelf_types.h" |
14 #include "ash/public/interfaces/shelf.mojom.h" | 14 #include "ash/public/interfaces/shelf.mojom.h" |
| 15 #include "components/prefs/pref_store.h" |
15 #include "mojo/public/cpp/bindings/binding_set.h" | 16 #include "mojo/public/cpp/bindings/binding_set.h" |
16 #include "mojo/public/cpp/bindings/interface_ptr_set.h" | 17 #include "mojo/public/cpp/bindings/interface_ptr_set.h" |
17 | 18 |
18 namespace ash { | 19 namespace ash { |
19 | 20 |
20 class WmShelf; | 21 class WmShelf; |
21 | 22 |
22 // Ash's implementation of the mojom::ShelfController interface. Chrome connects | 23 // Ash's implementation of the mojom::ShelfController interface. Chrome connects |
23 // to this interface to observe and manage the per-display ash shelf instances. | 24 // to this interface to observe and manage the per-display ash shelf instances. |
24 class ShelfController : public mojom::ShelfController { | 25 class ShelfController : public mojom::ShelfController, |
| 26 public PrefStore::Observer { |
25 public: | 27 public: |
26 ShelfController(); | 28 ShelfController(); |
27 ~ShelfController() override; | 29 ~ShelfController() override; |
28 | 30 |
29 // Binds the mojom::ShelfController interface request to this object. | 31 // Binds the mojom::ShelfController interface request to this object. |
30 void BindRequest(mojom::ShelfControllerRequest request); | 32 void BindRequest(mojom::ShelfControllerRequest request); |
31 | 33 |
32 ShelfModel* model() { return &model_; } | 34 ShelfModel* model() { return &model_; } |
33 | 35 |
34 const std::map<std::string, ShelfID>& app_id_to_shelf_id() { | 36 const std::map<std::string, ShelfID>& app_id_to_shelf_id() { |
(...skipping 12 matching lines...) Expand all Loading... |
47 // mojom::Shelf: | 49 // mojom::Shelf: |
48 void AddObserver(mojom::ShelfObserverAssociatedPtrInfo observer) override; | 50 void AddObserver(mojom::ShelfObserverAssociatedPtrInfo observer) override; |
49 void SetAlignment(ShelfAlignment alignment, int64_t display_id) override; | 51 void SetAlignment(ShelfAlignment alignment, int64_t display_id) override; |
50 void SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide, | 52 void SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide, |
51 int64_t display_id) override; | 53 int64_t display_id) override; |
52 void PinItem(mojom::ShelfItemPtr item, | 54 void PinItem(mojom::ShelfItemPtr item, |
53 mojom::ShelfItemDelegateAssociatedPtrInfo delegate) override; | 55 mojom::ShelfItemDelegateAssociatedPtrInfo delegate) override; |
54 void UnpinItem(const std::string& app_id) override; | 56 void UnpinItem(const std::string& app_id) override; |
55 void SetItemImage(const std::string& app_id, const SkBitmap& image) override; | 57 void SetItemImage(const std::string& app_id, const SkBitmap& image) override; |
56 | 58 |
| 59 // PrefStore::Observer: |
| 60 void OnPrefValueChanged(const std::string& key) override; |
| 61 void OnInitializationCompleted(bool succeeded) override; |
| 62 |
57 private: | 63 private: |
58 // The shelf model shared by all shelf instances. | 64 // The shelf model shared by all shelf instances. |
59 ShelfModel model_; | 65 ShelfModel model_; |
60 | 66 |
61 // Bindings for the ShelfController interface. | 67 // Bindings for the ShelfController interface. |
62 mojo::BindingSet<mojom::ShelfController> bindings_; | 68 mojo::BindingSet<mojom::ShelfController> bindings_; |
63 | 69 |
64 // The set of shelf observers notified about shelf state and settings changes. | 70 // The set of shelf observers notified about shelf state and settings changes. |
65 mojo::AssociatedInterfacePtrSet<mojom::ShelfObserver> observers_; | 71 mojo::AssociatedInterfacePtrSet<mojom::ShelfObserver> observers_; |
66 | 72 |
67 // Mappings between application and shelf ids. | 73 // Mappings between application and shelf ids. |
68 std::map<std::string, ShelfID> app_id_to_shelf_id_; | 74 std::map<std::string, ShelfID> app_id_to_shelf_id_; |
69 std::map<ShelfID, std::string> shelf_id_to_app_id_; | 75 std::map<ShelfID, std::string> shelf_id_to_app_id_; |
70 | 76 |
71 DISALLOW_COPY_AND_ASSIGN(ShelfController); | 77 DISALLOW_COPY_AND_ASSIGN(ShelfController); |
72 }; | 78 }; |
73 | 79 |
74 } // namespace ash | 80 } // namespace ash |
75 | 81 |
76 #endif // ASH_COMMON_SHELF_SHELF_CONTROLLER_H_ | 82 #endif // ASH_COMMON_SHELF_SHELF_CONTROLLER_H_ |
OLD | NEW |