| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/login/user_manager.h" | 5 #include "chrome/browser/chromeos/login/user_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 18 #include "base/rand_util.h" | 18 #include "base/rand_util.h" |
| 19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 20 #include "base/stringprintf.h" | 20 #include "base/stringprintf.h" |
| 21 #include "base/time.h" | 21 #include "base/time.h" |
| 22 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
| 23 #include "base/values.h" | 23 #include "base/values.h" |
| 24 #include "crypto/nss_util.h" | 24 #include "crypto/nss_util.h" |
| 25 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
| 26 #include "chrome/browser/chromeos/cros_settings.h" |
| 26 #include "chrome/browser/chromeos/cros/cros_library.h" | 27 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 27 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 28 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
| 28 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 29 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 29 #include "chrome/browser/chromeos/login/default_user_images.h" | 30 #include "chrome/browser/chromeos/login/default_user_images.h" |
| 30 #include "chrome/browser/chromeos/login/login_display.h" | 31 #include "chrome/browser/chromeos/login/login_display.h" |
| 31 #include "chrome/browser/chromeos/login/ownership_service.h" | 32 #include "chrome/browser/chromeos/login/ownership_service.h" |
| 32 #include "chrome/browser/chromeos/user_cros_settings_provider.h" | 33 #include "chrome/browser/chromeos/user_cros_settings_provider.h" |
| 33 #include "chrome/browser/defaults.h" | 34 #include "chrome/browser/defaults.h" |
| 34 #include "chrome/browser/prefs/pref_service.h" | 35 #include "chrome/browser/prefs/pref_service.h" |
| 35 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 36 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 delegate_(delegate), | 206 delegate_(delegate), |
| 206 weak_factory_(this) { | 207 weak_factory_(this) { |
| 207 RemoveUser(); | 208 RemoveUser(); |
| 208 } | 209 } |
| 209 | 210 |
| 210 virtual ~RemoveAttempt() {} | 211 virtual ~RemoveAttempt() {} |
| 211 | 212 |
| 212 void RemoveUser() { | 213 void RemoveUser() { |
| 213 // Owner is not allowed to be removed from the device. | 214 // Owner is not allowed to be removed from the device. |
| 214 // Must not proceed without signature verification. | 215 // Must not proceed without signature verification. |
| 215 UserCrosSettingsProvider user_settings; | 216 CrosSettings* cros_settings = CrosSettings::Get(); |
| 216 bool trusted_owner_available = user_settings.RequestTrustedOwner( | 217 bool trusted_owner_available = cros_settings->GetTrusted( |
| 218 kDeviceOwner, |
| 217 base::Bind(&RemoveAttempt::RemoveUser, weak_factory_.GetWeakPtr())); | 219 base::Bind(&RemoveAttempt::RemoveUser, weak_factory_.GetWeakPtr())); |
| 218 if (!trusted_owner_available) { | 220 if (!trusted_owner_available) { |
| 219 // Value of owner email is still not verified. | 221 // Value of owner email is still not verified. |
| 220 // Another attempt will be invoked after verification completion. | 222 // Another attempt will be invoked after verification completion. |
| 221 return; | 223 return; |
| 222 } | 224 } |
| 223 if (user_email_ == UserCrosSettingsProvider::cached_owner()) { | 225 std::string owner; |
| 226 cros_settings->GetString(kDeviceOwner, &owner); |
| 227 if (user_email_ == owner) { |
| 224 // Owner is not allowed to be removed from the device. Probably on | 228 // Owner is not allowed to be removed from the device. Probably on |
| 225 // the stack, so deffer the deletion. | 229 // the stack, so deffer the deletion. |
| 226 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 230 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 227 return; | 231 return; |
| 228 } | 232 } |
| 229 | 233 |
| 230 if (delegate_) | 234 if (delegate_) |
| 231 delegate_->OnBeforeUserRemoved(user_email_); | 235 delegate_->OnBeforeUserRemoved(user_email_); |
| 232 | 236 |
| 233 chromeos::UserManager::Get()->RemoveUserFromList(user_email_); | 237 chromeos::UserManager::Get()->RemoveUserFromList(user_email_); |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 observer_list_, | 819 observer_list_, |
| 816 LocalStateChanged(this)); | 820 LocalStateChanged(this)); |
| 817 } | 821 } |
| 818 | 822 |
| 819 void UserManager::DownloadProfileImage() { | 823 void UserManager::DownloadProfileImage() { |
| 820 profile_image_downloader_.reset(new ProfileImageDownloader(this)); | 824 profile_image_downloader_.reset(new ProfileImageDownloader(this)); |
| 821 profile_image_downloader_->Start(); | 825 profile_image_downloader_->Start(); |
| 822 } | 826 } |
| 823 | 827 |
| 824 } // namespace chromeos | 828 } // namespace chromeos |
| OLD | NEW |