OLD | NEW |
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 "ash/system/chromeos/multi_user/user_switch_util.h" | 5 #include "ash/system/chromeos/multi_user/user_switch_util.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/chromeos/screen_security/screen_tray_item.h" | 8 #include "ash/system/chromeos/screen_security/screen_tray_item.h" |
9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
10 #include "grit/ash_strings.h" | 10 #include "grit/ash_strings.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 if (system_tray->GetScreenShareItem()->is_started()) | 94 if (system_tray->GetScreenShareItem()->is_started()) |
95 system_tray->GetScreenShareItem()->Stop(); | 95 system_tray->GetScreenShareItem()->Stop(); |
96 if (system_tray->GetScreenCaptureItem()->is_started()) | 96 if (system_tray->GetScreenCaptureItem()->is_started()) |
97 system_tray->GetScreenCaptureItem()->Stop(); | 97 system_tray->GetScreenCaptureItem()->Stop(); |
98 | 98 |
99 on_switch_.Run(); | 99 on_switch_.Run(); |
100 return true; | 100 return true; |
101 } | 101 } |
102 | 102 |
103 base::string16 DesktopCastingWarningView::GetDialogButtonLabel( | 103 base::string16 DesktopCastingWarningView::GetDialogButtonLabel( |
104 ui::DialogButton button) const { | 104 ui::DialogButton button) const { |
105 return l10n_util::GetStringUTF16( | 105 return l10n_util::GetStringUTF16( |
106 button == ui::DIALOG_BUTTON_OK ? | 106 button == ui::DIALOG_BUTTON_OK |
107 IDS_DESKTOP_CASTING_ACTIVE_BUTTON_SWITCH_USER : | 107 ? IDS_DESKTOP_CASTING_ACTIVE_BUTTON_SWITCH_USER |
108 IDS_DESKTOP_CASTING_ACTIVE_BUTTON_ABORT_USER_SWITCH); | 108 : IDS_DESKTOP_CASTING_ACTIVE_BUTTON_ABORT_USER_SWITCH); |
109 } | 109 } |
110 | 110 |
111 bool DesktopCastingWarningView::IsDialogButtonEnabled( | 111 bool DesktopCastingWarningView::IsDialogButtonEnabled( |
112 ui::DialogButton button) const { | 112 ui::DialogButton button) const { |
113 return button == ui::DIALOG_BUTTON_OK || button == ui::DIALOG_BUTTON_CANCEL; | 113 return button == ui::DIALOG_BUTTON_OK || button == ui::DIALOG_BUTTON_CANCEL; |
114 } | 114 } |
115 | 115 |
116 int DesktopCastingWarningView::GetDefaultDialogButton() const { | 116 int DesktopCastingWarningView::GetDefaultDialogButton() const { |
117 // The default should turn off the casting. | 117 // The default should turn off the casting. |
118 return ui::DIALOG_BUTTON_CANCEL; | 118 return ui::DIALOG_BUTTON_CANCEL; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 160 |
161 SetLayoutManager(grid_layout); | 161 SetLayoutManager(grid_layout); |
162 Layout(); | 162 Layout(); |
163 } | 163 } |
164 | 164 |
165 } // namespace | 165 } // namespace |
166 | 166 |
167 //////////////////////////////////////////////////////////////////////////////// | 167 //////////////////////////////////////////////////////////////////////////////// |
168 // Factory function. | 168 // Factory function. |
169 | 169 |
170 void TrySwitchingActiveUser( | 170 void TrySwitchingActiveUser(const base::Callback<void()> on_switch) { |
171 const base::Callback<void()> on_switch) { | |
172 // Some unit tests do not have a shell. In that case simply execute. | 171 // Some unit tests do not have a shell. In that case simply execute. |
173 if (!ash::Shell::HasInstance()) { | 172 if (!ash::Shell::HasInstance()) { |
174 on_switch.Run(); | 173 on_switch.Run(); |
175 return; | 174 return; |
176 } | 175 } |
177 // If neither screen sharing nor capturing is going on we can immediately | 176 // If neither screen sharing nor capturing is going on we can immediately |
178 // switch users. | 177 // switch users. |
179 SystemTray* system_tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); | 178 SystemTray* system_tray = ash::Shell::GetInstance()->GetPrimarySystemTray(); |
180 if (!system_tray->GetScreenShareItem()->is_started() && | 179 if (!system_tray->GetScreenShareItem()->is_started() && |
181 !system_tray->GetScreenCaptureItem()->is_started()) { | 180 !system_tray->GetScreenCaptureItem()->is_started()) { |
182 on_switch.Run(); | 181 on_switch.Run(); |
183 return; | 182 return; |
184 } | 183 } |
185 DesktopCastingWarningView::ShowDialog(on_switch); | 184 DesktopCastingWarningView::ShowDialog(on_switch); |
186 } | 185 } |
187 | 186 |
188 bool TestAndTerminateDesktopCastingWarningForTest(bool accept) { | 187 bool TestAndTerminateDesktopCastingWarningForTest(bool accept) { |
189 if (!instance_for_test) | 188 if (!instance_for_test) |
190 return false; | 189 return false; |
191 if (accept) | 190 if (accept) |
192 instance_for_test->Accept(); | 191 instance_for_test->Accept(); |
193 delete instance_for_test->GetWidget()->GetNativeWindow(); | 192 delete instance_for_test->GetWidget()->GetNativeWindow(); |
194 CHECK(!instance_for_test); | 193 CHECK(!instance_for_test); |
195 return true; | 194 return true; |
196 } | 195 } |
197 | 196 |
198 } // namespace chromeos | 197 } // namespace chromeos |
OLD | NEW |