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

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: similarity 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 const base::string16 SystemTrayDelegateChromeOS::GetEnterpriseMessage() const { 366 const base::string16 SystemTrayDelegateChromeOS::GetEnterpriseMessage() const {
365 if (GetEnterpriseDomain().empty()) 367 if (GetEnterpriseDomain().empty())
366 return base::string16(); 368 return base::string16();
367 return l10n_util::GetStringFUTF16(IDS_DEVICE_OWNED_BY_NOTICE, 369 return l10n_util::GetStringFUTF16(IDS_DEVICE_OWNED_BY_NOTICE,
368 base::UTF8ToUTF16(GetEnterpriseDomain())); 370 base::UTF8ToUTF16(GetEnterpriseDomain()));
369 } 371 }
370 372
371 const std::string SystemTrayDelegateChromeOS::GetSupervisedUserManager() const { 373 const std::string SystemTrayDelegateChromeOS::GetSupervisedUserManager() const {
372 if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED) 374 if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED)
373 return std::string(); 375 return std::string();
374 return UserManager::Get()->GetSupervisedUserManager()->GetManagerDisplayEmail( 376 return ChromeUserManager::Get()
375 chromeos::UserManager::Get()->GetActiveUser()->email()); 377 ->GetSupervisedUserManager()
378 ->GetManagerDisplayEmail(
379 user_manager::UserManager::Get()->GetActiveUser()->email());
376 } 380 }
377 381
378 const base::string16 382 const base::string16
379 SystemTrayDelegateChromeOS::GetSupervisedUserManagerName() const { 383 SystemTrayDelegateChromeOS::GetSupervisedUserManagerName() const {
380 if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED) 384 if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED)
381 return base::string16(); 385 return base::string16();
382 return UserManager::Get()->GetSupervisedUserManager()->GetManagerDisplayName( 386 return ChromeUserManager::Get()
383 chromeos::UserManager::Get()->GetActiveUser()->email()); 387 ->GetSupervisedUserManager()
388 ->GetManagerDisplayName(
389 user_manager::UserManager::Get()->GetActiveUser()->email());
384 } 390 }
385 391
386 const base::string16 SystemTrayDelegateChromeOS::GetSupervisedUserMessage() 392 const base::string16 SystemTrayDelegateChromeOS::GetSupervisedUserMessage()
387 const { 393 const {
388 if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED) 394 if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED)
389 return base::string16(); 395 return base::string16();
390 return l10n_util::GetStringFUTF16( 396 return l10n_util::GetStringFUTF16(
391 IDS_USER_IS_SUPERVISED_BY_NOTICE, 397 IDS_USER_IS_SUPERVISED_BY_NOTICE,
392 base::UTF8ToUTF16(GetSupervisedUserManager())); 398 base::UTF8ToUTF16(GetSupervisedUserManager()));
393 } 399 }
394 400
395 bool SystemTrayDelegateChromeOS::SystemShouldUpgrade() const { 401 bool SystemTrayDelegateChromeOS::SystemShouldUpgrade() const {
396 return UpgradeDetector::GetInstance()->notify_upgrade(); 402 return UpgradeDetector::GetInstance()->notify_upgrade();
397 } 403 }
398 404
399 base::HourClockType SystemTrayDelegateChromeOS::GetHourClockType() const { 405 base::HourClockType SystemTrayDelegateChromeOS::GetHourClockType() const {
400 return clock_type_; 406 return clock_type_;
401 } 407 }
402 408
403 void SystemTrayDelegateChromeOS::ShowSettings() { 409 void SystemTrayDelegateChromeOS::ShowSettings() {
404 ShowSettingsSubPageForActiveUser(""); 410 ShowSettingsSubPageForActiveUser("");
405 } 411 }
406 412
407 bool SystemTrayDelegateChromeOS::ShouldShowSettings() { 413 bool SystemTrayDelegateChromeOS::ShouldShowSettings() {
408 return UserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() && 414 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() &&
409 !ash::Shell::GetInstance() 415 !ash::Shell::GetInstance()
410 ->session_state_delegate() 416 ->session_state_delegate()
411 ->IsInSecondaryLoginScreen(); 417 ->IsInSecondaryLoginScreen();
412 } 418 }
413 419
414 void SystemTrayDelegateChromeOS::ShowDateSettings() { 420 void SystemTrayDelegateChromeOS::ShowDateSettings() {
415 content::RecordAction(base::UserMetricsAction("ShowDateOptions")); 421 content::RecordAction(base::UserMetricsAction("ShowDateOptions"));
416 std::string sub_page = 422 std::string sub_page =
417 std::string(chrome::kSearchSubPage) + "#" + 423 std::string(chrome::kSearchSubPage) + "#" +
418 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME); 424 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 GURL(chrome::kLearnMoreEnterpriseURL)); 533 GURL(chrome::kLearnMoreEnterpriseURL));
528 } 534 }
529 } 535 }
530 536
531 void SystemTrayDelegateChromeOS::ShowUserLogin() { 537 void SystemTrayDelegateChromeOS::ShowUserLogin() {
532 ash::Shell* shell = ash::Shell::GetInstance(); 538 ash::Shell* shell = ash::Shell::GetInstance();
533 if (!shell->delegate()->IsMultiProfilesEnabled()) 539 if (!shell->delegate()->IsMultiProfilesEnabled())
534 return; 540 return;
535 541
536 // Only regular users could add other users to current session. 542 // Only regular users could add other users to current session.
537 if (UserManager::Get()->GetActiveUser()->GetType() != 543 if (user_manager::UserManager::Get()->GetActiveUser()->GetType() !=
538 user_manager::USER_TYPE_REGULAR) { 544 user_manager::USER_TYPE_REGULAR) {
539 return; 545 return;
540 } 546 }
541 547
542 if (static_cast<int>(UserManager::Get()->GetLoggedInUsers().size()) >= 548 if (static_cast<int>(
549 user_manager::UserManager::Get()->GetLoggedInUsers().size()) >=
543 shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers()) 550 shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers())
544 return; 551 return;
545 552
546 // Launch sign in screen to add another user to current session. 553 // Launch sign in screen to add another user to current session.
547 if (UserManager::Get()->GetUsersAdmittedForMultiProfile().size()) { 554 if (user_manager::UserManager::Get()
555 ->GetUsersAdmittedForMultiProfile()
556 .size()) {
548 // Don't show dialog if any logged in user in multi-profiles session 557 // Don't show dialog if any logged in user in multi-profiles session
549 // dismissed it. 558 // dismissed it.
550 bool show_intro = true; 559 bool show_intro = true;
551 const user_manager::UserList logged_in_users = 560 const user_manager::UserList logged_in_users =
552 UserManager::Get()->GetLoggedInUsers(); 561 user_manager::UserManager::Get()->GetLoggedInUsers();
553 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); 562 for (user_manager::UserList::const_iterator it = logged_in_users.begin();
554 it != logged_in_users.end(); 563 it != logged_in_users.end();
555 ++it) { 564 ++it) {
556 show_intro &= !multi_user_util::GetProfileFromUserID( 565 show_intro &= !multi_user_util::GetProfileFromUserID(
557 multi_user_util::GetUserIDFromEmail((*it)->email())) 566 multi_user_util::GetUserIDFromEmail((*it)->email()))
558 ->GetPrefs() 567 ->GetPrefs()
559 ->GetBoolean(prefs::kMultiProfileNeverShowIntro); 568 ->GetBoolean(prefs::kMultiProfileNeverShowIntro);
560 if (!show_intro) 569 if (!show_intro)
561 break; 570 break;
562 } 571 }
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 } 828 }
820 829
821 bool SystemTrayDelegateChromeOS::IsSearchKeyMappedToCapsLock() { 830 bool SystemTrayDelegateChromeOS::IsSearchKeyMappedToCapsLock() {
822 return search_key_mapped_to_ == input_method::kCapsLockKey; 831 return search_key_mapped_to_ == input_method::kCapsLockKey;
823 } 832 }
824 833
825 ash::tray::UserAccountsDelegate* 834 ash::tray::UserAccountsDelegate*
826 SystemTrayDelegateChromeOS::GetUserAccountsDelegate( 835 SystemTrayDelegateChromeOS::GetUserAccountsDelegate(
827 const std::string& user_id) { 836 const std::string& user_id) {
828 if (!accounts_delegates_.contains(user_id)) { 837 if (!accounts_delegates_.contains(user_id)) {
829 const user_manager::User* user = UserManager::Get()->FindUser(user_id); 838 const user_manager::User* user =
839 user_manager::UserManager::Get()->FindUser(user_id);
830 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user); 840 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user);
831 CHECK(user_profile); 841 CHECK(user_profile);
832 accounts_delegates_.set( 842 accounts_delegates_.set(
833 user_id, 843 user_id,
834 scoped_ptr<ash::tray::UserAccountsDelegate>( 844 scoped_ptr<ash::tray::UserAccountsDelegate>(
835 new UserAccountsDelegateChromeOS(user_profile))); 845 new UserAccountsDelegateChromeOS(user_profile)));
836 } 846 }
837 return accounts_delegates_.get(user_id); 847 return accounts_delegates_.get(user_id);
838 } 848 }
839 849
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 user_pref->GetValue()->GetAsBoolean(&use_24_hour_clock); 948 user_pref->GetValue()->GetAsBoolean(&use_24_hour_clock);
939 return use_24_hour_clock; 949 return use_24_hour_clock;
940 } 950 }
941 951
942 void SystemTrayDelegateChromeOS::UpdateClockType() { 952 void SystemTrayDelegateChromeOS::UpdateClockType() {
943 const bool use_24_hour_clock = ShouldUse24HourClock(); 953 const bool use_24_hour_clock = ShouldUse24HourClock();
944 clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock; 954 clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock;
945 GetSystemTrayNotifier()->NotifyDateFormatChanged(); 955 GetSystemTrayNotifier()->NotifyDateFormatChanged();
946 // This also works for enterprise-managed devices because they never have 956 // This also works for enterprise-managed devices because they never have
947 // local owner. 957 // local owner.
948 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) 958 if (user_manager::UserManager::Get()->IsCurrentUserOwner())
949 CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, use_24_hour_clock); 959 CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, use_24_hour_clock);
950 } 960 }
951 961
952 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() { 962 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() {
953 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged( 963 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged(
954 user_pref_registrar_->prefs()->GetBoolean( 964 user_pref_registrar_->prefs()->GetBoolean(
955 prefs::kShowLogoutButtonInTray)); 965 prefs::kShowLogoutButtonInTray));
956 } 966 }
957 967
958 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() { 968 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 void SystemTrayDelegateChromeOS::LoggedInStateChanged() { 1038 void SystemTrayDelegateChromeOS::LoggedInStateChanged() {
1029 // It apparently sometimes takes a while after login before the current user 1039 // It apparently sometimes takes a while after login before the current user
1030 // is recognized as the owner. Make sure that the system-wide clock setting 1040 // is recognized as the owner. Make sure that the system-wide clock setting
1031 // is updated when the recognition eventually happens 1041 // is updated when the recognition eventually happens
1032 // (http://crbug.com/278601). 1042 // (http://crbug.com/278601).
1033 // 1043 //
1034 // Note that it isn't safe to blindly call UpdateClockType() from this 1044 // Note that it isn't safe to blindly call UpdateClockType() from this
1035 // method, as LoggedInStateChanged() is also called before the logged-in 1045 // method, as LoggedInStateChanged() is also called before the logged-in
1036 // user's profile has actually been loaded (http://crbug.com/317745). The 1046 // user's profile has actually been loaded (http://crbug.com/317745). The
1037 // system tray's time format is updated at login via SetProfile(). 1047 // system tray's time format is updated at login via SetProfile().
1038 if (chromeos::UserManager::Get()->IsCurrentUserOwner()) { 1048 if (user_manager::UserManager::Get()->IsCurrentUserOwner()) {
1039 CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, 1049 CrosSettings::Get()->SetBoolean(kSystemUse24HourClock,
1040 ShouldUse24HourClock()); 1050 ShouldUse24HourClock());
1041 } 1051 }
1042 } 1052 }
1043 1053
1044 // Overridden from SessionManagerClient::Observer. 1054 // Overridden from SessionManagerClient::Observer.
1045 void SystemTrayDelegateChromeOS::ScreenIsLocked() { 1055 void SystemTrayDelegateChromeOS::ScreenIsLocked() {
1046 screen_locked_ = true; 1056 screen_locked_ = true;
1047 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(GetUserLoginStatus()); 1057 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
1048 } 1058 }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 accessibility_subscription_.reset(); 1284 accessibility_subscription_.reset();
1275 else 1285 else
1276 OnAccessibilityModeChanged(details.notify); 1286 OnAccessibilityModeChanged(details.notify);
1277 } 1287 }
1278 1288
1279 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1289 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1280 return new SystemTrayDelegateChromeOS(); 1290 return new SystemTrayDelegateChromeOS();
1281 } 1291 }
1282 1292
1283 } // namespace chromeos 1293 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698