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

Side by Side Diff: chrome/browser/chromeos/policy/device_status_collector.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chromeos/policy/device_status_collector.h" 5 #include "chrome/browser/chromeos/policy/device_status_collector.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <cstdio> 8 #include <cstdio>
9 #include <limits> 9 #include <limits>
10 #include <sstream> 10 #include <sstream>
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // Returns the DeviceLocalAccount associated with the current kiosk session. 142 // Returns the DeviceLocalAccount associated with the current kiosk session.
143 // Returns null if there is no active kiosk session, or if that kiosk 143 // Returns null if there is no active kiosk session, or if that kiosk
144 // session has been removed from policy since the session started, in which 144 // session has been removed from policy since the session started, in which
145 // case we won't report its status). 145 // case we won't report its status).
146 scoped_ptr<policy::DeviceLocalAccount> 146 scoped_ptr<policy::DeviceLocalAccount>
147 GetCurrentKioskDeviceLocalAccount(chromeos::CrosSettings* settings) { 147 GetCurrentKioskDeviceLocalAccount(chromeos::CrosSettings* settings) {
148 if (!user_manager::UserManager::Get()->IsLoggedInAsKioskApp()) 148 if (!user_manager::UserManager::Get()->IsLoggedInAsKioskApp())
149 return scoped_ptr<policy::DeviceLocalAccount>(); 149 return scoped_ptr<policy::DeviceLocalAccount>();
150 const user_manager::User* const user = 150 const user_manager::User* const user =
151 user_manager::UserManager::Get()->GetActiveUser(); 151 user_manager::UserManager::Get()->GetActiveUser();
152 const std::string user_id = user->GetUserID(); 152 const user_manager::UserID user_id = user->GetUserID();
153 const std::vector<policy::DeviceLocalAccount> accounts = 153 const std::vector<policy::DeviceLocalAccount> accounts =
154 policy::GetDeviceLocalAccounts(settings); 154 policy::GetDeviceLocalAccounts(settings);
155 155
156 for (const auto& device_local_account : accounts) { 156 for (const auto& device_local_account : accounts) {
157 if (device_local_account.user_id == user_id) { 157 if (device_local_account.user_id == user_id) {
158 return make_scoped_ptr( 158 return make_scoped_ptr(
159 new policy::DeviceLocalAccount(device_local_account)).Pass(); 159 new policy::DeviceLocalAccount(device_local_account)).Pass();
160 } 160 }
161 } 161 }
162 LOG(WARNING) << "Kiosk app not found in list of device-local accounts"; 162 LOG(WARNING) << "Kiosk app not found in list of device-local accounts";
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 774 g_browser_process->platform_part()->browser_policy_connector_chromeos();
775 const user_manager::UserList& users = 775 const user_manager::UserList& users =
776 user_manager::UserManager::Get()->GetUsers(); 776 user_manager::UserManager::Get()->GetUsers();
777 user_manager::UserList::const_iterator user; 777 user_manager::UserList::const_iterator user;
778 for (user = users.begin(); user != users.end(); ++user) { 778 for (user = users.begin(); user != users.end(); ++user) {
779 // Only users with gaia accounts (regular) are reported. 779 // Only users with gaia accounts (regular) are reported.
780 if (!(*user)->HasGaiaAccount()) 780 if (!(*user)->HasGaiaAccount())
781 continue; 781 continue;
782 782
783 em::DeviceUser* device_user = request->add_user(); 783 em::DeviceUser* device_user = request->add_user();
784 const std::string& email = (*user)->email(); 784 const user_manager::UserID& user_id = (*user)->GetUserID();
785 if (connector->GetUserAffiliation(email) == USER_AFFILIATION_MANAGED) { 785 if (connector->GetUserAffiliation(user_id) == USER_AFFILIATION_MANAGED) {
786 device_user->set_type(em::DeviceUser::USER_TYPE_MANAGED); 786 device_user->set_type(em::DeviceUser::USER_TYPE_MANAGED);
787 device_user->set_email(email); 787 device_user->set_email(user_id.GetUserEmail());
788 } else { 788 } else {
789 device_user->set_type(em::DeviceUser::USER_TYPE_UNMANAGED); 789 device_user->set_type(em::DeviceUser::USER_TYPE_UNMANAGED);
790 // Do not report the email address of unmanaged users. 790 // Do not report the email address of unmanaged users.
791 } 791 }
792 } 792 }
793 } 793 }
794 794
795 void DeviceStatusCollector::GetHardwareStatus( 795 void DeviceStatusCollector::GetHardwareStatus(
796 em::DeviceStatusReportRequest* status) { 796 em::DeviceStatusReportRequest* status) {
797 // Add volume info. 797 // Add volume info.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 ScheduleGeolocationUpdateRequest(); 956 ScheduleGeolocationUpdateRequest();
957 } 957 }
958 958
959 void DeviceStatusCollector::ReceiveVolumeInfo( 959 void DeviceStatusCollector::ReceiveVolumeInfo(
960 const std::vector<em::VolumeInfo>& info) { 960 const std::vector<em::VolumeInfo>& info) {
961 if (report_hardware_status_) 961 if (report_hardware_status_)
962 volume_info_ = info; 962 volume_info_ = info;
963 } 963 }
964 964
965 } // namespace policy 965 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698