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

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

Powered by Google App Engine
This is Rietveld 408576698