Index: mash/shelf/shelf_model.h |
diff --git a/ash/shelf/shelf_model.h b/mash/shelf/shelf_model.h |
similarity index 67% |
copy from ash/shelf/shelf_model.h |
copy to mash/shelf/shelf_model.h |
index 01ab2a924accacceb25c5bf9725200f705a2c7ec..99c5767699f8abf9f412d789162036b83c9581d3 100644 |
--- a/ash/shelf/shelf_model.h |
+++ b/mash/shelf/shelf_model.h |
@@ -2,20 +2,26 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#ifndef ASH_SHELF_SHELF_MODEL_H_ |
-#define ASH_SHELF_SHELF_MODEL_H_ |
+#ifndef MASH_SHELF_SHELF_MODEL_H_ |
+#define MASH_SHELF_SHELF_MODEL_H_ |
-#include "ash/ash_export.h" |
-#include "ash/shelf/shelf_item_types.h" |
#include "base/macros.h" |
#include "base/observer_list.h" |
+#include "mash/shelf/shelf_item_types.h" |
+#include "mash/wm/public/interfaces/user_window_controller.mojom.h" |
+#include "mojo/public/cpp/bindings/binding.h" |
-namespace ash { |
+namespace mojo { |
+class ApplicationImpl; |
+} |
+ |
+namespace mash { |
+namespace shelf { |
class ShelfModelObserver; |
// Model used by ShelfView. |
-class ASH_EXPORT ShelfModel { |
+class ShelfModel : public mash::wm::mojom::UserWindowObserver { |
public: |
enum Status { |
STATUS_NORMAL, |
@@ -23,8 +29,8 @@ class ASH_EXPORT ShelfModel { |
STATUS_LOADING, |
}; |
- ShelfModel(); |
- ~ShelfModel(); |
+ explicit ShelfModel(mojo::ApplicationImpl* app); |
+ ~ShelfModel() override; |
// Adds a new item to the model. Returns the resulting index. |
int Add(const ShelfItem& item); |
@@ -80,12 +86,28 @@ class ASH_EXPORT ShelfModel { |
void AddObserver(ShelfModelObserver* observer); |
void RemoveObserver(ShelfModelObserver* observer); |
+ // TODO(msw): Do not expose this member, used by ShelfView to FocusUserWindow. |
+ mash::wm::mojom::UserWindowController* user_window_controller() const { |
+ return user_window_controller_.get(); |
+ } |
+ |
private: |
+ // Overridden from mash::wm::mojom::UserWindowObserver: |
+ void OnUserWindowObserverAdded( |
+ mojo::Array<mash::wm::mojom::UserWindowPtr> user_windows) override; |
+ void OnUserWindowAdded(mash::wm::mojom::UserWindowPtr user_window) override; |
+ void OnUserWindowRemoved(uint32_t window_id) override; |
+ void OnUserWindowTitleChanged(uint32_t window_id, |
+ const mojo::String& window_title) override; |
+ |
// Makes sure |index| is in line with the type-based order of items. If that |
// is not the case, adjusts index by shifting it to the valid range and |
// returns the new value. |
int ValidateInsertionIndex(ShelfItemType type, int index) const; |
+ // Return the index of the item by window id. |
+ int ItemIndexByWindowID(uint32_t window_id) const; |
+ |
// ID assigned to the next item. |
ShelfID next_id_; |
@@ -93,9 +115,13 @@ class ASH_EXPORT ShelfModel { |
Status status_; |
base::ObserverList<ShelfModelObserver> observers_; |
+ mash::wm::mojom::UserWindowControllerPtr user_window_controller_; |
+ mojo::Binding<mash::wm::mojom::UserWindowObserver> binding_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ShelfModel); |
}; |
-} // namespace ash |
+} // namespace shelf |
+} // namespace mash |
-#endif // ASH_SHELF_SHELF_MODEL_H_ |
+#endif // MASH_SHELF_SHELF_MODEL_H_ |