OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/mus/shelf_delegate_mus.h" | 5 #include "ash/mus/shelf_delegate_mus.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
8 #include "ash/shelf/shelf_item_delegate.h" | 10 #include "ash/shelf/shelf_item_delegate.h" |
9 #include "ash/shelf/shelf_item_delegate_manager.h" | 11 #include "ash/shelf/shelf_item_delegate_manager.h" |
10 #include "ash/shelf/shelf_layout_manager.h" | 12 #include "ash/shelf/shelf_layout_manager.h" |
11 #include "ash/shelf/shelf_model.h" | 13 #include "ash/shelf/shelf_model.h" |
12 #include "ash/shelf/shelf_widget.h" | 14 #include "ash/shelf/shelf_widget.h" |
13 #include "ash/shell.h" | 15 #include "ash/shell.h" |
14 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
15 #include "components/mus/public/cpp/property_type_converters.h" | 17 #include "components/mus/public/cpp/property_type_converters.h" |
16 #include "components/mus/public/cpp/window.h" | 18 #include "components/mus/public/cpp/window.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 item.status = user_window->window_has_focus ? STATUS_ACTIVE : STATUS_RUNNING; | 181 item.status = user_window->window_has_focus ? STATUS_ACTIVE : STATUS_RUNNING; |
180 item.image = GetShelfIconFromBitmap(user_window->window_app_icon); | 182 item.image = GetShelfIconFromBitmap(user_window->window_app_icon); |
181 | 183 |
182 ShelfID shelf_id = model_->next_id(); | 184 ShelfID shelf_id = model_->next_id(); |
183 window_id_to_shelf_id_.insert( | 185 window_id_to_shelf_id_.insert( |
184 std::make_pair(user_window->window_id, shelf_id)); | 186 std::make_pair(user_window->window_id, shelf_id)); |
185 model_->Add(item); | 187 model_->Add(item); |
186 | 188 |
187 ShelfItemDelegateManager* manager = | 189 ShelfItemDelegateManager* manager = |
188 Shell::GetInstance()->shelf_item_delegate_manager(); | 190 Shell::GetInstance()->shelf_item_delegate_manager(); |
189 scoped_ptr<ShelfItemDelegate> delegate(new ShelfItemDelegateMus( | 191 std::unique_ptr<ShelfItemDelegate> delegate(new ShelfItemDelegateMus( |
190 user_window->window_id, user_window->window_title.To<base::string16>(), | 192 user_window->window_id, user_window->window_title.To<base::string16>(), |
191 user_window_controller_.get())); | 193 user_window_controller_.get())); |
192 manager->SetShelfItemDelegate(shelf_id, std::move(delegate)); | 194 manager->SetShelfItemDelegate(shelf_id, std::move(delegate)); |
193 } | 195 } |
194 | 196 |
195 void ShelfDelegateMus::OnUserWindowRemoved(uint32_t window_id) { | 197 void ShelfDelegateMus::OnUserWindowRemoved(uint32_t window_id) { |
196 DCHECK(window_id_to_shelf_id_.count(window_id)); | 198 DCHECK(window_id_to_shelf_id_.count(window_id)); |
197 model_->RemoveItemAt( | 199 model_->RemoveItemAt( |
198 model_->ItemIndexByID(window_id_to_shelf_id_[window_id])); | 200 model_->ItemIndexByID(window_id_to_shelf_id_[window_id])); |
199 } | 201 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 DCHECK_GE(index, 0); | 246 DCHECK_GE(index, 0); |
245 ShelfItems::const_iterator iter = model_->ItemByID(shelf_id); | 247 ShelfItems::const_iterator iter = model_->ItemByID(shelf_id); |
246 DCHECK(iter != model_->items().end()); | 248 DCHECK(iter != model_->items().end()); |
247 ShelfItem item = *iter; | 249 ShelfItem item = *iter; |
248 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING; | 250 item.status = has_focus ? STATUS_ACTIVE : STATUS_RUNNING; |
249 model_->Set(index, item); | 251 model_->Set(index, item); |
250 } | 252 } |
251 | 253 |
252 } // namespace sysui | 254 } // namespace sysui |
253 } // namespace ash | 255 } // namespace ash |
OLD | NEW |