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/managed/locally_managed_user_creation_co
ntroller.h" | 5 #include "chrome/browser/chromeos/login/managed/locally_managed_user_creation_co
ntroller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/chromeos/chromeos_version.h" | |
9 #include "base/file_util.h" | 8 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
11 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/sys_info.h" |
13 #include "base/task_runner_util.h" | 13 #include "base/task_runner_util.h" |
14 #include "base/threading/sequenced_worker_pool.h" | 14 #include "base/threading/sequenced_worker_pool.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/chromeos/login/managed/locally_managed_user_constants.h
" | 16 #include "chrome/browser/chromeos/login/managed/locally_managed_user_constants.h
" |
17 #include "chrome/browser/chromeos/login/mount_manager.h" | 17 #include "chrome/browser/chromeos/login/mount_manager.h" |
18 #include "chrome/browser/chromeos/login/user.h" | 18 #include "chrome/browser/chromeos/login/user.h" |
19 #include "chrome/browser/chromeos/login/user_manager.h" | 19 #include "chrome/browser/chromeos/login/user_manager.h" |
20 #include "chrome/browser/lifetime/application_lifetime.h" | 20 #include "chrome/browser/lifetime/application_lifetime.h" |
21 #include "chrome/browser/sync/profile_sync_service.h" | 21 #include "chrome/browser/sync/profile_sync_service.h" |
22 #include "chrome/browser/sync/profile_sync_service_factory.h" | 22 #include "chrome/browser/sync/profile_sync_service_factory.h" |
23 #include "chromeos/dbus/dbus_thread_manager.h" | 23 #include "chromeos/dbus/dbus_thread_manager.h" |
24 #include "chromeos/dbus/session_manager_client.h" | 24 #include "chromeos/dbus/session_manager_client.h" |
25 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/browser/user_metrics.h" | 26 #include "content/public/browser/user_metrics.h" |
27 #include "crypto/random.h" | 27 #include "crypto/random.h" |
28 #include "google_apis/gaia/google_service_auth_error.h" | 28 #include "google_apis/gaia/google_service_auth_error.h" |
29 | 29 |
30 namespace chromeos { | 30 namespace chromeos { |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 const int kDummyAvatarIndex = -111; | 34 const int kDummyAvatarIndex = -111; |
35 const int kMasterKeySize = 32; | 35 const int kMasterKeySize = 32; |
36 const int kUserCreationTimeoutSeconds = 30; // 30 seconds. | 36 const int kUserCreationTimeoutSeconds = 30; // 30 seconds. |
37 | 37 |
38 bool StoreManagedUserFiles(const std::string& token, | 38 bool StoreManagedUserFiles(const std::string& token, |
39 const base::FilePath& base_path) { | 39 const base::FilePath& base_path) { |
40 if (!base::chromeos::IsRunningOnChromeOS()) { | 40 if (!base::SysInfo::IsRunningOnChromeOS()) { |
41 // If running on desktop, cryptohome stub does not create home directory. | 41 // If running on desktop, cryptohome stub does not create home directory. |
42 file_util::CreateDirectory(base_path); | 42 file_util::CreateDirectory(base_path); |
43 } | 43 } |
44 base::FilePath token_file = base_path.Append(kManagedUserTokenFilename); | 44 base::FilePath token_file = base_path.Append(kManagedUserTokenFilename); |
45 int bytes = file_util::WriteFile(token_file, token.c_str(), token.length()); | 45 int bytes = file_util::WriteFile(token_file, token.c_str(), token.length()); |
46 return bytes >= 0; | 46 return bytes >= 0; |
47 } | 47 } |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // Assume that new token is valid. It will be automatically invalidated if | 251 // Assume that new token is valid. It will be automatically invalidated if |
252 // sync service fails to use it. | 252 // sync service fails to use it. |
253 UserManager::Get()->SaveUserOAuthStatus(creation_context_->local_user_id, | 253 UserManager::Get()->SaveUserOAuthStatus(creation_context_->local_user_id, |
254 User::OAUTH2_TOKEN_STATUS_VALID); | 254 User::OAUTH2_TOKEN_STATUS_VALID); |
255 UserManager::Get()->CommitLocallyManagedUserCreationTransaction(); | 255 UserManager::Get()->CommitLocallyManagedUserCreationTransaction(); |
256 if (consumer_) | 256 if (consumer_) |
257 consumer_->OnCreationSuccess(); | 257 consumer_->OnCreationSuccess(); |
258 } | 258 } |
259 | 259 |
260 } // namespace chromeos | 260 } // namespace chromeos |
OLD | NEW |