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

Unified Diff: ash/common/shelf/shelf_controller.h

Issue 2391253004: Use mojo Shelf interfaces for both mash and classic ash. (Closed)
Patch Set: Sync and rebase. Created 4 years, 2 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/common/shelf/shelf_controller.h
diff --git a/ash/common/shelf/shelf_controller.h b/ash/common/shelf/shelf_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..ce97894a1264dbb0a095aa97a5497fede37c9134
--- /dev/null
+++ b/ash/common/shelf/shelf_controller.h
@@ -0,0 +1,75 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_COMMON_SHELF_SHELF_CONTROLLER_H_
+#define ASH_COMMON_SHELF_SHELF_CONTROLLER_H_
+
+#include <map>
+#include <string>
+
+#include "ash/common/shelf/shelf_item_types.h"
+#include "ash/common/shelf/shelf_model.h"
+#include "ash/public/cpp/shelf_types.h"
+#include "ash/public/interfaces/shelf.mojom.h"
+#include "mojo/public/cpp/bindings/binding_set.h"
+#include "mojo/public/cpp/bindings/interface_ptr_set.h"
+
+namespace ash {
+
+class WmShelf;
+
+// Used by chrome to observe and manage the per-display ash shelf instances.
sky 2016/10/07 16:10:17 This comment is confusing as it implies this code
msw 2016/10/07 22:45:57 Done.
+class ShelfController : public mojom::ShelfController {
+ public:
+ ShelfController();
+ ~ShelfController() override;
+
+ // Binds the mojom::ShelfController interface request to this object.
+ void BindRequest(mojom::ShelfControllerRequest request);
+
+ ShelfModel* model() { return &model_; }
+
+ const std::map<std::string, ShelfID>& app_id_to_shelf_id() {
+ return app_id_to_shelf_id_;
+ }
+
+ const std::map<ShelfID, std::string>& shelf_id_to_app_id() {
+ return shelf_id_to_app_id_;
+ }
+
+ // Functions used to notify mojom::ShelfObserver instances of changes.
+ void NotifyShelfCreated(WmShelf* shelf);
+ void NotifyShelfAlignmentChanged(WmShelf* shelf);
+ void NotifyShelfAutoHideBehaviorChanged(WmShelf* shelf);
+
+ // mojom::Shelf:
+ 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(mojom::ShelfItemPtr item,
+ mojom::ShelfItemDelegateAssociatedPtrInfo delegate) override;
+ void UnpinItem(const std::string& app_id) override;
+ void SetItemImage(const std::string& app_id, const SkBitmap& image) override;
+
+ private:
+ // The shelf model shared by all shelf instances.
+ ShelfModel model_;
+
+ // Bindings for the ShelfController interface.
+ mojo::BindingSet<mojom::ShelfController> bindings_;
+
+ // The set of shelf observers notified about shelf state and settings changes.
+ mojo::AssociatedInterfacePtrSet<mojom::ShelfObserver> observers_;
+
+ // Mappings between application and shelf ids.
+ std::map<std::string, ShelfID> app_id_to_shelf_id_;
+ std::map<ShelfID, std::string> shelf_id_to_app_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(ShelfController);
+};
+
+} // namespace ash
+
+#endif // ASH_COMMON_SHELF_SHELF_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698