| 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/task.h" | 21 #include "base/task.h" |
| 22 #include "base/time.h" | 22 #include "base/time.h" |
| 23 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
| 24 #include "base/values.h" | 24 #include "base/values.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/cert_library.h" | 27 #include "chrome/browser/chromeos/cros/cert_library.h" |
| 27 #include "chrome/browser/chromeos/cros/cros_library.h" | 28 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 28 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 29 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
| 29 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 30 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 30 #include "chrome/browser/chromeos/login/default_user_images.h" | 31 #include "chrome/browser/chromeos/login/default_user_images.h" |
| 31 #include "chrome/browser/chromeos/login/helper.h" | 32 #include "chrome/browser/chromeos/login/helper.h" |
| 32 #include "chrome/browser/chromeos/login/login_display.h" | 33 #include "chrome/browser/chromeos/login/login_display.h" |
| 33 #include "chrome/browser/chromeos/login/ownership_service.h" | 34 #include "chrome/browser/chromeos/login/ownership_service.h" |
| 34 #include "chrome/browser/chromeos/system/runtime_environment.h" | 35 #include "chrome/browser/chromeos/system/runtime_environment.h" |
| 35 #include "chrome/browser/chromeos/user_cros_settings_provider.h" | 36 #include "chrome/browser/chromeos/user_cros_settings_provider.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 delegate_(delegate), | 97 delegate_(delegate), |
| 97 weak_factory_(this) { | 98 weak_factory_(this) { |
| 98 RemoveUser(); | 99 RemoveUser(); |
| 99 } | 100 } |
| 100 | 101 |
| 101 virtual ~RemoveAttempt() {} | 102 virtual ~RemoveAttempt() {} |
| 102 | 103 |
| 103 void RemoveUser() { | 104 void RemoveUser() { |
| 104 // Owner is not allowed to be removed from the device. | 105 // Owner is not allowed to be removed from the device. |
| 105 // Must not proceed without signature verification. | 106 // Must not proceed without signature verification. |
| 106 UserCrosSettingsProvider user_settings; | 107 CrosSettings* cros_settings = CrosSettings::Get(); |
| 107 bool trusted_owner_available = user_settings.RequestTrustedOwner( | 108 bool trusted_owner_available = cros_settings->GetTrusted( |
| 109 kDeviceOwner, |
| 108 base::Bind(&RemoveAttempt::RemoveUser, weak_factory_.GetWeakPtr())); | 110 base::Bind(&RemoveAttempt::RemoveUser, weak_factory_.GetWeakPtr())); |
| 109 if (!trusted_owner_available) { | 111 if (!trusted_owner_available) { |
| 110 // Value of owner email is still not verified. | 112 // Value of owner email is still not verified. |
| 111 // Another attempt will be invoked after verification completion. | 113 // Another attempt will be invoked after verification completion. |
| 112 return; | 114 return; |
| 113 } | 115 } |
| 114 if (user_email_ == UserCrosSettingsProvider::cached_owner()) { | 116 std::string owner; |
| 117 cros_settings->GetString(kDeviceOwner, &owner); |
| 118 if (user_email_ == owner) { |
| 115 // Owner is not allowed to be removed from the device. Probably on | 119 // Owner is not allowed to be removed from the device. Probably on |
| 116 // the stack, so deffer the deletion. | 120 // the stack, so deffer the deletion. |
| 117 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 121 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 118 return; | 122 return; |
| 119 } | 123 } |
| 120 | 124 |
| 121 if (delegate_) | 125 if (delegate_) |
| 122 delegate_->OnBeforeUserRemoved(user_email_); | 126 delegate_->OnBeforeUserRemoved(user_email_); |
| 123 | 127 |
| 124 chromeos::UserManager::Get()->RemoveUserFromList(user_email_); | 128 chromeos::UserManager::Get()->RemoveUserFromList(user_email_); |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 | 857 |
| 854 User* UserManager::CreateUser(const std::string& email) const { | 858 User* UserManager::CreateUser(const std::string& email) const { |
| 855 User* user = new User(email); | 859 User* user = new User(email); |
| 856 user->set_oauth_token_status(GetUserOAuthStatus(email)); | 860 user->set_oauth_token_status(GetUserOAuthStatus(email)); |
| 857 // Used to determine whether user's display name is unique. | 861 // Used to determine whether user's display name is unique. |
| 858 ++display_name_count_[user->GetDisplayName()]; | 862 ++display_name_count_[user->GetDisplayName()]; |
| 859 return user; | 863 return user; |
| 860 } | 864 } |
| 861 | 865 |
| 862 } // namespace chromeos | 866 } // namespace chromeos |
| OLD | NEW |