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

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

Issue 375413002: Replace chromeos::UserManager::Get() with chromeos::GetUserManager(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 6 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 | Annotate | Revision Log
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>
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 if (GetEnterpriseDomain().empty()) 430 if (GetEnterpriseDomain().empty())
431 return base::string16(); 431 return base::string16();
432 return l10n_util::GetStringFUTF16(IDS_DEVICE_OWNED_BY_NOTICE, 432 return l10n_util::GetStringFUTF16(IDS_DEVICE_OWNED_BY_NOTICE,
433 base::UTF8ToUTF16(GetEnterpriseDomain())); 433 base::UTF8ToUTF16(GetEnterpriseDomain()));
434 } 434 }
435 435
436 const std::string SystemTrayDelegateChromeOS::GetLocallyManagedUserManager() 436 const std::string SystemTrayDelegateChromeOS::GetLocallyManagedUserManager()
437 const { 437 const {
438 if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED) 438 if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED)
439 return std::string(); 439 return std::string();
440 return UserManager::Get()->GetSupervisedUserManager()->GetManagerDisplayEmail( 440 return GetUserManager()->GetSupervisedUserManager()->GetManagerDisplayEmail(
441 chromeos::UserManager::Get()->GetActiveUser()->email()); 441 chromeos::GetUserManager()->GetActiveUser()->email());
442 } 442 }
443 443
444 const base::string16 444 const base::string16
445 SystemTrayDelegateChromeOS::GetLocallyManagedUserManagerName() const { 445 SystemTrayDelegateChromeOS::GetLocallyManagedUserManagerName() const {
446 if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED) 446 if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED)
447 return base::string16(); 447 return base::string16();
448 return UserManager::Get()->GetSupervisedUserManager()->GetManagerDisplayName( 448 return GetUserManager()->GetSupervisedUserManager()->GetManagerDisplayName(
449 chromeos::UserManager::Get()->GetActiveUser()->email()); 449 chromeos::GetUserManager()->GetActiveUser()->email());
450 } 450 }
451 451
452 const base::string16 SystemTrayDelegateChromeOS::GetLocallyManagedUserMessage() 452 const base::string16 SystemTrayDelegateChromeOS::GetLocallyManagedUserMessage()
453 const { 453 const {
454 if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED) 454 if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED)
455 return base::string16(); 455 return base::string16();
456 return l10n_util::GetStringFUTF16( 456 return l10n_util::GetStringFUTF16(
457 IDS_USER_IS_LOCALLY_MANAGED_BY_NOTICE, 457 IDS_USER_IS_LOCALLY_MANAGED_BY_NOTICE,
458 base::UTF8ToUTF16(GetLocallyManagedUserManager())); 458 base::UTF8ToUTF16(GetLocallyManagedUserManager()));
459 } 459 }
460 460
461 bool SystemTrayDelegateChromeOS::SystemShouldUpgrade() const { 461 bool SystemTrayDelegateChromeOS::SystemShouldUpgrade() const {
462 return UpgradeDetector::GetInstance()->notify_upgrade(); 462 return UpgradeDetector::GetInstance()->notify_upgrade();
463 } 463 }
464 464
465 base::HourClockType SystemTrayDelegateChromeOS::GetHourClockType() const { 465 base::HourClockType SystemTrayDelegateChromeOS::GetHourClockType() const {
466 return clock_type_; 466 return clock_type_;
467 } 467 }
468 468
469 void SystemTrayDelegateChromeOS::ShowSettings() { 469 void SystemTrayDelegateChromeOS::ShowSettings() {
470 ShowSettingsSubPageForActiveUser(""); 470 ShowSettingsSubPageForActiveUser("");
471 } 471 }
472 472
473 bool SystemTrayDelegateChromeOS::ShouldShowSettings() { 473 bool SystemTrayDelegateChromeOS::ShouldShowSettings() {
474 return UserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings(); 474 return GetUserManager()->GetCurrentUserFlow()->ShouldShowSettings();
475 } 475 }
476 476
477 void SystemTrayDelegateChromeOS::ShowDateSettings() { 477 void SystemTrayDelegateChromeOS::ShowDateSettings() {
478 content::RecordAction(base::UserMetricsAction("ShowDateOptions")); 478 content::RecordAction(base::UserMetricsAction("ShowDateOptions"));
479 std::string sub_page = 479 std::string sub_page =
480 std::string(chrome::kSearchSubPage) + "#" + 480 std::string(chrome::kSearchSubPage) + "#" +
481 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME); 481 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME);
482 // Everybody can change the time zone (even though it is a device setting). 482 // Everybody can change the time zone (even though it is a device setting).
483 ShowSettingsSubPageForActiveUser(sub_page); 483 ShowSettingsSubPageForActiveUser(sub_page);
484 } 484 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 GURL(chrome::kLearnMoreEnterpriseURL)); 593 GURL(chrome::kLearnMoreEnterpriseURL));
594 } 594 }
595 } 595 }
596 596
597 void SystemTrayDelegateChromeOS::ShowUserLogin() { 597 void SystemTrayDelegateChromeOS::ShowUserLogin() {
598 ash::Shell* shell = ash::Shell::GetInstance(); 598 ash::Shell* shell = ash::Shell::GetInstance();
599 if (!shell->delegate()->IsMultiProfilesEnabled()) 599 if (!shell->delegate()->IsMultiProfilesEnabled())
600 return; 600 return;
601 601
602 // Only regular users could add other users to current session. 602 // Only regular users could add other users to current session.
603 if (UserManager::Get()->GetActiveUser()->GetType() != 603 if (GetUserManager()->GetActiveUser()->GetType() !=
604 user_manager::USER_TYPE_REGULAR) { 604 user_manager::USER_TYPE_REGULAR) {
605 return; 605 return;
606 } 606 }
607 607
608 if (static_cast<int>(UserManager::Get()->GetLoggedInUsers().size()) >= 608 if (static_cast<int>(GetUserManager()->GetLoggedInUsers().size()) >=
609 shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers()) 609 shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers())
610 return; 610 return;
611 611
612 // Launch sign in screen to add another user to current session. 612 // Launch sign in screen to add another user to current session.
613 if (UserManager::Get()->GetUsersAdmittedForMultiProfile().size()) { 613 if (GetUserManager()->GetUsersAdmittedForMultiProfile().size()) {
614 // Don't show dialog if any logged in user in multi-profiles session 614 // Don't show dialog if any logged in user in multi-profiles session
615 // dismissed it. 615 // dismissed it.
616 bool show_intro = true; 616 bool show_intro = true;
617 const UserList logged_in_users = UserManager::Get()->GetLoggedInUsers(); 617 const UserList logged_in_users = GetUserManager()->GetLoggedInUsers();
618 for (UserList::const_iterator it = logged_in_users.begin(); 618 for (UserList::const_iterator it = logged_in_users.begin();
619 it != logged_in_users.end(); 619 it != logged_in_users.end();
620 ++it) { 620 ++it) {
621 show_intro &= !multi_user_util::GetProfileFromUserID( 621 show_intro &= !multi_user_util::GetProfileFromUserID(
622 multi_user_util::GetUserIDFromEmail((*it)->email())) 622 multi_user_util::GetUserIDFromEmail((*it)->email()))
623 ->GetPrefs() 623 ->GetPrefs()
624 ->GetBoolean(prefs::kMultiProfileNeverShowIntro); 624 ->GetBoolean(prefs::kMultiProfileNeverShowIntro);
625 if (!show_intro) 625 if (!show_intro)
626 break; 626 break;
627 } 627 }
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 } 902 }
903 903
904 bool SystemTrayDelegateChromeOS::IsSearchKeyMappedToCapsLock() { 904 bool SystemTrayDelegateChromeOS::IsSearchKeyMappedToCapsLock() {
905 return search_key_mapped_to_ == input_method::kCapsLockKey; 905 return search_key_mapped_to_ == input_method::kCapsLockKey;
906 } 906 }
907 907
908 ash::tray::UserAccountsDelegate* 908 ash::tray::UserAccountsDelegate*
909 SystemTrayDelegateChromeOS::GetUserAccountsDelegate( 909 SystemTrayDelegateChromeOS::GetUserAccountsDelegate(
910 const std::string& user_id) { 910 const std::string& user_id) {
911 if (!accounts_delegates_.contains(user_id)) { 911 if (!accounts_delegates_.contains(user_id)) {
912 const User* user = UserManager::Get()->FindUser(user_id); 912 const User* user = GetUserManager()->FindUser(user_id);
913 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user); 913 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user);
914 CHECK(user_profile); 914 CHECK(user_profile);
915 accounts_delegates_.set( 915 accounts_delegates_.set(
916 user_id, 916 user_id,
917 scoped_ptr<ash::tray::UserAccountsDelegate>( 917 scoped_ptr<ash::tray::UserAccountsDelegate>(
918 new UserAccountsDelegateChromeOS(user_profile))); 918 new UserAccountsDelegateChromeOS(user_profile)));
919 } 919 }
920 return accounts_delegates_.get(user_id); 920 return accounts_delegates_.get(user_id);
921 } 921 }
922 922
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 user_pref->GetValue()->GetAsBoolean(&use_24_hour_clock); 1037 user_pref->GetValue()->GetAsBoolean(&use_24_hour_clock);
1038 return use_24_hour_clock; 1038 return use_24_hour_clock;
1039 } 1039 }
1040 1040
1041 void SystemTrayDelegateChromeOS::UpdateClockType() { 1041 void SystemTrayDelegateChromeOS::UpdateClockType() {
1042 const bool use_24_hour_clock = ShouldUse24HourClock(); 1042 const bool use_24_hour_clock = ShouldUse24HourClock();
1043 clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock; 1043 clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock;
1044 GetSystemTrayNotifier()->NotifyDateFormatChanged(); 1044 GetSystemTrayNotifier()->NotifyDateFormatChanged();
1045 // This also works for enterprise-managed devices because they never have 1045 // This also works for enterprise-managed devices because they never have
1046 // local owner. 1046 // local owner.
1047 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) 1047 if (chromeos::GetUserManager()->IsCurrentUserOwner())
1048 CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, use_24_hour_clock); 1048 CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, use_24_hour_clock);
1049 } 1049 }
1050 1050
1051 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() { 1051 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() {
1052 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged( 1052 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged(
1053 user_pref_registrar_->prefs()->GetBoolean( 1053 user_pref_registrar_->prefs()->GetBoolean(
1054 prefs::kShowLogoutButtonInTray)); 1054 prefs::kShowLogoutButtonInTray));
1055 } 1055 }
1056 1056
1057 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() { 1057 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 void SystemTrayDelegateChromeOS::LoggedInStateChanged() { 1127 void SystemTrayDelegateChromeOS::LoggedInStateChanged() {
1128 // It apparently sometimes takes a while after login before the current user 1128 // It apparently sometimes takes a while after login before the current user
1129 // is recognized as the owner. Make sure that the system-wide clock setting 1129 // is recognized as the owner. Make sure that the system-wide clock setting
1130 // is updated when the recognition eventually happens 1130 // is updated when the recognition eventually happens
1131 // (http://crbug.com/278601). 1131 // (http://crbug.com/278601).
1132 // 1132 //
1133 // Note that it isn't safe to blindly call UpdateClockType() from this 1133 // Note that it isn't safe to blindly call UpdateClockType() from this
1134 // method, as LoggedInStateChanged() is also called before the logged-in 1134 // method, as LoggedInStateChanged() is also called before the logged-in
1135 // user's profile has actually been loaded (http://crbug.com/317745). The 1135 // user's profile has actually been loaded (http://crbug.com/317745). The
1136 // system tray's time format is updated at login via SetProfile(). 1136 // system tray's time format is updated at login via SetProfile().
1137 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { 1137 if (chromeos::GetUserManager()->IsCurrentUserOwner()) {
1138 CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, 1138 CrosSettings::Get()->SetBoolean(kSystemUse24HourClock,
1139 ShouldUse24HourClock()); 1139 ShouldUse24HourClock());
1140 } 1140 }
1141 } 1141 }
1142 1142
1143 // Overridden from SessionManagerClient::Observer. 1143 // Overridden from SessionManagerClient::Observer.
1144 void SystemTrayDelegateChromeOS::ScreenIsLocked() { 1144 void SystemTrayDelegateChromeOS::ScreenIsLocked() {
1145 screen_locked_ = true; 1145 screen_locked_ = true;
1146 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(GetUserLoginStatus()); 1146 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
1147 } 1147 }
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 accessibility_subscription_.reset(); 1398 accessibility_subscription_.reset();
1399 else 1399 else
1400 OnAccessibilityModeChanged(details.notify); 1400 OnAccessibilityModeChanged(details.notify);
1401 } 1401 }
1402 1402
1403 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1403 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1404 return new SystemTrayDelegateChromeOS(); 1404 return new SystemTrayDelegateChromeOS();
1405 } 1405 }
1406 1406
1407 } // namespace chromeos 1407 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698