Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: ash/shelf/shelf_window_watcher.cc

Issue 2808723004: Renames WmShell to ShellPort (Closed)
Patch Set: feedback Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
11 #include "ash/public/cpp/window_properties.h" 11 #include "ash/public/cpp/window_properties.h"
12 #include "ash/shelf/shelf_constants.h" 12 #include "ash/shelf/shelf_constants.h"
13 #include "ash/shelf/shelf_model.h" 13 #include "ash/shelf/shelf_model.h"
14 #include "ash/shelf/shelf_window_watcher_item_delegate.h" 14 #include "ash/shelf/shelf_window_watcher_item_delegate.h"
15 #include "ash/shell.h" 15 #include "ash/shell.h"
16 #include "ash/shell_port.h"
16 #include "ash/wm/window_properties.h" 17 #include "ash/wm/window_properties.h"
17 #include "ash/wm/window_state.h" 18 #include "ash/wm/window_state.h"
18 #include "ash/wm/window_state_aura.h" 19 #include "ash/wm/window_state_aura.h"
19 #include "ash/wm/window_util.h" 20 #include "ash/wm/window_util.h"
20 #include "ash/wm_shell.h"
21 #include "ash/wm_window.h" 21 #include "ash/wm_window.h"
22 #include "ui/aura/client/aura_constants.h" 22 #include "ui/aura/client/aura_constants.h"
23 #include "ui/aura/window.h" 23 #include "ui/aura/window.h"
24 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
25 #include "ui/display/display.h" 25 #include "ui/display/display.h"
26 #include "ui/display/screen.h" 26 #include "ui/display/screen.h"
27 #include "ui/resources/grit/ui_resources.h" 27 #include "ui/resources/grit/ui_resources.h"
28 #include "ui/wm/public/activation_client.h" 28 #include "ui/wm/public/activation_client.h"
29 29
30 namespace ash { 30 namespace ash {
31 namespace { 31 namespace {
32 32
33 // Returns the shelf item type, with special temporary behavior for Mash: 33 // Returns the shelf item type, with special temporary behavior for Mash:
34 // Mash provides a default shelf item type (TYPE_APP) for non-ignored windows. 34 // Mash provides a default shelf item type (TYPE_APP) for non-ignored windows.
35 ShelfItemType GetShelfItemType(aura::Window* window) { 35 ShelfItemType GetShelfItemType(aura::Window* window) {
36 if (!WmShell::Get()->IsRunningInMash() || 36 if (!ShellPort::Get()->IsRunningInMash() ||
37 window->GetProperty(kShelfItemTypeKey) != TYPE_UNDEFINED) { 37 window->GetProperty(kShelfItemTypeKey) != TYPE_UNDEFINED) {
38 return static_cast<ShelfItemType>(window->GetProperty(kShelfItemTypeKey)); 38 return static_cast<ShelfItemType>(window->GetProperty(kShelfItemTypeKey));
39 } 39 }
40 return wm::GetWindowState(window)->ignored_by_shelf() ? TYPE_UNDEFINED 40 return wm::GetWindowState(window)->ignored_by_shelf() ? TYPE_UNDEFINED
41 : TYPE_APP; 41 : TYPE_APP;
42 } 42 }
43 43
44 // Update the ShelfItem from relevant window properties. 44 // Update the ShelfItem from relevant window properties.
45 void UpdateShelfItemForWindow(ShelfItem* item, aura::Window* window) { 45 void UpdateShelfItemForWindow(ShelfItem* item, aura::Window* window) {
46 item->type = GetShelfItemType(window); 46 item->type = GetShelfItemType(window);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 void ShelfWindowWatcher::OnWindowActivated(ActivationReason reason, 231 void ShelfWindowWatcher::OnWindowActivated(ActivationReason reason,
232 aura::Window* gained_active, 232 aura::Window* gained_active,
233 aura::Window* lost_active) { 233 aura::Window* lost_active) {
234 if (gained_active && user_windows_with_items_.count(gained_active) > 0) 234 if (gained_active && user_windows_with_items_.count(gained_active) > 0)
235 OnUserWindowPropertyChanged(gained_active); 235 OnUserWindowPropertyChanged(gained_active);
236 if (lost_active && user_windows_with_items_.count(lost_active) > 0) 236 if (lost_active && user_windows_with_items_.count(lost_active) > 0)
237 OnUserWindowPropertyChanged(lost_active); 237 OnUserWindowPropertyChanged(lost_active);
238 } 238 }
239 239
240 void ShelfWindowWatcher::OnDisplayAdded(const display::Display& new_display) { 240 void ShelfWindowWatcher::OnDisplayAdded(const display::Display& new_display) {
241 WmWindow* root = WmShell::Get()->GetRootWindowForDisplayId(new_display.id()); 241 WmWindow* root =
242 ShellPort::Get()->GetRootWindowForDisplayId(new_display.id());
242 aura::Window* aura_root = WmWindow::GetAuraWindow(root); 243 aura::Window* aura_root = WmWindow::GetAuraWindow(root);
243 244
244 // When the primary root window's display is removed, the existing root window 245 // When the primary root window's display is removed, the existing root window
245 // is taken over by the new display, and the observer is already set. 246 // is taken over by the new display, and the observer is already set.
246 aura::Window* default_container = 247 aura::Window* default_container =
247 aura_root->GetChildById(kShellWindowId_DefaultContainer); 248 aura_root->GetChildById(kShellWindowId_DefaultContainer);
248 if (!observed_container_windows_.IsObserving(default_container)) { 249 if (!observed_container_windows_.IsObserving(default_container)) {
249 for (aura::Window* window : default_container->children()) 250 for (aura::Window* window : default_container->children())
250 OnUserWindowAdded(window); 251 OnUserWindowAdded(window);
251 observed_container_windows_.Add(default_container); 252 observed_container_windows_.Add(default_container);
252 } 253 }
253 aura::Window* panel_container = 254 aura::Window* panel_container =
254 aura_root->GetChildById(kShellWindowId_PanelContainer); 255 aura_root->GetChildById(kShellWindowId_PanelContainer);
255 if (!observed_container_windows_.IsObserving(panel_container)) { 256 if (!observed_container_windows_.IsObserving(panel_container)) {
256 for (aura::Window* window : panel_container->children()) 257 for (aura::Window* window : panel_container->children())
257 OnUserWindowAdded(window); 258 OnUserWindowAdded(window);
258 observed_container_windows_.Add(panel_container); 259 observed_container_windows_.Add(panel_container);
259 } 260 }
260 } 261 }
261 262
262 void ShelfWindowWatcher::OnDisplayRemoved(const display::Display& old_display) { 263 void ShelfWindowWatcher::OnDisplayRemoved(const display::Display& old_display) {
263 } 264 }
264 265
265 void ShelfWindowWatcher::OnDisplayMetricsChanged(const display::Display&, 266 void ShelfWindowWatcher::OnDisplayMetricsChanged(const display::Display&,
266 uint32_t) {} 267 uint32_t) {}
267 268
268 } // namespace ash 269 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698