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

Side by Side Diff: chrome/browser/chromeos/login/existing_user_controller.cc

Issue 1138143002: Pass Device ID in the oauth2/token request. Keep Device ID in local state on Chrome OS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final version. Created 5 years, 7 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/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
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
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) {
achuithb 2015/05/12 23:25:01 Maybe call this user_context, and use uc for the s
dzhioev (left Google) 2015/05/13 00:25:17 'user_context' variable is used 5-6 times in this
1127 UserContext user_context = user_context_wo_device_id;
1128 std::string known_device_id =
achuithb 2015/05/12 23:25:01 I'd suggest merging the variables known_device_id
dzhioev (left Google) 2015/05/13 00:25:17 Done.
1129 user_manager::UserManager::Get()->GetKnownUserDeviceId(
1130 user_context.GetUserID());
1131 if (known_device_id.empty()) {
1132 std::string new_device_id = base::GenerateGUID();
1133 if (ChromeUserManager::Get()->AreEphemeralUsersEnabled() &&
1134 user_context.GetUserID() != ChromeUserManager::Get()->GetOwnerEmail()) {
1135 new_device_id = kEphemeralUserDeviceIDPrefix + new_device_id;
1136 }
1137 user_context.SetDeviceId(new_device_id);
1138 } else {
1139 user_context.SetDeviceId(known_device_id);
1140 }
1141
1123 PerformPreLoginActions(user_context); 1142 PerformPreLoginActions(user_context);
1124 1143
1125 if (!time_init_.is_null()) { 1144 if (!time_init_.is_null()) {
1126 base::TimeDelta delta = base::Time::Now() - time_init_; 1145 base::TimeDelta delta = base::Time::Now() - time_init_;
1127 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta); 1146 UMA_HISTOGRAM_MEDIUM_TIMES("Login.PromptToCompleteLoginTime", delta);
1128 time_init_ = base::Time(); // Reset to null. 1147 time_init_ = base::Time(); // Reset to null.
1129 } 1148 }
1130 1149
1131 host_->OnCompleteLogin(); 1150 host_->OnCompleteLogin();
1132 1151
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 void ExistingUserController::OnTokenHandleObtained( 1273 void ExistingUserController::OnTokenHandleObtained(
1255 const user_manager::UserID& id, 1274 const user_manager::UserID& id,
1256 TokenHandleUtil::TokenHandleStatus status) { 1275 TokenHandleUtil::TokenHandleStatus status) {
1257 if (status != TokenHandleUtil::VALID) { 1276 if (status != TokenHandleUtil::VALID) {
1258 LOG(ERROR) << "OAuth2 token handle fetch failed."; 1277 LOG(ERROR) << "OAuth2 token handle fetch failed.";
1259 return; 1278 return;
1260 } 1279 }
1261 } 1280 }
1262 1281
1263 } // namespace chromeos 1282 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698