| OLD | NEW |
| 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/login/existing_user_controller.h" | 5 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/guid.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 16 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 17 #include "base/prefs/pref_service.h" | 18 #include "base/prefs/pref_service.h" |
| 18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/values.h" | 21 #include "base/values.h" |
| 21 #include "base/version.h" | 22 #include "base/version.h" |
| 22 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 #include "ui/views/widget/widget.h" | 83 #include "ui/views/widget/widget.h" |
| 83 | 84 |
| 84 namespace chromeos { | 85 namespace chromeos { |
| 85 | 86 |
| 86 namespace { | 87 namespace { |
| 87 | 88 |
| 88 // URL for account creation. | 89 // URL for account creation. |
| 89 const char kCreateAccountURL[] = | 90 const char kCreateAccountURL[] = |
| 90 "https://accounts.google.com/NewAccount?service=mail"; | 91 "https://accounts.google.com/NewAccount?service=mail"; |
| 91 | 92 |
| 93 const char kEphemeralUserDeviceIDPrefix[] = "t_"; |
| 94 |
| 92 // Delay for transferring the auth cache to the system profile. | 95 // Delay for transferring the auth cache to the system profile. |
| 93 const long int kAuthCacheTransferDelayMs = 2000; | 96 const long int kAuthCacheTransferDelayMs = 2000; |
| 94 | 97 |
| 95 // Delay for restarting the ui if safe-mode login has failed. | 98 // Delay for restarting the ui if safe-mode login has failed. |
| 96 const long int kSafeModeRestartUiDelayMs = 30000; | 99 const long int kSafeModeRestartUiDelayMs = 30000; |
| 97 | 100 |
| 98 // Makes a call to the policy subsystem to reload the policy when we detect | 101 // Makes a call to the policy subsystem to reload the policy when we detect |
| 99 // authentication change. | 102 // authentication change. |
| 100 void RefreshPoliciesOnUIThread() { | 103 void RefreshPoliciesOnUIThread() { |
| 101 if (g_browser_process->policy_service()) | 104 if (g_browser_process->policy_service()) |
| (...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 | 1115 |
| 1113 // Re-enable clicking on other windows and the status area. Do not start the | 1116 // Re-enable clicking on other windows and the status area. Do not start the |
| 1114 // auto-login timer though. On a disabled device, no auto-login can succeed. | 1117 // auto-login timer though. On a disabled device, no auto-login can succeed. |
| 1115 login_display_->SetUIEnabled(true); | 1118 login_display_->SetUIEnabled(true); |
| 1116 return; | 1119 return; |
| 1117 } | 1120 } |
| 1118 | 1121 |
| 1119 continuation.Run(); | 1122 continuation.Run(); |
| 1120 } | 1123 } |
| 1121 | 1124 |
| 1122 void ExistingUserController::DoCompleteLogin(const UserContext& user_context) { | 1125 void ExistingUserController::DoCompleteLogin( |
| 1126 const UserContext& user_context_wo_device_id) { |
| 1127 UserContext user_context = user_context_wo_device_id; |
| 1128 std::string device_id = |
| 1129 user_manager::UserManager::Get()->GetKnownUserDeviceId( |
| 1130 user_context.GetUserID()); |
| 1131 if (device_id.empty()) { |
| 1132 device_id = base::GenerateGUID(); |
| 1133 if (ChromeUserManager::Get()->AreEphemeralUsersEnabled() && |
| 1134 user_context.GetUserID() != ChromeUserManager::Get()->GetOwnerEmail()) { |
| 1135 device_id = kEphemeralUserDeviceIDPrefix + device_id; |
| 1136 } |
| 1137 } |
| 1138 user_context.SetDeviceId(device_id); |
| 1139 |
| 1123 PerformPreLoginActions(user_context); | 1140 PerformPreLoginActions(user_context); |
| 1124 | 1141 |
| 1125 if (!time_init_.is_null()) { | 1142 if (!time_init_.is_null()) { |
| 1126 base::TimeDelta delta = base::Time::Now() - time_init_; | 1143 base::TimeDelta delta = base::Time::Now() - time_init_; |
| 1127 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); | 1144 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); |
| 1128 time_init_ = base::Time(); // Reset to null. | 1145 time_init_ = base::Time(); // Reset to null. |
| 1129 } | 1146 } |
| 1130 | 1147 |
| 1131 host_->OnCompleteLogin(); | 1148 host_->OnCompleteLogin(); |
| 1132 | 1149 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1254 void ExistingUserController::OnTokenHandleObtained( | 1271 void ExistingUserController::OnTokenHandleObtained( |
| 1255 const user_manager::UserID& id, | 1272 const user_manager::UserID& id, |
| 1256 TokenHandleUtil::TokenHandleStatus status) { | 1273 TokenHandleUtil::TokenHandleStatus status) { |
| 1257 if (status != TokenHandleUtil::VALID) { | 1274 if (status != TokenHandleUtil::VALID) { |
| 1258 LOG(ERROR) << "OAuth2 token handle fetch failed."; | 1275 LOG(ERROR) << "OAuth2 token handle fetch failed."; |
| 1259 return; | 1276 return; |
| 1260 } | 1277 } |
| 1261 } | 1278 } |
| 1262 | 1279 |
| 1263 } // namespace chromeos | 1280 } // namespace chromeos |
| OLD | NEW |