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

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

Issue 444903002: [cros] user_manager component - move UserManagerBase and UserManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "chrome/browser/chromeos/charger_replace/charger_replacement_dialog.h" 49 #include "chrome/browser/chromeos/charger_replace/charger_replacement_dialog.h"
50 #include "chrome/browser/chromeos/enrollment_dialog_view.h" 50 #include "chrome/browser/chromeos/enrollment_dialog_view.h"
51 #include "chrome/browser/chromeos/events/system_key_event_listener.h" 51 #include "chrome/browser/chromeos/events/system_key_event_listener.h"
52 #include "chrome/browser/chromeos/input_method/input_method_util.h" 52 #include "chrome/browser/chromeos/input_method/input_method_util.h"
53 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" 53 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
54 #include "chrome/browser/chromeos/login/help_app_launcher.h" 54 #include "chrome/browser/chromeos/login/help_app_launcher.h"
55 #include "chrome/browser/chromeos/login/login_wizard.h" 55 #include "chrome/browser/chromeos/login/login_wizard.h"
56 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 56 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
57 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 57 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
58 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" 58 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
59 #include "chrome/browser/chromeos/login/user_flow.h"
60 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
59 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 61 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
60 #include "chrome/browser/chromeos/login/users/user_manager.h"
61 #include "chrome/browser/chromeos/options/network_config_view.h" 62 #include "chrome/browser/chromeos/options/network_config_view.h"
62 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 63 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
63 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 64 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
64 #include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h" 65 #include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h"
65 #include "chrome/browser/chromeos/profiles/profile_helper.h" 66 #include "chrome/browser/chromeos/profiles/profile_helper.h"
66 #include "chrome/browser/chromeos/set_time_dialog.h" 67 #include "chrome/browser/chromeos/set_time_dialog.h"
67 #include "chrome/browser/chromeos/settings/cros_settings.h" 68 #include "chrome/browser/chromeos/settings/cros_settings.h"
68 #include "chrome/browser/chromeos/sim_dialog_delegate.h" 69 #include "chrome/browser/chromeos/sim_dialog_delegate.h"
69 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" 70 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h"
70 #include "chrome/browser/lifetime/application_lifetime.h" 71 #include "chrome/browser/lifetime/application_lifetime.h"
(...skipping 18 matching lines...) Expand all
89 #include "chromeos/dbus/dbus_thread_manager.h" 90 #include "chromeos/dbus/dbus_thread_manager.h"
90 #include "chromeos/dbus/session_manager_client.h" 91 #include "chromeos/dbus/session_manager_client.h"
91 #include "chromeos/ime/extension_ime_util.h" 92 #include "chromeos/ime/extension_ime_util.h"
92 #include "chromeos/ime/ime_keyboard.h" 93 #include "chromeos/ime/ime_keyboard.h"
93 #include "chromeos/ime/input_method_manager.h" 94 #include "chromeos/ime/input_method_manager.h"
94 #include "chromeos/login/login_state.h" 95 #include "chromeos/login/login_state.h"
95 #include "chromeos/network/portal_detector/network_portal_detector.h" 96 #include "chromeos/network/portal_detector/network_portal_detector.h"
96 #include "components/google/core/browser/google_util.h" 97 #include "components/google/core/browser/google_util.h"
97 #include "components/policy/core/common/cloud/cloud_policy_store.h" 98 #include "components/policy/core/common/cloud/cloud_policy_store.h"
98 #include "components/user_manager/user.h" 99 #include "components/user_manager/user.h"
100 #include "components/user_manager/user_manager.h"
99 #include "components/user_manager/user_type.h" 101 #include "components/user_manager/user_type.h"
100 #include "content/public/browser/notification_observer.h" 102 #include "content/public/browser/notification_observer.h"
101 #include "content/public/browser/notification_service.h" 103 #include "content/public/browser/notification_service.h"
102 #include "content/public/browser/user_metrics.h" 104 #include "content/public/browser/user_metrics.h"
103 #include "content/public/browser/web_contents.h" 105 #include "content/public/browser/web_contents.h"
104 #include "device/bluetooth/bluetooth_adapter.h" 106 #include "device/bluetooth/bluetooth_adapter.h"
105 #include "device/bluetooth/bluetooth_adapter_factory.h" 107 #include "device/bluetooth/bluetooth_adapter_factory.h"
106 #include "device/bluetooth/bluetooth_device.h" 108 #include "device/bluetooth/bluetooth_device.h"
107 #include "grit/ash_strings.h" 109 #include "grit/ash_strings.h"
108 #include "grit/generated_resources.h" 110 #include "grit/generated_resources.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 const base::string16 SystemTrayDelegateChromeOS::GetEnterpriseMessage() const { 370 const base::string16 SystemTrayDelegateChromeOS::GetEnterpriseMessage() const {
369 if (GetEnterpriseDomain().empty()) 371 if (GetEnterpriseDomain().empty())
370 return base::string16(); 372 return base::string16();
371 return l10n_util::GetStringFUTF16(IDS_DEVICE_OWNED_BY_NOTICE, 373 return l10n_util::GetStringFUTF16(IDS_DEVICE_OWNED_BY_NOTICE,
372 base::UTF8ToUTF16(GetEnterpriseDomain())); 374 base::UTF8ToUTF16(GetEnterpriseDomain()));
373 } 375 }
374 376
375 const std::string SystemTrayDelegateChromeOS::GetSupervisedUserManager() const { 377 const std::string SystemTrayDelegateChromeOS::GetSupervisedUserManager() const {
376 if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED) 378 if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED)
377 return std::string(); 379 return std::string();
378 return UserManager::Get()->GetSupervisedUserManager()->GetManagerDisplayEmail( 380 return ChromeUserManager::Get()
379 chromeos::UserManager::Get()->GetActiveUser()->email()); 381 ->GetSupervisedUserManager()
382 ->GetManagerDisplayEmail(
383 user_manager::UserManager::Get()->GetActiveUser()->email());
380 } 384 }
381 385
382 const base::string16 386 const base::string16
383 SystemTrayDelegateChromeOS::GetSupervisedUserManagerName() const { 387 SystemTrayDelegateChromeOS::GetSupervisedUserManagerName() const {
384 if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED) 388 if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED)
385 return base::string16(); 389 return base::string16();
386 return UserManager::Get()->GetSupervisedUserManager()->GetManagerDisplayName( 390 return ChromeUserManager::Get()
387 chromeos::UserManager::Get()->GetActiveUser()->email()); 391 ->GetSupervisedUserManager()
392 ->GetManagerDisplayName(
393 user_manager::UserManager::Get()->GetActiveUser()->email());
388 } 394 }
389 395
390 const base::string16 SystemTrayDelegateChromeOS::GetSupervisedUserMessage() 396 const base::string16 SystemTrayDelegateChromeOS::GetSupervisedUserMessage()
391 const { 397 const {
392 if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED) 398 if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED)
393 return base::string16(); 399 return base::string16();
394 return l10n_util::GetStringFUTF16( 400 return l10n_util::GetStringFUTF16(
395 IDS_USER_IS_SUPERVISED_BY_NOTICE, 401 IDS_USER_IS_SUPERVISED_BY_NOTICE,
396 base::UTF8ToUTF16(GetSupervisedUserManager())); 402 base::UTF8ToUTF16(GetSupervisedUserManager()));
397 } 403 }
398 404
399 bool SystemTrayDelegateChromeOS::SystemShouldUpgrade() const { 405 bool SystemTrayDelegateChromeOS::SystemShouldUpgrade() const {
400 return UpgradeDetector::GetInstance()->notify_upgrade(); 406 return UpgradeDetector::GetInstance()->notify_upgrade();
401 } 407 }
402 408
403 base::HourClockType SystemTrayDelegateChromeOS::GetHourClockType() const { 409 base::HourClockType SystemTrayDelegateChromeOS::GetHourClockType() const {
404 return clock_type_; 410 return clock_type_;
405 } 411 }
406 412
407 void SystemTrayDelegateChromeOS::ShowSettings() { 413 void SystemTrayDelegateChromeOS::ShowSettings() {
408 ShowSettingsSubPageForActiveUser(""); 414 ShowSettingsSubPageForActiveUser("");
409 } 415 }
410 416
411 bool SystemTrayDelegateChromeOS::ShouldShowSettings() { 417 bool SystemTrayDelegateChromeOS::ShouldShowSettings() {
412 return UserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() && 418 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() &&
413 !ash::Shell::GetInstance() 419 !ash::Shell::GetInstance()
414 ->session_state_delegate() 420 ->session_state_delegate()
415 ->IsInSecondaryLoginScreen(); 421 ->IsInSecondaryLoginScreen();
416 } 422 }
417 423
418 void SystemTrayDelegateChromeOS::ShowDateSettings() { 424 void SystemTrayDelegateChromeOS::ShowDateSettings() {
419 content::RecordAction(base::UserMetricsAction("ShowDateOptions")); 425 content::RecordAction(base::UserMetricsAction("ShowDateOptions"));
420 std::string sub_page = 426 std::string sub_page =
421 std::string(chrome::kSearchSubPage) + "#" + 427 std::string(chrome::kSearchSubPage) + "#" +
422 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME); 428 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 GURL(chrome::kLearnMoreEnterpriseURL)); 537 GURL(chrome::kLearnMoreEnterpriseURL));
532 } 538 }
533 } 539 }
534 540
535 void SystemTrayDelegateChromeOS::ShowUserLogin() { 541 void SystemTrayDelegateChromeOS::ShowUserLogin() {
536 ash::Shell* shell = ash::Shell::GetInstance(); 542 ash::Shell* shell = ash::Shell::GetInstance();
537 if (!shell->delegate()->IsMultiProfilesEnabled()) 543 if (!shell->delegate()->IsMultiProfilesEnabled())
538 return; 544 return;
539 545
540 // Only regular users could add other users to current session. 546 // Only regular users could add other users to current session.
541 if (UserManager::Get()->GetActiveUser()->GetType() != 547 if (user_manager::UserManager::Get()->GetActiveUser()->GetType() !=
542 user_manager::USER_TYPE_REGULAR) { 548 user_manager::USER_TYPE_REGULAR) {
543 return; 549 return;
544 } 550 }
545 551
546 if (static_cast<int>(UserManager::Get()->GetLoggedInUsers().size()) >= 552 if (static_cast<int>(
553 user_manager::UserManager::Get()->GetLoggedInUsers().size()) >=
547 shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers()) 554 shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers())
548 return; 555 return;
549 556
550 // Launch sign in screen to add another user to current session. 557 // Launch sign in screen to add another user to current session.
551 if (UserManager::Get()->GetUsersAdmittedForMultiProfile().size()) { 558 if (user_manager::UserManager::Get()
559 ->GetUsersAdmittedForMultiProfile()
560 .size()) {
552 // Don't show dialog if any logged in user in multi-profiles session 561 // Don't show dialog if any logged in user in multi-profiles session
553 // dismissed it. 562 // dismissed it.
554 bool show_intro = true; 563 bool show_intro = true;
555 const user_manager::UserList logged_in_users = 564 const user_manager::UserList logged_in_users =
556 UserManager::Get()->GetLoggedInUsers(); 565 user_manager::UserManager::Get()->GetLoggedInUsers();
557 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); 566 for (user_manager::UserList::const_iterator it = logged_in_users.begin();
558 it != logged_in_users.end(); 567 it != logged_in_users.end();
559 ++it) { 568 ++it) {
560 show_intro &= !multi_user_util::GetProfileFromUserID( 569 show_intro &= !multi_user_util::GetProfileFromUserID(
561 multi_user_util::GetUserIDFromEmail((*it)->email())) 570 multi_user_util::GetUserIDFromEmail((*it)->email()))
562 ->GetPrefs() 571 ->GetPrefs()
563 ->GetBoolean(prefs::kMultiProfileNeverShowIntro); 572 ->GetBoolean(prefs::kMultiProfileNeverShowIntro);
564 if (!show_intro) 573 if (!show_intro)
565 break; 574 break;
566 } 575 }
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 } 832 }
824 833
825 bool SystemTrayDelegateChromeOS::IsSearchKeyMappedToCapsLock() { 834 bool SystemTrayDelegateChromeOS::IsSearchKeyMappedToCapsLock() {
826 return search_key_mapped_to_ == input_method::kCapsLockKey; 835 return search_key_mapped_to_ == input_method::kCapsLockKey;
827 } 836 }
828 837
829 ash::tray::UserAccountsDelegate* 838 ash::tray::UserAccountsDelegate*
830 SystemTrayDelegateChromeOS::GetUserAccountsDelegate( 839 SystemTrayDelegateChromeOS::GetUserAccountsDelegate(
831 const std::string& user_id) { 840 const std::string& user_id) {
832 if (!accounts_delegates_.contains(user_id)) { 841 if (!accounts_delegates_.contains(user_id)) {
833 const user_manager::User* user = UserManager::Get()->FindUser(user_id); 842 const user_manager::User* user =
843 user_manager::UserManager::Get()->FindUser(user_id);
834 Profile* user_profile = ProfileHelper::Get()->GetProfileByUserUnsafe(user); 844 Profile* user_profile = ProfileHelper::Get()->GetProfileByUserUnsafe(user);
835 CHECK(user_profile); 845 CHECK(user_profile);
836 accounts_delegates_.set( 846 accounts_delegates_.set(
837 user_id, 847 user_id,
838 scoped_ptr<ash::tray::UserAccountsDelegate>( 848 scoped_ptr<ash::tray::UserAccountsDelegate>(
839 new UserAccountsDelegateChromeOS(user_profile))); 849 new UserAccountsDelegateChromeOS(user_profile)));
840 } 850 }
841 return accounts_delegates_.get(user_id); 851 return accounts_delegates_.get(user_id);
842 } 852 }
843 853
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 user_pref->GetValue()->GetAsBoolean(&use_24_hour_clock); 952 user_pref->GetValue()->GetAsBoolean(&use_24_hour_clock);
943 return use_24_hour_clock; 953 return use_24_hour_clock;
944 } 954 }
945 955
946 void SystemTrayDelegateChromeOS::UpdateClockType() { 956 void SystemTrayDelegateChromeOS::UpdateClockType() {
947 const bool use_24_hour_clock = ShouldUse24HourClock(); 957 const bool use_24_hour_clock = ShouldUse24HourClock();
948 clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock; 958 clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock;
949 GetSystemTrayNotifier()->NotifyDateFormatChanged(); 959 GetSystemTrayNotifier()->NotifyDateFormatChanged();
950 // This also works for enterprise-managed devices because they never have 960 // This also works for enterprise-managed devices because they never have
951 // local owner. 961 // local owner.
952 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) 962 if (user_manager::UserManager::Get()->IsCurrentUserOwner())
953 CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, use_24_hour_clock); 963 CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, use_24_hour_clock);
954 } 964 }
955 965
956 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() { 966 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() {
957 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged( 967 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged(
958 user_pref_registrar_->prefs()->GetBoolean( 968 user_pref_registrar_->prefs()->GetBoolean(
959 prefs::kShowLogoutButtonInTray)); 969 prefs::kShowLogoutButtonInTray));
960 } 970 }
961 971
962 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() { 972 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 void SystemTrayDelegateChromeOS::LoggedInStateChanged() { 1042 void SystemTrayDelegateChromeOS::LoggedInStateChanged() {
1033 // It apparently sometimes takes a while after login before the current user 1043 // It apparently sometimes takes a while after login before the current user
1034 // is recognized as the owner. Make sure that the system-wide clock setting 1044 // is recognized as the owner. Make sure that the system-wide clock setting
1035 // is updated when the recognition eventually happens 1045 // is updated when the recognition eventually happens
1036 // (http://crbug.com/278601). 1046 // (http://crbug.com/278601).
1037 // 1047 //
1038 // Note that it isn't safe to blindly call UpdateClockType() from this 1048 // Note that it isn't safe to blindly call UpdateClockType() from this
1039 // method, as LoggedInStateChanged() is also called before the logged-in 1049 // method, as LoggedInStateChanged() is also called before the logged-in
1040 // user's profile has actually been loaded (http://crbug.com/317745). The 1050 // user's profile has actually been loaded (http://crbug.com/317745). The
1041 // system tray's time format is updated at login via SetProfile(). 1051 // system tray's time format is updated at login via SetProfile().
1042 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { 1052 if (user_manager::UserManager::Get()->IsCurrentUserOwner()) {
1043 CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, 1053 CrosSettings::Get()->SetBoolean(kSystemUse24HourClock,
1044 ShouldUse24HourClock()); 1054 ShouldUse24HourClock());
1045 } 1055 }
1046 } 1056 }
1047 1057
1048 // Overridden from SessionManagerClient::Observer. 1058 // Overridden from SessionManagerClient::Observer.
1049 void SystemTrayDelegateChromeOS::ScreenIsLocked() { 1059 void SystemTrayDelegateChromeOS::ScreenIsLocked() {
1050 screen_locked_ = true; 1060 screen_locked_ = true;
1051 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(GetUserLoginStatus()); 1061 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
1052 } 1062 }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 accessibility_subscription_.reset(); 1288 accessibility_subscription_.reset();
1279 else 1289 else
1280 OnAccessibilityModeChanged(details.notify); 1290 OnAccessibilityModeChanged(details.notify);
1281 } 1291 }
1282 1292
1283 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1293 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1284 return new SystemTrayDelegateChromeOS(); 1294 return new SystemTrayDelegateChromeOS();
1285 } 1295 }
1286 1296
1287 } // namespace chromeos 1297 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698