| 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/shelf/shelf_window_watcher.h" | 5 #include "ash/shelf/shelf_window_watcher.h" |
| 6 | 6 |
| 7 #include <memory> |
| 7 #include <utility> | 8 #include <utility> |
| 8 | 9 |
| 9 #include "ash/display/window_tree_host_manager.h" | 10 #include "ash/display/window_tree_host_manager.h" |
| 10 #include "ash/shelf/shelf_constants.h" | 11 #include "ash/shelf/shelf_constants.h" |
| 11 #include "ash/shelf/shelf_item_delegate_manager.h" | 12 #include "ash/shelf/shelf_item_delegate_manager.h" |
| 12 #include "ash/shelf/shelf_model.h" | 13 #include "ash/shelf/shelf_model.h" |
| 13 #include "ash/shelf/shelf_util.h" | 14 #include "ash/shelf/shelf_util.h" |
| 14 #include "ash/shelf/shelf_window_watcher_item_delegate.h" | 15 #include "ash/shelf/shelf_window_watcher_item_delegate.h" |
| 15 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 16 #include "ash/shell_window_ids.h" | 17 #include "ash/shell_window_ids.h" |
| 17 #include "ash/wm/window_state.h" | 18 #include "ash/wm/window_state.h" |
| 18 #include "ash/wm/window_util.h" | 19 #include "ash/wm/window_util.h" |
| 19 #include "base/memory/scoped_ptr.h" | |
| 20 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
| 21 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 22 #include "ui/gfx/image/image_skia.h" | 22 #include "ui/gfx/image/image_skia.h" |
| 23 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
| 24 #include "ui/wm/public/activation_client.h" | 24 #include "ui/wm/public/activation_client.h" |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Sets ShelfItem property by using the value of |details|. | 28 // Sets ShelfItem property by using the value of |details|. |
| 29 void SetShelfItemDetailsForShelfItem(ash::ShelfItem* item, | 29 void SetShelfItemDetailsForShelfItem(ash::ShelfItem* item, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 } | 128 } |
| 129 | 129 |
| 130 void ShelfWindowWatcher::AddShelfItem(aura::Window* window) { | 130 void ShelfWindowWatcher::AddShelfItem(aura::Window* window) { |
| 131 const ShelfItemDetails* item_details = | 131 const ShelfItemDetails* item_details = |
| 132 GetShelfItemDetailsForWindow(window); | 132 GetShelfItemDetailsForWindow(window); |
| 133 ShelfItem item; | 133 ShelfItem item; |
| 134 ShelfID id = model_->next_id(); | 134 ShelfID id = model_->next_id(); |
| 135 item.status = wm::IsActiveWindow(window) ? STATUS_ACTIVE: STATUS_RUNNING; | 135 item.status = wm::IsActiveWindow(window) ? STATUS_ACTIVE: STATUS_RUNNING; |
| 136 SetShelfItemDetailsForShelfItem(&item, *item_details); | 136 SetShelfItemDetailsForShelfItem(&item, *item_details); |
| 137 SetShelfIDForWindow(id, window); | 137 SetShelfIDForWindow(id, window); |
| 138 scoped_ptr<ShelfItemDelegate> item_delegate( | 138 std::unique_ptr<ShelfItemDelegate> item_delegate( |
| 139 new ShelfWindowWatcherItemDelegate(window)); | 139 new ShelfWindowWatcherItemDelegate(window)); |
| 140 // |item_delegate| is owned by |item_delegate_manager_|. | 140 // |item_delegate| is owned by |item_delegate_manager_|. |
| 141 item_delegate_manager_->SetShelfItemDelegate(id, std::move(item_delegate)); | 141 item_delegate_manager_->SetShelfItemDelegate(id, std::move(item_delegate)); |
| 142 model_->Add(item); | 142 model_->Add(item); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void ShelfWindowWatcher::RemoveShelfItem(aura::Window* window) { | 145 void ShelfWindowWatcher::RemoveShelfItem(aura::Window* window) { |
| 146 model_->RemoveItemAt(model_->ItemIndexByID(GetShelfIDForWindow(window))); | 146 model_->RemoveItemAt(model_->ItemIndexByID(GetShelfIDForWindow(window))); |
| 147 SetShelfIDForWindow(kInvalidShelfID, window); | 147 SetShelfIDForWindow(kInvalidShelfID, window); |
| 148 } | 148 } |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 // Instead, we remove an observer from RootWindow and ActivationClient in the | 285 // Instead, we remove an observer from RootWindow and ActivationClient in the |
| 286 // OnRootWindowDestroyed(). | 286 // OnRootWindowDestroyed(). |
| 287 // Do nothing here. | 287 // Do nothing here. |
| 288 } | 288 } |
| 289 | 289 |
| 290 void ShelfWindowWatcher::OnDisplayMetricsChanged(const gfx::Display&, | 290 void ShelfWindowWatcher::OnDisplayMetricsChanged(const gfx::Display&, |
| 291 uint32_t) { | 291 uint32_t) { |
| 292 } | 292 } |
| 293 | 293 |
| 294 } // namespace ash | 294 } // namespace ash |
| OLD | NEW |