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

Side by Side Diff: chrome/browser/ui/ash/multi_user/user_switch_util.cc

Issue 2775973002: Promotes more accessors from WmShell to Shell (Closed)
Patch Set: feedback Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/ash/multi_user/user_switch_util.h" 5 #include "chrome/browser/ui/ash/multi_user/user_switch_util.h"
6 6
7 #include "ash/common/system/chromeos/screen_security/screen_tray_item.h" 7 #include "ash/common/system/chromeos/screen_security/screen_tray_item.h"
8 #include "ash/common/system/tray/system_tray.h" 8 #include "ash/common/system/tray/system_tray.h"
9 #include "ash/common/wm/overview/window_selector_controller.h" 9 #include "ash/common/wm/overview/window_selector_controller.h"
10 #include "ash/common/wm_shell.h"
11 #include "ash/shell.h" 10 #include "ash/shell.h"
12 #include "ash/strings/grit/ash_strings.h" 11 #include "ash/strings/grit/ash_strings.h"
13 #include "chrome/browser/ui/simple_message_box.h" 12 #include "chrome/browser/ui/simple_message_box.h"
14 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
15 14
16 void TrySwitchingActiveUser(const base::Callback<void()> on_switch) { 15 void TrySwitchingActiveUser(const base::Callback<void()> on_switch) {
17 // Some unit tests do not have a shell. In that case simply execute. 16 // Some unit tests do not have a shell. In that case simply execute.
18 if (!ash::Shell::HasInstance()) { 17 if (!ash::Shell::HasInstance()) {
19 on_switch.Run(); 18 on_switch.Run();
20 return; 19 return;
21 } 20 }
22 21
23 // Cancel overview mode when switching user profiles. 22 // Cancel overview mode when switching user profiles.
24 ash::WindowSelectorController* controller = 23 ash::WindowSelectorController* controller =
25 ash::WmShell::Get()->window_selector_controller(); 24 ash::Shell::Get()->window_selector_controller();
26 if (controller->IsSelecting()) 25 if (controller->IsSelecting())
27 controller->ToggleOverview(); 26 controller->ToggleOverview();
28 27
29 // If neither screen sharing nor capturing is going on we can immediately 28 // If neither screen sharing nor capturing is going on we can immediately
30 // switch users. 29 // switch users.
31 ash::SystemTray* system_tray = 30 ash::SystemTray* system_tray =
32 ash::Shell::GetInstance()->GetPrimarySystemTray(); 31 ash::Shell::GetInstance()->GetPrimarySystemTray();
33 if (!system_tray->GetScreenShareItem()->is_started() && 32 if (!system_tray->GetScreenShareItem()->is_started() &&
34 !system_tray->GetScreenCaptureItem()->is_started()) { 33 !system_tray->GetScreenCaptureItem()->is_started()) {
35 on_switch.Run(); 34 on_switch.Run();
36 return; 35 return;
37 } 36 }
38 if (chrome::ShowQuestionMessageBox( 37 if (chrome::ShowQuestionMessageBox(
39 nullptr, l10n_util::GetStringUTF16(IDS_DESKTOP_CASTING_ACTIVE_TITLE), 38 nullptr, l10n_util::GetStringUTF16(IDS_DESKTOP_CASTING_ACTIVE_TITLE),
40 l10n_util::GetStringUTF16(IDS_DESKTOP_CASTING_ACTIVE_MESSAGE)) == 39 l10n_util::GetStringUTF16(IDS_DESKTOP_CASTING_ACTIVE_MESSAGE)) ==
41 chrome::MESSAGE_BOX_RESULT_YES) { 40 chrome::MESSAGE_BOX_RESULT_YES) {
42 // Stop screen sharing and capturing. 41 // Stop screen sharing and capturing.
43 ash::SystemTray* system_tray = 42 ash::SystemTray* system_tray =
44 ash::Shell::GetInstance()->GetPrimarySystemTray(); 43 ash::Shell::GetInstance()->GetPrimarySystemTray();
45 if (system_tray->GetScreenShareItem()->is_started()) 44 if (system_tray->GetScreenShareItem()->is_started())
46 system_tray->GetScreenShareItem()->Stop(); 45 system_tray->GetScreenShareItem()->Stop();
47 if (system_tray->GetScreenCaptureItem()->is_started()) 46 if (system_tray->GetScreenCaptureItem()->is_started())
48 system_tray->GetScreenCaptureItem()->Stop(); 47 system_tray->GetScreenCaptureItem()->Stop();
49 48
50 on_switch.Run(); 49 on_switch.Run();
51 } 50 }
52 } 51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698