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" |
18 #include "services/preferences/public/cpp/pref_observer_store.h" | |
17 | 19 |
18 namespace ash { | 20 namespace ash { |
19 | 21 |
20 class WmShelf; | 22 class WmShelf; |
21 | 23 |
22 // Ash's implementation of the mojom::ShelfController interface. Chrome connects | 24 // Ash's implementation of the mojom::ShelfController interface. Chrome connects |
23 // to this interface to observe and manage the per-display ash shelf instances. | 25 // to this interface to observe and manage the per-display ash shelf instances. |
24 class ShelfController : public mojom::ShelfController { | 26 class ShelfController : public mojom::ShelfController, |
27 public PrefStore::Observer { | |
25 public: | 28 public: |
26 ShelfController(); | 29 ShelfController(); |
27 ~ShelfController() override; | 30 ~ShelfController() override; |
28 | 31 |
29 // Binds the mojom::ShelfController interface request to this object. | 32 // Binds the mojom::ShelfController interface request to this object. |
30 void BindRequest(mojom::ShelfControllerRequest request); | 33 void BindRequest(mojom::ShelfControllerRequest request); |
31 | 34 |
32 ShelfModel* model() { return &model_; } | 35 ShelfModel* model() { return &model_; } |
33 | 36 |
34 const std::map<std::string, ShelfID>& app_id_to_shelf_id() { | 37 const std::map<std::string, ShelfID>& app_id_to_shelf_id() { |
(...skipping 12 matching lines...) Expand all Loading... | |
47 // mojom::Shelf: | 50 // mojom::Shelf: |
48 void AddObserver(mojom::ShelfObserverAssociatedPtrInfo observer) override; | 51 void AddObserver(mojom::ShelfObserverAssociatedPtrInfo observer) override; |
49 void SetAlignment(ShelfAlignment alignment, int64_t display_id) override; | 52 void SetAlignment(ShelfAlignment alignment, int64_t display_id) override; |
50 void SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide, | 53 void SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide, |
51 int64_t display_id) override; | 54 int64_t display_id) override; |
52 void PinItem(mojom::ShelfItemPtr item, | 55 void PinItem(mojom::ShelfItemPtr item, |
53 mojom::ShelfItemDelegateAssociatedPtrInfo delegate) override; | 56 mojom::ShelfItemDelegateAssociatedPtrInfo delegate) override; |
54 void UnpinItem(const std::string& app_id) override; | 57 void UnpinItem(const std::string& app_id) override; |
55 void SetItemImage(const std::string& app_id, const SkBitmap& image) override; | 58 void SetItemImage(const std::string& app_id, const SkBitmap& image) override; |
56 | 59 |
60 // PrefStore::Observer: | |
61 void OnPrefValueChanged(const std::string& key) override; | |
62 void OnInitializationCompleted(bool succeeded) override; | |
63 | |
57 private: | 64 private: |
58 // The shelf model shared by all shelf instances. | 65 // The shelf model shared by all shelf instances. |
59 ShelfModel model_; | 66 ShelfModel model_; |
60 | 67 |
61 // Bindings for the ShelfController interface. | 68 // Bindings for the ShelfController interface. |
62 mojo::BindingSet<mojom::ShelfController> bindings_; | 69 mojo::BindingSet<mojom::ShelfController> bindings_; |
63 | 70 |
64 // The set of shelf observers notified about shelf state and settings changes. | 71 // The set of shelf observers notified about shelf state and settings changes. |
65 mojo::AssociatedInterfacePtrSet<mojom::ShelfObserver> observers_; | 72 mojo::AssociatedInterfacePtrSet<mojom::ShelfObserver> observers_; |
66 | 73 |
74 scoped_refptr<PrefObserverStore> store_; | |
James Cook
2016/11/18 00:50:34
Like we discussed in person, I think a single cent
jonross
2016/11/18 20:31:23
Yeah I agree. I will update this example in a bit
| |
75 | |
67 // Mappings between application and shelf ids. | 76 // Mappings between application and shelf ids. |
68 std::map<std::string, ShelfID> app_id_to_shelf_id_; | 77 std::map<std::string, ShelfID> app_id_to_shelf_id_; |
69 std::map<ShelfID, std::string> shelf_id_to_app_id_; | 78 std::map<ShelfID, std::string> shelf_id_to_app_id_; |
70 | 79 |
71 DISALLOW_COPY_AND_ASSIGN(ShelfController); | 80 DISALLOW_COPY_AND_ASSIGN(ShelfController); |
72 }; | 81 }; |
73 | 82 |
74 } // namespace ash | 83 } // namespace ash |
75 | 84 |
76 #endif // ASH_COMMON_SHELF_SHELF_CONTROLLER_H_ | 85 #endif // ASH_COMMON_SHELF_SHELF_CONTROLLER_H_ |
OLD | NEW |