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/sysui/shelf_delegate_mus.h" | 5 #include "ash/sysui/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 10 matching lines...) Expand all Loading... |
21 #include "components/mus/public/cpp/window_property.h" | 21 #include "components/mus/public/cpp/window_property.h" |
22 #include "mojo/common/common_type_converters.h" | 22 #include "mojo/common/common_type_converters.h" |
23 #include "services/shell/public/cpp/connector.h" | 23 #include "services/shell/public/cpp/connector.h" |
24 #include "skia/public/type_converters.h" | 24 #include "skia/public/type_converters.h" |
25 #include "ui/aura/mus/mus_util.h" | 25 #include "ui/aura/mus/mus_util.h" |
26 #include "ui/base/resource/resource_bundle.h" | 26 #include "ui/base/resource/resource_bundle.h" |
27 #include "ui/gfx/image/image_skia.h" | 27 #include "ui/gfx/image/image_skia.h" |
28 #include "ui/resources/grit/ui_resources.h" | 28 #include "ui/resources/grit/ui_resources.h" |
29 #include "ui/views/mus/window_manager_connection.h" | 29 #include "ui/views/mus/window_manager_connection.h" |
30 | 30 |
31 using mash::wm::mojom::UserWindowController; | 31 using ash::mojom::UserWindowController; |
32 | 32 |
33 namespace ash { | 33 namespace ash { |
34 namespace sysui { | 34 namespace sysui { |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 // A ShelfItemDelegate used for pinned items and open user windows. | 38 // A ShelfItemDelegate used for pinned items and open user windows. |
39 class ShelfItemDelegateMus : public ShelfItemDelegate { | 39 class ShelfItemDelegateMus : public ShelfItemDelegate { |
40 public: | 40 public: |
41 explicit ShelfItemDelegateMus(UserWindowController* user_window_controller) | 41 explicit ShelfItemDelegateMus(UserWindowController* user_window_controller) |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 return; | 347 return; |
348 ShelfID shelf_id = app_id_to_shelf_id_[app_id.To<std::string>()]; | 348 ShelfID shelf_id = app_id_to_shelf_id_[app_id.To<std::string>()]; |
349 int index = model_->ItemIndexByID(shelf_id); | 349 int index = model_->ItemIndexByID(shelf_id); |
350 DCHECK_GE(index, 0); | 350 DCHECK_GE(index, 0); |
351 ShelfItem item = *model_->ItemByID(shelf_id); | 351 ShelfItem item = *model_->ItemByID(shelf_id); |
352 item.image = GetShelfIconFromBitmap(image.To<SkBitmap>()); | 352 item.image = GetShelfIconFromBitmap(image.To<SkBitmap>()); |
353 model_->Set(index, item); | 353 model_->Set(index, item); |
354 } | 354 } |
355 | 355 |
356 void ShelfDelegateMus::OnUserWindowObserverAdded( | 356 void ShelfDelegateMus::OnUserWindowObserverAdded( |
357 mojo::Array<mash::wm::mojom::UserWindowPtr> user_windows) { | 357 mojo::Array<mojom::UserWindowPtr> user_windows) { |
358 for (size_t i = 0; i < user_windows.size(); ++i) | 358 for (size_t i = 0; i < user_windows.size(); ++i) |
359 OnUserWindowAdded(std::move(user_windows[i])); | 359 OnUserWindowAdded(std::move(user_windows[i])); |
360 } | 360 } |
361 | 361 |
362 void ShelfDelegateMus::OnUserWindowAdded( | 362 void ShelfDelegateMus::OnUserWindowAdded(mojom::UserWindowPtr user_window) { |
363 mash::wm::mojom::UserWindowPtr user_window) { | |
364 DCHECK(!window_id_to_shelf_id_.count(user_window->window_id)); | 363 DCHECK(!window_id_to_shelf_id_.count(user_window->window_id)); |
365 | 364 |
366 if (user_window->ignored_by_shelf) | 365 if (user_window->ignored_by_shelf) |
367 return; | 366 return; |
368 | 367 |
369 std::string app_id(user_window->window_app_id.To<std::string>()); | 368 std::string app_id(user_window->window_app_id.To<std::string>()); |
370 if (app_id_to_shelf_id_.count(app_id)) { | 369 if (app_id_to_shelf_id_.count(app_id)) { |
371 ShelfID shelf_id = app_id_to_shelf_id_[app_id]; | 370 ShelfID shelf_id = app_id_to_shelf_id_[app_id]; |
372 window_id_to_shelf_id_.insert( | 371 window_id_to_shelf_id_.insert( |
373 std::make_pair(user_window->window_id, shelf_id)); | 372 std::make_pair(user_window->window_id, shelf_id)); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 StatusAreaWidget* status_widget = widget->status_area_widget(); | 473 StatusAreaWidget* status_widget = widget->status_area_widget(); |
475 mus::Window* status_window = | 474 mus::Window* status_window = |
476 aura::GetMusWindow(status_widget->GetNativeWindow()); | 475 aura::GetMusWindow(status_widget->GetNativeWindow()); |
477 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); | 476 gfx::Size status_size = status_widget->GetWindowBoundsInScreen().size(); |
478 status_window->SetSharedProperty<gfx::Size>( | 477 status_window->SetSharedProperty<gfx::Size>( |
479 mus::mojom::WindowManager::kPreferredSize_Property, status_size); | 478 mus::mojom::WindowManager::kPreferredSize_Property, status_size); |
480 } | 479 } |
481 | 480 |
482 } // namespace sysui | 481 } // namespace sysui |
483 } // namespace ash | 482 } // namespace ash |
OLD | NEW |