Index: ash/shelf/shelf_controller.h |
diff --git a/ash/shelf/shelf_controller.h b/ash/shelf/shelf_controller.h |
index c12ce330c56c33367f9281528c13893c2bdc93cf..32fd7388bd7e025ec6974a2e0f0f0a1b3e31fd55 100644 |
--- a/ash/shelf/shelf_controller.h |
+++ b/ash/shelf/shelf_controller.h |
@@ -5,13 +5,11 @@ |
#ifndef ASH_SHELF_SHELF_CONTROLLER_H_ |
#define ASH_SHELF_SHELF_CONTROLLER_H_ |
-#include <map> |
-#include <string> |
- |
#include "ash/public/cpp/shelf_item.h" |
#include "ash/public/cpp/shelf_types.h" |
#include "ash/public/interfaces/shelf.mojom.h" |
#include "ash/shelf/shelf_model.h" |
+#include "ash/shelf/shelf_model_observer.h" |
#include "mojo/public/cpp/bindings/binding_set.h" |
#include "mojo/public/cpp/bindings/interface_ptr_set.h" |
@@ -21,7 +19,11 @@ class Shelf; |
// Ash's implementation of the mojom::ShelfController interface. Chrome connects |
// to this interface to observe and manage the per-display ash shelf instances. |
-class ShelfController : public mojom::ShelfController { |
+// This class also owns Ash's ShelfModel, and syncs it with Chrome's ShelfModel. |
+// TODO(mash): Remove Chrome's dependencies on synchronous ShelfModel access. |
+class ShelfController : public mojom::ShelfController, |
+ public mojom::ShelfModelObserver, |
+ public ShelfModelObserver { |
public: |
ShelfController(); |
~ShelfController() override; |
@@ -38,13 +40,28 @@ class ShelfController : public mojom::ShelfController { |
// mojom::Shelf: |
void AddObserver(mojom::ShelfObserverAssociatedPtrInfo observer) override; |
+ void LinkShelfModels(mojom::ShelfModelObserverPtr observer, |
+ LinkShelfModelsCallback callback) override; |
void SetAlignment(ShelfAlignment alignment, int64_t display_id) override; |
void SetAutoHideBehavior(ShelfAutoHideBehavior auto_hide, |
int64_t display_id) override; |
- void PinItem(const ShelfItem& item, |
- mojom::ShelfItemDelegateAssociatedPtrInfo delegate) override; |
- void UnpinItem(const std::string& app_id) override; |
- void SetItemImage(const std::string& app_id, const SkBitmap& image) override; |
+ |
+ // mojom::ShelfModelObserver: |
+ void OnShelfItemAdded(int32_t index, const ShelfItem& item) override; |
+ void OnShelfItemRemoved(int32_t index, const ShelfItem& item) override; |
+ void OnShelfItemMoved(int32_t start_index, int32_t target_index) override; |
+ void OnShelfItemChanged(int32_t index, const ShelfItem& item) override; |
+ void OnShelfItemDelegateChanged( |
+ const ShelfID& id, |
+ mojom::ShelfItemDelegatePtr delegate) override; |
+ |
+ // ShelfModelObserver: |
+ void ShelfItemAdded(int index) override; |
+ void ShelfItemRemoved(int index, const ShelfItem& old_item) override; |
+ void ShelfItemMoved(int start_index, int target_index) override; |
+ void ShelfItemChanged(int index, const ShelfItem& old_item) override; |
+ void ShelfItemDelegateChanged(const ShelfID& id, |
+ ShelfItemDelegate* delegate) override; |
private: |
// The shelf model shared by all shelf instances. |
@@ -53,9 +70,19 @@ class ShelfController : public mojom::ShelfController { |
// Bindings for the ShelfController interface. |
mojo::BindingSet<mojom::ShelfController> bindings_; |
+ // Binding for observation of the remote ShelfModel owned by Chrome. |
+ mojo::Binding<mojom::ShelfModelObserver> shelf_model_observer_binding_; |
+ |
+ // True when applying changes from the remote ShelfModel owned by Chrome. |
+ // Changes to the local ShelfModel should not be reported during this time. |
+ bool applying_remote_shelf_model_changes_ = false; |
+ |
// The set of shelf observers notified about shelf state and settings changes. |
mojo::AssociatedInterfacePtrSet<mojom::ShelfObserver> observers_; |
+ // The set of shelf model observers notified about shelf model changes. |
+ mojo::InterfacePtrSet<mojom::ShelfModelObserver> model_observers_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ShelfController); |
}; |