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

Side by Side Diff: chrome/browser/chromeos/login/managed/locally_managed_user_login_flow.cc

Issue 12929026: Load sync token upon login (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/login/managed/locally_managed_user_login_flow. h"
6
7 #include "base/file_util.h"
8 #include "base/files/file_path.h"
9 #include "base/logging.h"
10 #include "base/prefs/pref_registry_simple.h"
11 #include "base/prefs/pref_service.h"
12 #include "base/threading/sequenced_worker_pool.h"
13 #include "base/values.h"
14 #include "chrome/browser/chromeos/login/base_login_display_host.h"
15 #include "chrome/browser/chromeos/login/login_utils.h"
16 #include "chrome/browser/chromeos/login/managed/locally_managed_user_creation_sc reen.h"
17 #include "chrome/browser/chromeos/login/wizard_controller.h"
18 #include "content/public/browser/browser_thread.h"
19
20 using content::BrowserThread;
21
22 namespace chromeos {
23
24 // namespace {
25 //
26 // A pref for the sync token.
27 // const char kSyncServiceAuthorizationToken[] =
28 // "ManagedUserSyncServiceAuthorizationToken";
29 //
30 // } // namespace
31 //
32 // // static
33 // void LocallyManagedUserLoginFlow::RegisterPrefs(
34 // PrefRegistrySimple* registry) {
35 // registry->RegisterStringPref(
36 // kSyncServiceAuthorizationToken, "");
37 // }
38
39 LocallyManagedUserLoginFlow::LocallyManagedUserLoginFlow(
40 const std::string& user_id)
41 : ExtendedUserFlow(user_id),
42 data_loaded_(false),
43 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
44 }
45
46 LocallyManagedUserLoginFlow::~LocallyManagedUserLoginFlow() {}
47
48 bool LocallyManagedUserLoginFlow::ShouldLaunchBrowser() {
49 return data_loaded_;
50 }
51
52 bool LocallyManagedUserLoginFlow::ShouldSkipPostLoginScreens() {
53 return false;
54 }
55
56 bool LocallyManagedUserLoginFlow::HandleLoginFailure(
57 const LoginFailure& failure,
58 LoginDisplayHost* host) {
59 return false;
60 }
61
62 bool LocallyManagedUserLoginFlow::HandlePasswordChangeDetected(
63 LoginDisplayHost* host) {
64 return false;
65 }
66
67 void LocallyManagedUserLoginFlow::LoadSyncSetupData() {
68 std::string token;
69 base::FilePath token_file = file_util::GetHomeDir().Append("token");
70 file_util::ReadFileToString(token_file, &token);
71 BrowserThread::PostTask(
72 BrowserThread::UI,
73 FROM_HERE,
74 base::Bind(&LocallyManagedUserLoginFlow::OnSyncSetupDataLoaded,
75 weak_factory_.GetWeakPtr(),
76 token));
77 }
78
79 void LocallyManagedUserLoginFlow::OnSyncSetupDataLoaded(
80 const std::string& token) {
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
82
83 // PrefService* prefs = profile_->GetPrefs();
84 // prefs->SetString(kSyncServiceAuthorizationToken,
85 // token);
86 ConfigureSync(token);
87 }
88
89 void LocallyManagedUserLoginFlow::ConfigureSync(const std::string& token) {
90 data_loaded_ = true;
91 // TODO(antrim): Propagate token when we know API.
92
93 LoginUtils::Get()->DoBrowserLaunch(profile_, host_);
94 profile_ = NULL;
95 host_ = NULL;
96 UnregisterFlowSoon();
97 }
98
99 void LocallyManagedUserLoginFlow::LaunchExtraSteps(
100 Profile* profile,
101 LoginDisplayHost* host) {
102 profile_ = profile;
103 host_ = host;
104 // PrefService* prefs = profile->GetPrefs();
105 const std::string token;
106 // = prefs->GetString(kSyncServiceAuthorizationToken);
107 if (token.empty()) {
108 BrowserThread::GetBlockingPool()->PostTask(
109 FROM_HERE,
110 base::Bind(&LocallyManagedUserLoginFlow::LoadSyncSetupData,
111 weak_factory_.GetWeakPtr()));
112 } else {
113 ConfigureSync(token);
114 }
115 }
116
117 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/managed/locally_managed_user_login_flow.h ('k') | chrome/browser/chromeos/login/user_flow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698