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

Side by Side Diff: ash/shell_port.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 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/wm_shell.h" 5 #include "ash/shell_port.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/accelerators/accelerator_controller.h" 9 #include "ash/accelerators/accelerator_controller.h"
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
11 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.h"
12 #include "ash/session/session_controller.h" 12 #include "ash/session/session_controller.h"
13 #include "ash/session/session_state_delegate.h" 13 #include "ash/session/session_state_delegate.h"
14 #include "ash/shelf/app_list_shelf_item_delegate.h" 14 #include "ash/shelf/app_list_shelf_item_delegate.h"
15 #include "ash/shell.h" 15 #include "ash/shell.h"
16 #include "ash/shell_delegate.h" 16 #include "ash/shell_delegate.h"
17 #include "ash/wm/root_window_finder.h" 17 #include "ash/wm/root_window_finder.h"
18 #include "ash/wm/system_modal_container_layout_manager.h" 18 #include "ash/wm/system_modal_container_layout_manager.h"
19 #include "ash/wm_window.h" 19 #include "ash/wm_window.h"
20 #include "base/bind.h" 20 #include "base/bind.h"
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "base/memory/ptr_util.h" 22 #include "base/memory/ptr_util.h"
23 #include "ui/display/display.h" 23 #include "ui/display/display.h"
24 24
25 namespace ash { 25 namespace ash {
26 26
27 // static 27 // static
28 WmShell* WmShell::instance_ = nullptr; 28 ShellPort* ShellPort::instance_ = nullptr;
29 29
30 WmShell::~WmShell() { 30 ShellPort::~ShellPort() {
31 DCHECK_EQ(this, instance_); 31 DCHECK_EQ(this, instance_);
32 instance_ = nullptr; 32 instance_ = nullptr;
33 } 33 }
34 34
35 // static 35 // static
36 WmShell* WmShell::Get() { 36 ShellPort* ShellPort::Get() {
37 return instance_; 37 return instance_;
38 } 38 }
39 39
40 void WmShell::Shutdown() { 40 void ShellPort::Shutdown() {}
41 }
42 41
43 void WmShell::ShowContextMenu(const gfx::Point& location_in_screen, 42 void ShellPort::ShowContextMenu(const gfx::Point& location_in_screen,
44 ui::MenuSourceType source_type) { 43 ui::MenuSourceType source_type) {
45 // Bail if there is no active user session or if the screen is locked. 44 // Bail if there is no active user session or if the screen is locked.
46 if (Shell::Get()->session_controller()->NumberOfLoggedInUsers() < 1 || 45 if (Shell::Get()->session_controller()->NumberOfLoggedInUsers() < 1 ||
47 Shell::Get()->session_controller()->IsScreenLocked()) { 46 Shell::Get()->session_controller()->IsScreenLocked()) {
48 return; 47 return;
49 } 48 }
50 49
51 WmWindow* root = wm::GetRootWindowAt(location_in_screen); 50 WmWindow* root = wm::GetRootWindowAt(location_in_screen);
52 root->GetRootWindowController()->ShowContextMenu(location_in_screen, 51 root->GetRootWindowController()->ShowContextMenu(location_in_screen,
53 source_type); 52 source_type);
54 } 53 }
55 54
56 void WmShell::OnLockStateEvent(LockStateObserver::EventType event) { 55 void ShellPort::OnLockStateEvent(LockStateObserver::EventType event) {
57 for (auto& observer : lock_state_observers_) 56 for (auto& observer : lock_state_observers_)
58 observer.OnLockStateEvent(event); 57 observer.OnLockStateEvent(event);
59 } 58 }
60 59
61 void WmShell::AddLockStateObserver(LockStateObserver* observer) { 60 void ShellPort::AddLockStateObserver(LockStateObserver* observer) {
62 lock_state_observers_.AddObserver(observer); 61 lock_state_observers_.AddObserver(observer);
63 } 62 }
64 63
65 void WmShell::RemoveLockStateObserver(LockStateObserver* observer) { 64 void ShellPort::RemoveLockStateObserver(LockStateObserver* observer) {
66 lock_state_observers_.RemoveObserver(observer); 65 lock_state_observers_.RemoveObserver(observer);
67 } 66 }
68 67
69 WmShell::WmShell() { 68 ShellPort::ShellPort() {
70 DCHECK(!instance_); 69 DCHECK(!instance_);
71 instance_ = this; 70 instance_ = this;
72 } 71 }
73 72
74 RootWindowController* WmShell::GetPrimaryRootWindowController() { 73 RootWindowController* ShellPort::GetPrimaryRootWindowController() {
75 return GetPrimaryRootWindow()->GetRootWindowController(); 74 return GetPrimaryRootWindow()->GetRootWindowController();
76 } 75 }
77 76
78 bool WmShell::IsForceMaximizeOnFirstRun() { 77 bool ShellPort::IsForceMaximizeOnFirstRun() {
79 return Shell::Get()->shell_delegate()->IsForceMaximizeOnFirstRun(); 78 return Shell::Get()->shell_delegate()->IsForceMaximizeOnFirstRun();
80 } 79 }
81 80
82 bool WmShell::IsSystemModalWindowOpen() { 81 bool ShellPort::IsSystemModalWindowOpen() {
83 if (simulate_modal_window_open_for_testing_) 82 if (simulate_modal_window_open_for_testing_)
84 return true; 83 return true;
85 84
86 // Traverse all system modal containers, and find its direct child window 85 // Traverse all system modal containers, and find its direct child window
87 // with "SystemModal" setting, and visible. 86 // with "SystemModal" setting, and visible.
88 for (WmWindow* root : GetAllRootWindows()) { 87 for (WmWindow* root : GetAllRootWindows()) {
89 WmWindow* system_modal = 88 WmWindow* system_modal =
90 root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer); 89 root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer);
91 if (!system_modal) 90 if (!system_modal)
92 continue; 91 continue;
93 for (const WmWindow* child : system_modal->GetChildren()) { 92 for (const WmWindow* child : system_modal->GetChildren()) {
94 if (child->IsSystemModal() && child->GetTargetVisibility()) { 93 if (child->IsSystemModal() && child->GetTargetVisibility()) {
95 return true; 94 return true;
96 } 95 }
97 } 96 }
98 } 97 }
99 return false; 98 return false;
100 } 99 }
101 100
102 void WmShell::CreateModalBackground(WmWindow* window) { 101 void ShellPort::CreateModalBackground(WmWindow* window) {
103 for (WmWindow* root_window : GetAllRootWindows()) { 102 for (WmWindow* root_window : GetAllRootWindows()) {
104 root_window->GetRootWindowController() 103 root_window->GetRootWindowController()
105 ->GetSystemModalLayoutManager(window) 104 ->GetSystemModalLayoutManager(window)
106 ->CreateModalBackground(); 105 ->CreateModalBackground();
107 } 106 }
108 } 107 }
109 108
110 void WmShell::OnModalWindowRemoved(WmWindow* removed) { 109 void ShellPort::OnModalWindowRemoved(WmWindow* removed) {
111 WmWindow::Windows root_windows = GetAllRootWindows(); 110 WmWindow::Windows root_windows = GetAllRootWindows();
112 for (WmWindow* root_window : root_windows) { 111 for (WmWindow* root_window : root_windows) {
113 if (root_window->GetRootWindowController() 112 if (root_window->GetRootWindowController()
114 ->GetSystemModalLayoutManager(removed) 113 ->GetSystemModalLayoutManager(removed)
115 ->ActivateNextModalWindow()) { 114 ->ActivateNextModalWindow()) {
116 return; 115 return;
117 } 116 }
118 } 117 }
119 for (WmWindow* root_window : root_windows) { 118 for (WmWindow* root_window : root_windows) {
120 root_window->GetRootWindowController() 119 root_window->GetRootWindowController()
121 ->GetSystemModalLayoutManager(removed) 120 ->GetSystemModalLayoutManager(removed)
122 ->DestroyModalBackground(); 121 ->DestroyModalBackground();
123 } 122 }
124 } 123 }
125 124
126 } // namespace ash 125 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698