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

Side by Side Diff: chrome/browser/ui/ash/system_tray_delegate_chromeos.cc

Issue 811033002: Add device policy to disallow shutdown - ash UI modifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reduced scope of CL (ash only now, removed webui changes) Created 5 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/system_tray_delegate_chromeos.h" 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "ash/ash_switches.h" 12 #include "ash/ash_switches.h"
13 #include "ash/desktop_background/desktop_background_controller.h" 13 #include "ash/desktop_background/desktop_background_controller.h"
14 #include "ash/metrics/user_metrics_recorder.h" 14 #include "ash/metrics/user_metrics_recorder.h"
15 #include "ash/session/session_state_delegate.h" 15 #include "ash/session/session_state_delegate.h"
16 #include "ash/session/session_state_observer.h" 16 #include "ash/session/session_state_observer.h"
17 #include "ash/shell.h" 17 #include "ash/shell.h"
18 #include "ash/shell_delegate.h" 18 #include "ash/shell_delegate.h"
19 #include "ash/shell_window_ids.h" 19 #include "ash/shell_window_ids.h"
20 #include "ash/system/bluetooth/bluetooth_observer.h" 20 #include "ash/system/bluetooth/bluetooth_observer.h"
21 #include "ash/system/chromeos/session/logout_button_observer.h" 21 #include "ash/system/chromeos/session/logout_button_observer.h"
22 #include "ash/system/chromeos/shutdown_policy_observer.h"
22 #include "ash/system/date/clock_observer.h" 23 #include "ash/system/date/clock_observer.h"
23 #include "ash/system/ime/ime_observer.h" 24 #include "ash/system/ime/ime_observer.h"
24 #include "ash/system/tray/system_tray.h" 25 #include "ash/system/tray/system_tray.h"
25 #include "ash/system/tray/system_tray_delegate.h" 26 #include "ash/system/tray/system_tray_delegate.h"
26 #include "ash/system/tray/system_tray_notifier.h" 27 #include "ash/system/tray/system_tray_notifier.h"
27 #include "ash/system/tray_accessibility.h" 28 #include "ash/system/tray_accessibility.h"
28 #include "ash/system/user/login_status.h" 29 #include "ash/system/user/login_status.h"
29 #include "ash/system/user/update_observer.h" 30 #include "ash/system/user/update_observer.h"
30 #include "ash/system/user/user_observer.h" 31 #include "ash/system/user/user_observer.h"
31 #include "ash/volume_control_delegate.h" 32 #include "ash/volume_control_delegate.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 registrar_->Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 225 registrar_->Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
225 content::NotificationService::AllSources()); 226 content::NotificationService::AllSources());
226 227
227 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); 228 AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
228 CHECK(accessibility_manager); 229 CHECK(accessibility_manager);
229 accessibility_subscription_ = accessibility_manager->RegisterCallback( 230 accessibility_subscription_ = accessibility_manager->RegisterCallback(
230 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, 231 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged,
231 base::Unretained(this))); 232 base::Unretained(this)));
232 233
233 user_manager::UserManager::Get()->AddSessionStateObserver(this); 234 user_manager::UserManager::Get()->AddSessionStateObserver(this);
235 shutdown_policy_handler_.reset(
236 new ShutdownPolicyHandler(CrosSettings::Get(), this));
stevenjb 2015/01/07 19:24:19 It's a shame that we have to provide this level of
cschuet (SLOW) 2015/01/13 10:38:28 As discussed in http://crbug.com/446937, the scope
234 } 237 }
235 238
236 void SystemTrayDelegateChromeOS::Initialize() { 239 void SystemTrayDelegateChromeOS::Initialize() {
237 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); 240 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
238 241
239 input_method::InputMethodManager::Get()->AddObserver(this); 242 input_method::InputMethodManager::Get()->AddObserver(this);
240 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); 243 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this);
241 UpdateClockType(); 244 UpdateClockType();
242 245
243 device::BluetoothAdapterFactory::GetAdapter( 246 device::BluetoothAdapterFactory::GetAdapter(
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 if (show_intro) { 592 if (show_intro) {
590 base::Callback<void(bool)> on_accept = 593 base::Callback<void(bool)> on_accept =
591 base::Bind(&OnAcceptMultiprofilesIntro); 594 base::Bind(&OnAcceptMultiprofilesIntro);
592 ShowMultiprofilesIntroDialog(on_accept); 595 ShowMultiprofilesIntroDialog(on_accept);
593 } else { 596 } else {
594 UserAddingScreen::Get()->Start(); 597 UserAddingScreen::Get()->Start();
595 } 598 }
596 } 599 }
597 } 600 }
598 601
599 void SystemTrayDelegateChromeOS::ShutDown() {
600 ash::Shell::GetInstance()->lock_state_controller()->RequestShutdown(
601 ash::LockStateController::POWER_OFF);
602 }
603
604 void SystemTrayDelegateChromeOS::SignOut() { 602 void SystemTrayDelegateChromeOS::SignOut() {
605 chrome::AttemptUserExit(); 603 chrome::AttemptUserExit();
606 } 604 }
607 605
608 void SystemTrayDelegateChromeOS::RequestLockScreen() { 606 void SystemTrayDelegateChromeOS::RequestLockScreen() {
609 // TODO(antrim) : additional logging for crbug/173178 607 // TODO(antrim) : additional logging for crbug/173178
610 LOG(WARNING) << "Requesting screen lock from AshSystemTrayDelegate"; 608 LOG(WARNING) << "Requesting screen lock from AshSystemTrayDelegate";
611 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen(); 609 DBusThreadManager::Get()->GetSessionManagerClient()->RequestLockScreen();
612 } 610 }
613 611
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 void SystemTrayDelegateChromeOS::AddCustodianInfoTrayObserver( 830 void SystemTrayDelegateChromeOS::AddCustodianInfoTrayObserver(
833 ash::CustodianInfoTrayObserver* observer) { 831 ash::CustodianInfoTrayObserver* observer) {
834 custodian_info_changed_observers_.AddObserver(observer); 832 custodian_info_changed_observers_.AddObserver(observer);
835 } 833 }
836 834
837 void SystemTrayDelegateChromeOS::RemoveCustodianInfoTrayObserver( 835 void SystemTrayDelegateChromeOS::RemoveCustodianInfoTrayObserver(
838 ash::CustodianInfoTrayObserver* observer) { 836 ash::CustodianInfoTrayObserver* observer) {
839 custodian_info_changed_observers_.RemoveObserver(observer); 837 custodian_info_changed_observers_.RemoveObserver(observer);
840 } 838 }
841 839
840 void SystemTrayDelegateChromeOS::AddShutdownPolicyObserver(
841 ash::ShutdownPolicyObserver* observer) {
842 shutdown_policy_observers_.AddObserver(observer);
843 }
844
845 void SystemTrayDelegateChromeOS::RemoveShutdownPolicyObserver(
846 ash::ShutdownPolicyObserver* observer) {
847 shutdown_policy_observers_.RemoveObserver(observer);
848 }
849
850 void SystemTrayDelegateChromeOS::ShouldRebootOnShutdown(
851 const ash::RebootOnShutdownCallback& callback) {
852 shutdown_policy_handler_->CheckIfRebootOnShutdown(callback);
853 }
854
842 void SystemTrayDelegateChromeOS::UserAddedToSession( 855 void SystemTrayDelegateChromeOS::UserAddedToSession(
843 const user_manager::User* active_user) { 856 const user_manager::User* active_user) {
844 } 857 }
845 858
846 void SystemTrayDelegateChromeOS::ActiveUserChanged( 859 void SystemTrayDelegateChromeOS::ActiveUserChanged(
847 const user_manager::User* /* active_user */) { 860 const user_manager::User* /* active_user */) {
848 } 861 }
849 862
850 void SystemTrayDelegateChromeOS::UserChangedChildStatus( 863 void SystemTrayDelegateChromeOS::UserChangedChildStatus(
851 user_manager::User* user) { 864 user_manager::User* user) {
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 } 1330 }
1318 1331
1319 void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged( 1332 void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged(
1320 const AccessibilityStatusEventDetails& details) { 1333 const AccessibilityStatusEventDetails& details) {
1321 if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN) 1334 if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN)
1322 accessibility_subscription_.reset(); 1335 accessibility_subscription_.reset();
1323 else 1336 else
1324 OnAccessibilityModeChanged(details.notify); 1337 OnAccessibilityModeChanged(details.notify);
1325 } 1338 }
1326 1339
1340 void SystemTrayDelegateChromeOS::OnShutdownPolicyChanged(
1341 bool reboot_on_shutdown) {
1342 // Notify all observers.
1343 FOR_EACH_OBSERVER(ash::ShutdownPolicyObserver, shutdown_policy_observers_,
1344 OnShutdownPolicyChanged(reboot_on_shutdown));
1345 }
1346
1327 const base::string16 1347 const base::string16
1328 SystemTrayDelegateChromeOS::GetLegacySupervisedUserMessage() const { 1348 SystemTrayDelegateChromeOS::GetLegacySupervisedUserMessage() const {
1329 std::string user_manager_name = GetSupervisedUserManager(); 1349 std::string user_manager_name = GetSupervisedUserManager();
1330 return l10n_util::GetStringFUTF16( 1350 return l10n_util::GetStringFUTF16(
1331 IDS_USER_IS_SUPERVISED_BY_NOTICE, 1351 IDS_USER_IS_SUPERVISED_BY_NOTICE,
1332 base::UTF8ToUTF16(user_manager_name)); 1352 base::UTF8ToUTF16(user_manager_name));
1333 } 1353 }
1334 1354
1335 const base::string16 1355 const base::string16
1336 SystemTrayDelegateChromeOS::GetChildUserMessage() const { 1356 SystemTrayDelegateChromeOS::GetChildUserMessage() const {
(...skipping 20 matching lines...) Expand all
1357 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " 1377 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while "
1358 << "ENABLE_SUPERVISED_USERS undefined."; 1378 << "ENABLE_SUPERVISED_USERS undefined.";
1359 return base::string16(); 1379 return base::string16();
1360 } 1380 }
1361 1381
1362 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1382 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1363 return new SystemTrayDelegateChromeOS(); 1383 return new SystemTrayDelegateChromeOS();
1364 } 1384 }
1365 1385
1366 } // namespace chromeos 1386 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698