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

Side by Side Diff: ash/common/wm_shell.cc

Issue 2108793002: mash: Convert system tray logout button to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments, fix windows Created 4 years, 5 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
« no previous file with comments | « ash/common/wm_shell.h ('k') | ash/shell.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/common/wm_shell.h" 5 #include "ash/common/wm_shell.h"
6 6
7 #include "ash/common/focus_cycler.h" 7 #include "ash/common/focus_cycler.h"
8 #include "ash/common/shell_window_ids.h" 8 #include "ash/common/shell_window_ids.h"
9 #include "ash/common/system/chromeos/session/logout_confirmation_controller.h"
9 #include "ash/common/system/tray/system_tray_delegate.h" 10 #include "ash/common/system/tray/system_tray_delegate.h"
10 #include "ash/common/system/tray/system_tray_notifier.h" 11 #include "ash/common/system/tray/system_tray_notifier.h"
11 #include "ash/common/wm/overview/window_selector_controller.h" 12 #include "ash/common/wm/overview/window_selector_controller.h"
12 #include "ash/common/wm_window.h" 13 #include "ash/common/wm_window.h"
14 #include "base/bind.h"
13 #include "base/logging.h" 15 #include "base/logging.h"
14 16
15 namespace ash { 17 namespace ash {
16 18
17 // static 19 // static
18 WmShell* WmShell::instance_ = nullptr; 20 WmShell* WmShell::instance_ = nullptr;
19 21
20 // static 22 // static
21 void WmShell::Set(WmShell* instance) { 23 void WmShell::Set(WmShell* instance) {
22 instance_ = instance; 24 instance_ = instance;
23 } 25 }
24 26
25 // static 27 // static
26 WmShell* WmShell::Get() { 28 WmShell* WmShell::Get() {
27 return instance_; 29 return instance_;
28 } 30 }
29 31
30 WmShell::WmShell() 32 WmShell::WmShell()
31 : focus_cycler_(new FocusCycler), 33 : focus_cycler_(new FocusCycler),
32 system_tray_notifier_(new SystemTrayNotifier), 34 system_tray_notifier_(new SystemTrayNotifier),
33 window_selector_controller_(new WindowSelectorController()) {} 35 window_selector_controller_(new WindowSelectorController()) {}
34 36
35 WmShell::~WmShell() {} 37 WmShell::~WmShell() {}
36 38
39 WmRootWindowController* WmShell::GetPrimaryRootWindowController() {
40 return GetPrimaryRootWindow()->GetRootWindowController();
41 }
42
37 bool WmShell::IsSystemModalWindowOpen() { 43 bool WmShell::IsSystemModalWindowOpen() {
38 if (simulate_modal_window_open_for_testing_) 44 if (simulate_modal_window_open_for_testing_)
39 return true; 45 return true;
40 46
41 // Traverse all system modal containers, and find its direct child window 47 // Traverse all system modal containers, and find its direct child window
42 // with "SystemModal" setting, and visible. 48 // with "SystemModal" setting, and visible.
43 for (WmWindow* root : GetAllRootWindows()) { 49 for (WmWindow* root : GetAllRootWindows()) {
44 WmWindow* system_modal = 50 WmWindow* system_modal =
45 root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer); 51 root->GetChildByShellWindowId(kShellWindowId_SystemModalContainer);
46 if (!system_modal) 52 if (!system_modal)
47 continue; 53 continue;
48 for (const WmWindow* child : system_modal->GetChildren()) { 54 for (const WmWindow* child : system_modal->GetChildren()) {
49 if (child->IsSystemModal() && child->GetTargetVisibility()) { 55 if (child->IsSystemModal() && child->GetTargetVisibility()) {
50 return true; 56 return true;
51 } 57 }
52 } 58 }
53 } 59 }
54 return false; 60 return false;
55 } 61 }
56 62
57 void WmShell::SetSystemTrayDelegate( 63 void WmShell::SetSystemTrayDelegate(
58 std::unique_ptr<SystemTrayDelegate> delegate) { 64 std::unique_ptr<SystemTrayDelegate> delegate) {
59 if (delegate) { 65 DCHECK(delegate);
60 DCHECK(!system_tray_delegate_); 66 DCHECK(!system_tray_delegate_);
61 // TODO(jamescook): Create via ShellDelegate once it moves to //ash/common. 67 // TODO(jamescook): Create via ShellDelegate once it moves to //ash/common.
62 system_tray_delegate_ = std::move(delegate); 68 system_tray_delegate_ = std::move(delegate);
63 system_tray_delegate_->Initialize(); 69 system_tray_delegate_->Initialize();
64 } else { 70 #if defined(OS_CHROMEOS)
65 DCHECK(system_tray_delegate_); 71 logout_confirmation_controller_.reset(new LogoutConfirmationController(
66 system_tray_delegate_->Shutdown(); 72 base::Bind(&SystemTrayDelegate::SignOut,
67 system_tray_delegate_.reset(); 73 base::Unretained(system_tray_delegate_.get()))));
68 } 74 #endif
75 }
76
77 void WmShell::DeleteSystemTrayDelegate() {
78 #if defined(OS_CHROMEOS)
79 logout_confirmation_controller_.reset();
80 #endif
81 DCHECK(system_tray_delegate_);
msw 2016/06/28 21:09:16 optional nit: DCHECK at top?
James Cook 2016/06/28 21:41:02 Done.
82 system_tray_delegate_.reset();
69 } 83 }
70 84
71 void WmShell::DeleteWindowSelectorController() { 85 void WmShell::DeleteWindowSelectorController() {
72 window_selector_controller_.reset(); 86 window_selector_controller_.reset();
73 } 87 }
74 88
75 } // namespace ash 89 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm_shell.h ('k') | ash/shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698