| 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 "ash/common/shelf/shelf_window_watcher.h" | 5 #include "ash/common/shelf/shelf_window_watcher.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "ash/common/shelf/shelf_constants.h" | 10 #include "ash/common/shelf/shelf_constants.h" |
| 11 #include "ash/common/shelf/shelf_model.h" | 11 #include "ash/common/shelf/shelf_model.h" |
| 12 #include "ash/common/shelf/shelf_window_watcher_item_delegate.h" | 12 #include "ash/common/shelf/shelf_window_watcher_item_delegate.h" |
| 13 #include "ash/common/wm/window_state.h" | 13 #include "ash/common/wm/window_state.h" |
| 14 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
| 15 #include "ash/common/wm_window.h" | 15 #include "ash/common/wm_window.h" |
| 16 #include "ash/common/wm_window_property.h" | 16 #include "ash/common/wm_window_property.h" |
| 17 #include "ash/public/cpp/shell_window_ids.h" | 17 #include "ash/public/cpp/shell_window_ids.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | |
| 19 #include "ui/display/display.h" | 18 #include "ui/display/display.h" |
| 20 #include "ui/display/screen.h" | 19 #include "ui/display/screen.h" |
| 21 #include "ui/gfx/image/image_skia.h" | |
| 22 #include "ui/resources/grit/ui_resources.h" | |
| 23 | 20 |
| 24 namespace ash { | 21 namespace ash { |
| 25 namespace { | 22 namespace { |
| 26 | 23 |
| 27 // Update the ShelfItem from relevant window properties. | 24 // Update the ShelfItem from relevant window properties. |
| 28 void UpdateShelfItemForWindow(ShelfItem* item, WmWindow* window) { | 25 void UpdateShelfItemForWindow(ShelfItem* item, WmWindow* window) { |
| 29 item->type = static_cast<ShelfItemType>( | 26 item->type = static_cast<ShelfItemType>( |
| 30 window->GetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE)); | 27 window->GetIntProperty(WmWindowProperty::SHELF_ITEM_TYPE)); |
| 31 | 28 |
| 32 item->status = STATUS_RUNNING; | 29 item->status = STATUS_RUNNING; |
| 33 if (window->IsActive()) | 30 if (window->IsActive()) |
| 34 item->status = STATUS_ACTIVE; | 31 item->status = STATUS_ACTIVE; |
| 35 else if (window->GetBoolProperty(WmWindowProperty::DRAW_ATTENTION)) | 32 else if (window->GetBoolProperty(WmWindowProperty::DRAW_ATTENTION)) |
| 36 item->status = STATUS_ATTENTION; | 33 item->status = STATUS_ATTENTION; |
| 37 | 34 |
| 38 item->app_id = window->GetStringProperty(WmWindowProperty::APP_ID); | 35 item->app_id = window->GetStringProperty(WmWindowProperty::APP_ID); |
| 39 | 36 |
| 40 // Prefer app icons over window icons, they're typically larger. | 37 // Prefer app icons over window icons, they're typically larger. |
| 41 gfx::ImageSkia image = window->GetAppIcon(); | 38 item->image = window->GetAppIcon(); |
| 42 if (image.isNull()) | 39 if (item->image.isNull()) |
| 43 image = window->GetWindowIcon(); | 40 item->image = window->GetWindowIcon(); |
| 44 if (image.isNull()) { | |
| 45 int icon = window->GetIntProperty(WmWindowProperty::SHELF_ICON_RESOURCE_ID); | |
| 46 if (icon != kInvalidImageResourceID) | |
| 47 image = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(icon); | |
| 48 } | |
| 49 item->image = image; | |
| 50 } | 41 } |
| 51 | 42 |
| 52 } // namespace | 43 } // namespace |
| 53 | 44 |
| 54 ShelfWindowWatcher::ContainerWindowObserver::ContainerWindowObserver( | 45 ShelfWindowWatcher::ContainerWindowObserver::ContainerWindowObserver( |
| 55 ShelfWindowWatcher* window_watcher) | 46 ShelfWindowWatcher* window_watcher) |
| 56 : window_watcher_(window_watcher) {} | 47 : window_watcher_(window_watcher) {} |
| 57 | 48 |
| 58 ShelfWindowWatcher::ContainerWindowObserver::~ContainerWindowObserver() {} | 49 ShelfWindowWatcher::ContainerWindowObserver::~ContainerWindowObserver() {} |
| 59 | 50 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 83 | 74 |
| 84 ShelfWindowWatcher::UserWindowObserver::~UserWindowObserver() {} | 75 ShelfWindowWatcher::UserWindowObserver::~UserWindowObserver() {} |
| 85 | 76 |
| 86 void ShelfWindowWatcher::UserWindowObserver::OnWindowPropertyChanged( | 77 void ShelfWindowWatcher::UserWindowObserver::OnWindowPropertyChanged( |
| 87 WmWindow* window, | 78 WmWindow* window, |
| 88 WmWindowProperty property) { | 79 WmWindowProperty property) { |
| 89 if (property == WmWindowProperty::APP_ICON || | 80 if (property == WmWindowProperty::APP_ICON || |
| 90 property == WmWindowProperty::APP_ID || | 81 property == WmWindowProperty::APP_ID || |
| 91 property == WmWindowProperty::DRAW_ATTENTION || | 82 property == WmWindowProperty::DRAW_ATTENTION || |
| 92 property == WmWindowProperty::SHELF_ITEM_TYPE || | 83 property == WmWindowProperty::SHELF_ITEM_TYPE || |
| 93 property == WmWindowProperty::SHELF_ICON_RESOURCE_ID || | |
| 94 property == WmWindowProperty::WINDOW_ICON) { | 84 property == WmWindowProperty::WINDOW_ICON) { |
| 95 window_watcher_->OnUserWindowPropertyChanged(window); | 85 window_watcher_->OnUserWindowPropertyChanged(window); |
| 96 } | 86 } |
| 97 } | 87 } |
| 98 | 88 |
| 99 void ShelfWindowWatcher::UserWindowObserver::OnWindowDestroying( | 89 void ShelfWindowWatcher::UserWindowObserver::OnWindowDestroying( |
| 100 WmWindow* window) { | 90 WmWindow* window) { |
| 101 window_watcher_->OnUserWindowDestroying(window); | 91 window_watcher_->OnUserWindowDestroying(window); |
| 102 } | 92 } |
| 103 | 93 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 observed_container_windows_.Add(panel_container); | 212 observed_container_windows_.Add(panel_container); |
| 223 } | 213 } |
| 224 | 214 |
| 225 void ShelfWindowWatcher::OnDisplayRemoved(const display::Display& old_display) { | 215 void ShelfWindowWatcher::OnDisplayRemoved(const display::Display& old_display) { |
| 226 } | 216 } |
| 227 | 217 |
| 228 void ShelfWindowWatcher::OnDisplayMetricsChanged(const display::Display&, | 218 void ShelfWindowWatcher::OnDisplayMetricsChanged(const display::Display&, |
| 229 uint32_t) {} | 219 uint32_t) {} |
| 230 | 220 |
| 231 } // namespace ash | 221 } // namespace ash |
| OLD | NEW |