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

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

Issue 1019283004: Switch to direct use of OwnerSettingsServiceChromeOS::Set() in tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits. Created 5 years, 8 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>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "chrome/browser/chromeos/input_method/input_method_util.h" 51 #include "chrome/browser/chromeos/input_method/input_method_util.h"
52 #include "chrome/browser/chromeos/login/help_app_launcher.h" 52 #include "chrome/browser/chromeos/login/help_app_launcher.h"
53 #include "chrome/browser/chromeos/login/login_wizard.h" 53 #include "chrome/browser/chromeos/login/login_wizard.h"
54 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 54 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
55 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 55 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
56 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" 56 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
57 #include "chrome/browser/chromeos/login/user_flow.h" 57 #include "chrome/browser/chromeos/login/user_flow.h"
58 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 58 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
59 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 59 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
60 #include "chrome/browser/chromeos/options/network_config_view.h" 60 #include "chrome/browser/chromeos/options/network_config_view.h"
61 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
62 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact ory.h"
61 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 63 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
62 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 64 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
63 #include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h" 65 #include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h"
64 #include "chrome/browser/chromeos/profiles/profile_helper.h" 66 #include "chrome/browser/chromeos/profiles/profile_helper.h"
65 #include "chrome/browser/chromeos/set_time_dialog.h" 67 #include "chrome/browser/chromeos/set_time_dialog.h"
66 #include "chrome/browser/chromeos/settings/cros_settings.h" 68 #include "chrome/browser/chromeos/settings/cros_settings.h"
67 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" 69 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h"
68 #include "chrome/browser/lifetime/application_lifetime.h" 70 #include "chrome/browser/lifetime/application_lifetime.h"
69 #include "chrome/browser/profiles/profile_manager.h" 71 #include "chrome/browser/profiles/profile_manager.h"
70 #include "chrome/browser/supervised_user/supervised_user_service.h" 72 #include "chrome/browser/supervised_user/supervised_user_service.h"
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 user_pref->GetValue()->GetAsBoolean(&use_24_hour_clock); 1013 user_pref->GetValue()->GetAsBoolean(&use_24_hour_clock);
1012 return use_24_hour_clock; 1014 return use_24_hour_clock;
1013 } 1015 }
1014 1016
1015 void SystemTrayDelegateChromeOS::UpdateClockType() { 1017 void SystemTrayDelegateChromeOS::UpdateClockType() {
1016 const bool use_24_hour_clock = ShouldUse24HourClock(); 1018 const bool use_24_hour_clock = ShouldUse24HourClock();
1017 clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock; 1019 clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock;
1018 GetSystemTrayNotifier()->NotifyDateFormatChanged(); 1020 GetSystemTrayNotifier()->NotifyDateFormatChanged();
1019 // This also works for enterprise-managed devices because they never have 1021 // This also works for enterprise-managed devices because they never have
1020 // local owner. 1022 // local owner.
1021 if (user_manager::UserManager::Get()->IsCurrentUserOwner()) 1023 if (user_manager::UserManager::Get()->IsCurrentUserOwner()) {
1022 CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, use_24_hour_clock); 1024 Profile* const profile = ProfileManager::GetActiveUserProfile();
bartfab (slow) 2015/04/10 08:38:14 ProfileManager::GetActiveUserProfile() is dangerou
Ivan Podogov 2015/04/10 09:50:53 OK, it was changed from that some iterations ago b
1025 OwnerSettingsServiceChromeOS* const service =
1026 OwnerSettingsServiceChromeOSFactory::GetForBrowserContext(profile);
1027 service->SetBoolean(kSystemUse24HourClock, use_24_hour_clock);
1028 }
1023 } 1029 }
1024 1030
1025 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() { 1031 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() {
1026 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged( 1032 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged(
1027 user_pref_registrar_->prefs()->GetBoolean( 1033 user_pref_registrar_->prefs()->GetBoolean(
1028 prefs::kShowLogoutButtonInTray)); 1034 prefs::kShowLogoutButtonInTray));
1029 } 1035 }
1030 1036
1031 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() { 1037 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() {
1032 const int duration_ms = 1038 const int duration_ms =
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 // It apparently sometimes takes a while after login before the current user 1119 // It apparently sometimes takes a while after login before the current user
1114 // is recognized as the owner. Make sure that the system-wide clock setting 1120 // is recognized as the owner. Make sure that the system-wide clock setting
1115 // is updated when the recognition eventually happens 1121 // is updated when the recognition eventually happens
1116 // (http://crbug.com/278601). 1122 // (http://crbug.com/278601).
1117 // 1123 //
1118 // Note that it isn't safe to blindly call UpdateClockType() from this 1124 // Note that it isn't safe to blindly call UpdateClockType() from this
1119 // method, as LoggedInStateChanged() is also called before the logged-in 1125 // method, as LoggedInStateChanged() is also called before the logged-in
1120 // user's profile has actually been loaded (http://crbug.com/317745). The 1126 // user's profile has actually been loaded (http://crbug.com/317745). The
1121 // system tray's time format is updated at login via SetProfile(). 1127 // system tray's time format is updated at login via SetProfile().
1122 if (user_manager::UserManager::Get()->IsCurrentUserOwner()) { 1128 if (user_manager::UserManager::Get()->IsCurrentUserOwner()) {
1123 CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, 1129 Profile* const profile = ProfileManager::GetActiveUserProfile();
bartfab (slow) 2015/04/10 08:38:14 As above, please do not use ProfileManager::GetAct
Ivan Podogov 2015/04/10 09:50:53 Done.
1124 ShouldUse24HourClock()); 1130 OwnerSettingsServiceChromeOS* const service =
1131 OwnerSettingsServiceChromeOSFactory::GetForBrowserContext(profile);
1132 service->SetBoolean(kSystemUse24HourClock, ShouldUse24HourClock());
1125 } 1133 }
1126 } 1134 }
1127 1135
1128 // Overridden from SessionManagerClient::Observer. 1136 // Overridden from SessionManagerClient::Observer.
1129 void SystemTrayDelegateChromeOS::ScreenIsLocked() { 1137 void SystemTrayDelegateChromeOS::ScreenIsLocked() {
1130 screen_locked_ = true; 1138 screen_locked_ = true;
1131 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(GetUserLoginStatus()); 1139 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
1132 } 1140 }
1133 1141
1134 void SystemTrayDelegateChromeOS::ScreenIsUnlocked() { 1142 void SystemTrayDelegateChromeOS::ScreenIsUnlocked() {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
1399 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " 1407 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while "
1400 << "ENABLE_SUPERVISED_USERS undefined."; 1408 << "ENABLE_SUPERVISED_USERS undefined.";
1401 return base::string16(); 1409 return base::string16();
1402 } 1410 }
1403 1411
1404 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1412 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1405 return new SystemTrayDelegateChromeOS(); 1413 return new SystemTrayDelegateChromeOS();
1406 } 1414 }
1407 1415
1408 } // namespace chromeos 1416 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698