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_login_flow. h" | 5 #include "chrome/browser/chromeos/login/managed/supervised_user_login_flow.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/threading/sequenced_worker_pool.h" | 12 #include "base/threading/sequenced_worker_pool.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 14 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
15 #include "chrome/browser/chromeos/login/login_utils.h" | 15 #include "chrome/browser/chromeos/login/login_utils.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/managed/locally_managed_user_creation_sc reen.h" | 17 #include "chrome/browser/chromeos/login/managed/locally_managed_user_creation_sc reen.h" |
18 #include "chrome/browser/chromeos/login/supervised_user_manager.h" | |
Nikita (slow)
2013/12/09 16:42:16
nit: not used.
Denis Kuznetsov (DE-MUC)
2013/12/12 19:45:24
Done.
| |
19 #include "chrome/browser/chromeos/login/user_manager.h" | |
18 #include "chrome/browser/chromeos/login/wizard_controller.h" | 20 #include "chrome/browser/chromeos/login/wizard_controller.h" |
19 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 21 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
20 #include "chrome/browser/managed_mode/managed_user_service.h" | 22 #include "chrome/browser/managed_mode/managed_user_service.h" |
21 #include "chrome/browser/managed_mode/managed_user_service_factory.h" | 23 #include "chrome/browser/managed_mode/managed_user_service_factory.h" |
22 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
23 | 25 |
24 using content::BrowserThread; | 26 using content::BrowserThread; |
25 | 27 |
26 namespace chromeos { | 28 namespace chromeos { |
27 | 29 |
28 namespace { | 30 namespace { |
29 | 31 |
30 std::string LoadSyncToken(base::FilePath profile_dir) { | 32 std::string LoadSyncToken(base::FilePath profile_dir) { |
31 std::string token; | 33 std::string token; |
32 base::FilePath token_file = | 34 base::FilePath token_file = |
33 profile_dir.Append(kManagedUserTokenFilename); | 35 profile_dir.Append(kManagedUserTokenFilename); |
34 LOG(INFO) << "Loading" << token_file.value(); | 36 VLOG(1) << "Loading" << token_file.value(); |
35 if (!base::ReadFileToString(token_file, &token)) { | 37 if (!base::ReadFileToString(token_file, &token)) { |
36 return std::string(); | 38 return std::string(); |
37 } | 39 } |
38 return token; | 40 return token; |
39 } | 41 } |
40 | 42 |
41 } // namespace | 43 } // namespace |
42 | 44 |
43 LocallyManagedUserLoginFlow::LocallyManagedUserLoginFlow( | 45 SupervisedUserLoginFlow::SupervisedUserLoginFlow( |
44 const std::string& user_id) | 46 const std::string& user_id) |
45 : ExtendedUserFlow(user_id), | 47 : ExtendedUserFlow(user_id), |
46 data_loaded_(false), | 48 data_loaded_(false), |
47 weak_factory_(this) { | 49 weak_factory_(this) { |
48 } | 50 } |
49 | 51 |
50 LocallyManagedUserLoginFlow::~LocallyManagedUserLoginFlow() {} | 52 SupervisedUserLoginFlow::~SupervisedUserLoginFlow() {} |
51 | 53 |
52 bool LocallyManagedUserLoginFlow::ShouldLaunchBrowser() { | 54 bool SupervisedUserLoginFlow::ShouldLaunchBrowser() { |
53 return data_loaded_; | 55 return data_loaded_; |
54 } | 56 } |
55 | 57 |
56 bool LocallyManagedUserLoginFlow::ShouldSkipPostLoginScreens() { | 58 bool SupervisedUserLoginFlow::ShouldSkipPostLoginScreens() { |
57 return true; | 59 return true; |
58 } | 60 } |
59 | 61 |
60 bool LocallyManagedUserLoginFlow::HandleLoginFailure( | 62 bool SupervisedUserLoginFlow::HandleLoginFailure( |
61 const LoginFailure& failure) { | 63 const LoginFailure& failure) { |
62 return false; | 64 return false; |
63 } | 65 } |
64 | 66 |
65 bool LocallyManagedUserLoginFlow::HandlePasswordChangeDetected() { | 67 bool SupervisedUserLoginFlow::HandlePasswordChangeDetected() { |
66 return false; | 68 return false; |
67 } | 69 } |
68 | 70 |
69 void LocallyManagedUserLoginFlow::HandleOAuthTokenStatusChange( | 71 void SupervisedUserLoginFlow::HandleOAuthTokenStatusChange( |
70 User::OAuthTokenStatus status) { | 72 User::OAuthTokenStatus status) { |
71 } | 73 } |
72 | 74 |
73 void LocallyManagedUserLoginFlow::OnSyncSetupDataLoaded( | 75 void SupervisedUserLoginFlow::OnSyncSetupDataLoaded( |
74 const std::string& token) { | 76 const std::string& token) { |
75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 77 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
76 ConfigureSync(token); | 78 ConfigureSync(token); |
77 } | 79 } |
78 | 80 |
79 void LocallyManagedUserLoginFlow::ConfigureSync(const std::string& token) { | 81 void SupervisedUserLoginFlow::ConfigureSync(const std::string& token) { |
80 data_loaded_ = true; | 82 data_loaded_ = true; |
81 // TODO(antrim): add error handling (no token loaded). | 83 // TODO(antrim): add error handling (no token loaded). |
82 // See also: http://crbug.com/312751 | 84 // See also: http://crbug.com/312751 |
83 if (!token.empty()) | 85 if (!token.empty()) |
84 ManagedUserServiceFactory::GetForProfile(profile_)->InitSync(token); | 86 ManagedUserServiceFactory::GetForProfile(profile_)->InitSync(token); |
85 | 87 |
86 LoginUtils::Get()->DoBrowserLaunch(profile_, host()); | 88 LoginUtils::Get()->DoBrowserLaunch(profile_, host()); |
87 profile_ = NULL; | 89 profile_ = NULL; |
88 UnregisterFlowSoon(); | 90 UnregisterFlowSoon(); |
89 } | 91 } |
90 | 92 |
91 void LocallyManagedUserLoginFlow::LaunchExtraSteps( | 93 void SupervisedUserLoginFlow::LaunchExtraSteps( |
92 Profile* profile) { | 94 Profile* profile) { |
93 profile_ = profile; | 95 profile_ = profile; |
94 base::FilePath profile_dir = ProfileHelper::GetProfilePathByUserIdHash( | 96 base::FilePath profile_dir = ProfileHelper::GetProfilePathByUserIdHash( |
95 UserManager::Get()->GetUserByProfile(profile)->username_hash()); | 97 UserManager::Get()->GetUserByProfile(profile)->username_hash()); |
96 PostTaskAndReplyWithResult( | 98 PostTaskAndReplyWithResult( |
97 content::BrowserThread::GetBlockingPool(), | 99 content::BrowserThread::GetBlockingPool(), |
98 FROM_HERE, | 100 FROM_HERE, |
99 base::Bind(&LoadSyncToken, profile_dir), | 101 base::Bind(&LoadSyncToken, profile_dir), |
100 base::Bind( | 102 base::Bind( |
101 &LocallyManagedUserLoginFlow::OnSyncSetupDataLoaded, | 103 &SupervisedUserLoginFlow::OnSyncSetupDataLoaded, |
102 weak_factory_.GetWeakPtr())); | 104 weak_factory_.GetWeakPtr())); |
103 } | 105 } |
104 | 106 |
105 } // namespace chromeos | 107 } // namespace chromeos |
OLD | NEW |