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

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

Issue 2833173002: mash: Support ShelfModel access in Chrome. (Closed)
Patch Set: Address comments; fix test failures. Created 3 years, 6 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 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_SHELF_SHELF_CONTROLLER_H_ 5 #ifndef ASH_SHELF_SHELF_CONTROLLER_H_
6 #define ASH_SHELF_SHELF_CONTROLLER_H_ 6 #define ASH_SHELF_SHELF_CONTROLLER_H_
7 7
8 #include <map>
9 #include <string>
10
11 #include "ash/public/cpp/shelf_item.h" 8 #include "ash/public/cpp/shelf_item.h"
12 #include "ash/public/cpp/shelf_types.h" 9 #include "ash/public/cpp/shelf_types.h"
13 #include "ash/public/interfaces/shelf.mojom.h" 10 #include "ash/public/interfaces/shelf.mojom.h"
14 #include "ash/shelf/shelf_model.h" 11 #include "ash/shelf/shelf_model.h"
12 #include "ash/shelf/shelf_model_observer.h"
15 #include "mojo/public/cpp/bindings/binding_set.h" 13 #include "mojo/public/cpp/bindings/binding_set.h"
16 #include "mojo/public/cpp/bindings/interface_ptr_set.h" 14 #include "mojo/public/cpp/bindings/interface_ptr_set.h"
17 15
18 namespace ash { 16 namespace ash {
19 17
20 class Shelf; 18 class Shelf;
21 19
22 // Ash's implementation of the mojom::ShelfController interface. Chrome connects 20 // Ash's ShelfController owns the ShelfModel and implements interface functions
23 // to this interface to observe and manage the per-display ash shelf instances. 21 // that allow Chrome to modify and observe the Shelf and ShelfModel state.
24 class ShelfController : public mojom::ShelfController { 22 class ShelfController : public mojom::ShelfController,
23 public ShelfModelObserver {
25 public: 24 public:
26 ShelfController(); 25 ShelfController();
27 ~ShelfController() override; 26 ~ShelfController() override;
28 27
29 // Binds the mojom::ShelfController interface request to this object. 28 // Binds the mojom::ShelfController interface request to this object.
30 void BindRequest(mojom::ShelfControllerRequest request); 29 void BindRequest(mojom::ShelfControllerRequest request);
31 30
32 ShelfModel* model() { return &model_; } 31 ShelfModel* model() { return &model_; }
33 32
34 // Functions used to notify mojom::ShelfObserver instances of changes. 33 // Functions used to notify mojom::ShelfObserver instances of changes.
35 void NotifyShelfInitialized(Shelf* shelf); 34 void NotifyShelfInitialized(Shelf* shelf);
36 void NotifyShelfAlignmentChanged(Shelf* shelf); 35 void NotifyShelfAlignmentChanged(Shelf* shelf);
37 void NotifyShelfAutoHideBehaviorChanged(Shelf* shelf); 36 void NotifyShelfAutoHideBehaviorChanged(Shelf* shelf);
38 37
39 // mojom::Shelf: 38 // mojom::ShelfController:
40 void AddObserver(mojom::ShelfObserverAssociatedPtrInfo observer) override; 39 void AddObserver(mojom::ShelfObserverAssociatedPtrInfo observer) override;
41 void SetAlignment(ShelfAlignment alignment, int64_t display_id) override; 40 void SetAlignment(ShelfAlignment alignment, int64_t display_id) override;
42 void SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide, 41 void SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide,
43 int64_t display_id) override; 42 int64_t display_id) override;
44 void PinItem(const ShelfItem& item, 43 void AddShelfItem(int32_t index, const ShelfItem& item) override;
45 mojom::ShelfItemDelegateAssociatedPtrInfo delegate) override; 44 void RemoveShelfItem(const ShelfID& id) override;
46 void UnpinItem(const std::string& app_id) override; 45 void MoveShelfItem(const ShelfID& id, int32_t index) override;
47 void SetItemImage(const std::string& app_id, const SkBitmap& image) override; 46 void UpdateShelfItem(const ShelfItem& item) override;
47 void SetShelfItemDelegate(const ShelfID& id,
48 mojom::ShelfItemDelegatePtr delegate) override;
49
50 // ShelfModelObserver:
51 void ShelfItemAdded(int index) override;
52 void ShelfItemRemoved(int index, const ShelfItem& old_item) override;
53 void ShelfItemMoved(int start_index, int target_index) override;
54 void ShelfItemChanged(int index, const ShelfItem& old_item) override;
55 void ShelfItemDelegateChanged(const ShelfID& id,
56 ShelfItemDelegate* delegate) override;
48 57
49 private: 58 private:
50 // The shelf model shared by all shelf instances. 59 // The shelf model shared by all shelf instances.
51 ShelfModel model_; 60 ShelfModel model_;
52 61
53 // Bindings for the ShelfController interface. 62 // Bindings for the ShelfController interface.
54 mojo::BindingSet<mojom::ShelfController> bindings_; 63 mojo::BindingSet<mojom::ShelfController> bindings_;
55 64
56 // The set of shelf observers notified about shelf state and settings changes. 65 // True when applying changes from the remote ShelfModel owned by Chrome.
66 // Changes to the local ShelfModel should not be reported during this time.
67 bool applying_remote_shelf_model_changes_ = false;
68
69 // The set of shelf observers notified about state and model changes.
57 mojo::AssociatedInterfacePtrSet<mojom::ShelfObserver> observers_; 70 mojo::AssociatedInterfacePtrSet<mojom::ShelfObserver> observers_;
58 71
59 DISALLOW_COPY_AND_ASSIGN(ShelfController); 72 DISALLOW_COPY_AND_ASSIGN(ShelfController);
60 }; 73 };
61 74
62 } // namespace ash 75 } // namespace ash
63 76
64 #endif // ASH_SHELF_SHELF_CONTROLLER_H_ 77 #endif // ASH_SHELF_SHELF_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698