| 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> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/shelf/shelf.h" | 9 #include "ash/shelf/shelf.h" |
| 10 #include "ash/shelf/shelf_item_delegate.h" | 10 #include "ash/shelf/shelf_item_delegate.h" |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 if (!app_id_to_shelf_id_.count(app_id.To<std::string>())) | 301 if (!app_id_to_shelf_id_.count(app_id.To<std::string>())) |
| 302 return; | 302 return; |
| 303 ShelfID shelf_id = app_id_to_shelf_id_[app_id.To<std::string>()]; | 303 ShelfID shelf_id = app_id_to_shelf_id_[app_id.To<std::string>()]; |
| 304 ShelfItemDelegateMus* item_delegate = GetShelfItemDelegate(shelf_id); | 304 ShelfItemDelegateMus* item_delegate = GetShelfItemDelegate(shelf_id); |
| 305 DCHECK(item_delegate->pinned()); | 305 DCHECK(item_delegate->pinned()); |
| 306 item_delegate->set_pinned(false); | 306 item_delegate->set_pinned(false); |
| 307 if (item_delegate->window_id_to_title().empty()) | 307 if (item_delegate->window_id_to_title().empty()) |
| 308 model_->RemoveItemAt(model_->ItemIndexByID(shelf_id)); | 308 model_->RemoveItemAt(model_->ItemIndexByID(shelf_id)); |
| 309 } | 309 } |
| 310 | 310 |
| 311 void ShelfDelegateMus::SetItemImage(const mojo::String& app_id, |
| 312 skia::mojom::BitmapPtr image) { |
| 313 if (!app_id_to_shelf_id_.count(app_id.To<std::string>())) |
| 314 return; |
| 315 ShelfID shelf_id = app_id_to_shelf_id_[app_id.To<std::string>()]; |
| 316 int index = model_->ItemIndexByID(shelf_id); |
| 317 DCHECK_GE(index, 0); |
| 318 ShelfItem item = *model_->ItemByID(shelf_id); |
| 319 item.image = GetShelfIconFromBitmap(image.To<SkBitmap>()); |
| 320 model_->Set(index, item); |
| 321 } |
| 322 |
| 311 void ShelfDelegateMus::OnUserWindowObserverAdded( | 323 void ShelfDelegateMus::OnUserWindowObserverAdded( |
| 312 mojo::Array<mash::wm::mojom::UserWindowPtr> user_windows) { | 324 mojo::Array<mash::wm::mojom::UserWindowPtr> user_windows) { |
| 313 for (size_t i = 0; i < user_windows.size(); ++i) | 325 for (size_t i = 0; i < user_windows.size(); ++i) |
| 314 OnUserWindowAdded(std::move(user_windows[i])); | 326 OnUserWindowAdded(std::move(user_windows[i])); |
| 315 } | 327 } |
| 316 | 328 |
| 317 void ShelfDelegateMus::OnUserWindowAdded( | 329 void ShelfDelegateMus::OnUserWindowAdded( |
| 318 mash::wm::mojom::UserWindowPtr user_window) { | 330 mash::wm::mojom::UserWindowPtr user_window) { |
| 319 DCHECK(!window_id_to_shelf_id_.count(user_window->window_id)); | 331 DCHECK(!window_id_to_shelf_id_.count(user_window->window_id)); |
| 320 | 332 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 StatusAreaWidget* status_widget = widget->status_area_widget(); | 429 StatusAreaWidget* status_widget = widget->status_area_widget(); |
| 418 mus::Window* status_window = | 430 mus::Window* status_window = |
| 419 aura::GetMusWindow(status_widget->GetNativeWindow()); | 431 aura::GetMusWindow(status_widget->GetNativeWindow()); |
| 420 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); | 432 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); |
| 421 status_window->SetSharedProperty<gfx::Size>( | 433 status_window->SetSharedProperty<gfx::Size>( |
| 422 mus::mojom::WindowManager::kPreferredSize_Property, status_size); | 434 mus::mojom::WindowManager::kPreferredSize_Property, status_size); |
| 423 } | 435 } |
| 424 | 436 |
| 425 } // namespace sysui | 437 } // namespace sysui |
| 426 } // namespace ash | 438 } // namespace ash |
| OLD | NEW |