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

Unified 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, 7 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 side-by-side diff with in-line comments
Download patch
Index: ash/shelf/shelf_controller.h
diff --git a/ash/shelf/shelf_controller.h b/ash/shelf/shelf_controller.h
index c12ce330c56c33367f9281528c13893c2bdc93cf..5b73a388fad2b8a8f45da7e708bd3f096be92a81 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"
@@ -19,9 +17,10 @@ namespace ash {
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 {
+// Ash's ShelfController owns the ShelfModel and implements interface functions
+// that allow Chrome to modify and observe the Shelf and ShelfModel state.
+class ShelfController : public mojom::ShelfController,
+ public ShelfModelObserver {
public:
ShelfController();
~ShelfController() override;
@@ -36,15 +35,25 @@ class ShelfController : public mojom::ShelfController {
void NotifyShelfAlignmentChanged(Shelf* shelf);
void NotifyShelfAutoHideBehaviorChanged(Shelf* shelf);
- // mojom::Shelf:
+ // mojom::ShelfController:
void AddObserver(mojom::ShelfObserverAssociatedPtrInfo observer) 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;
+ void AddShelfItem(int32_t index, const ShelfItem& item) override;
+ void RemoveShelfItem(const ShelfID& id) override;
+ void MoveShelfItem(const ShelfID& id, int32_t index) override;
+ void UpdateShelfItem(const ShelfItem& item) override;
+ void SetShelfItemDelegate(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,7 +62,11 @@ class ShelfController : public mojom::ShelfController {
// Bindings for the ShelfController interface.
mojo::BindingSet<mojom::ShelfController> bindings_;
- // The set of shelf observers notified about shelf state and settings changes.
+ // 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 state and model changes.
mojo::AssociatedInterfacePtrSet<mojom::ShelfObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(ShelfController);

Powered by Google App Engine
This is Rietveld 408576698