OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "mash/shelf/shelf_model.h" | 5 #include "mash/shelf/shelf_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "mash/shelf/shelf_model_observer.h" | 9 #include "mash/shelf/shelf_model_observer.h" |
10 #include "mojo/common/common_type_converters.h" | 10 #include "mojo/common/common_type_converters.h" |
11 #include "mojo/shell/public/cpp/application_impl.h" | 11 #include "mojo/shell/public/cpp/shell.h" |
12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
13 #include "ui/resources/grit/ui_resources.h" | 13 #include "ui/resources/grit/ui_resources.h" |
14 | 14 |
15 namespace mash { | 15 namespace mash { |
16 namespace shelf { | 16 namespace shelf { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 int ShelfItemTypeToWeight(ShelfItemType type) { | 20 int ShelfItemTypeToWeight(ShelfItemType type) { |
21 switch (type) { | 21 switch (type) { |
(...skipping 20 matching lines...) Expand all Loading... |
42 NOTREACHED() << "Invalid type " << type; | 42 NOTREACHED() << "Invalid type " << type; |
43 return 1; | 43 return 1; |
44 } | 44 } |
45 | 45 |
46 bool CompareByWeight(const ShelfItem& a, const ShelfItem& b) { | 46 bool CompareByWeight(const ShelfItem& a, const ShelfItem& b) { |
47 return ShelfItemTypeToWeight(a.type) < ShelfItemTypeToWeight(b.type); | 47 return ShelfItemTypeToWeight(a.type) < ShelfItemTypeToWeight(b.type); |
48 } | 48 } |
49 | 49 |
50 } // namespace | 50 } // namespace |
51 | 51 |
52 ShelfModel::ShelfModel(mojo::ApplicationImpl* app) | 52 ShelfModel::ShelfModel(mojo::Shell* shell) |
53 : next_id_(1), status_(STATUS_NORMAL), binding_(this) { | 53 : next_id_(1), status_(STATUS_NORMAL), binding_(this) { |
54 app->ConnectToService("mojo:desktop_wm", &user_window_controller_); | 54 shell->ConnectToService("mojo:desktop_wm", &user_window_controller_); |
55 user_window_controller_->AddUserWindowObserver( | 55 user_window_controller_->AddUserWindowObserver( |
56 binding_.CreateInterfacePtrAndBind()); | 56 binding_.CreateInterfacePtrAndBind()); |
57 } | 57 } |
58 | 58 |
59 ShelfModel::~ShelfModel() { | 59 ShelfModel::~ShelfModel() { |
60 } | 60 } |
61 | 61 |
62 int ShelfModel::Add(const ShelfItem& item) { | 62 int ShelfModel::Add(const ShelfItem& item) { |
63 return AddAt(static_cast<int>(items_.size()), item); | 63 return AddAt(static_cast<int>(items_.size()), item); |
64 } | 64 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 int ShelfModel::ItemIndexByWindowID(uint32_t window_id) const { | 233 int ShelfModel::ItemIndexByWindowID(uint32_t window_id) const { |
234 for (size_t i = 0; i < items_.size(); ++i) { | 234 for (size_t i = 0; i < items_.size(); ++i) { |
235 if (items_[i].window_id == window_id) | 235 if (items_[i].window_id == window_id) |
236 return static_cast<int>(i); | 236 return static_cast<int>(i); |
237 } | 237 } |
238 return -1; | 238 return -1; |
239 } | 239 } |
240 | 240 |
241 } // namespace shelf | 241 } // namespace shelf |
242 } // namespace mash | 242 } // namespace mash |
OLD | NEW |