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" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 display::Screen::GetScreen()->RemoveObserver(this); | 149 display::Screen::GetScreen()->RemoveObserver(this); |
150 Shell::GetInstance()->activation_client()->RemoveObserver(this); | 150 Shell::GetInstance()->activation_client()->RemoveObserver(this); |
151 } | 151 } |
152 | 152 |
153 void ShelfWindowWatcher::AddShelfItem(aura::Window* window) { | 153 void ShelfWindowWatcher::AddShelfItem(aura::Window* window) { |
154 user_windows_with_items_.insert(window); | 154 user_windows_with_items_.insert(window); |
155 ShelfItem item; | 155 ShelfItem item; |
156 ShelfID id = model_->next_id(); | 156 ShelfID id = model_->next_id(); |
157 UpdateShelfItemForWindow(&item, window); | 157 UpdateShelfItemForWindow(&item, window); |
158 window->SetProperty(kShelfIDKey, id); | 158 window->SetProperty(kShelfIDKey, id); |
159 std::unique_ptr<ShelfItemDelegate> item_delegate( | 159 model_->SetShelfItemDelegate(id, |
160 new ShelfWindowWatcherItemDelegate(id, WmWindow::Get(window))); | 160 base::MakeUnique<ShelfWindowWatcherItemDelegate>( |
161 model_->SetShelfItemDelegate(id, std::move(item_delegate)); | 161 id, WmWindow::Get(window))); |
162 // Panels are inserted on the left so as not to push all existing panels over. | 162 // Panels are inserted on the left so as not to push all existing panels over. |
163 model_->AddAt(item.type == TYPE_APP_PANEL ? 0 : model_->item_count(), item); | 163 model_->AddAt(item.type == TYPE_APP_PANEL ? 0 : model_->item_count(), item); |
164 } | 164 } |
165 | 165 |
166 void ShelfWindowWatcher::RemoveShelfItem(aura::Window* window) { | 166 void ShelfWindowWatcher::RemoveShelfItem(aura::Window* window) { |
167 user_windows_with_items_.erase(window); | 167 user_windows_with_items_.erase(window); |
168 int shelf_id = window->GetProperty(kShelfIDKey); | 168 int shelf_id = window->GetProperty(kShelfIDKey); |
169 DCHECK_NE(shelf_id, kInvalidShelfID); | 169 DCHECK_NE(shelf_id, kInvalidShelfID); |
170 int index = model_->ItemIndexByID(shelf_id); | 170 int index = model_->ItemIndexByID(shelf_id); |
171 DCHECK_GE(index, 0); | 171 DCHECK_GE(index, 0); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 } | 253 } |
254 } | 254 } |
255 | 255 |
256 void ShelfWindowWatcher::OnDisplayRemoved(const display::Display& old_display) { | 256 void ShelfWindowWatcher::OnDisplayRemoved(const display::Display& old_display) { |
257 } | 257 } |
258 | 258 |
259 void ShelfWindowWatcher::OnDisplayMetricsChanged(const display::Display&, | 259 void ShelfWindowWatcher::OnDisplayMetricsChanged(const display::Display&, |
260 uint32_t) {} | 260 uint32_t) {} |
261 | 261 |
262 } // namespace ash | 262 } // namespace ash |
OLD | NEW |