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

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

Issue 2498003: Revert r48735 "Added user image screen for new user login (or old user logging in through" (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: removed grd files from cl Created 10 years, 6 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/lock.h" 9 #include "base/lock.h"
10 #include "base/nss_util.h" 10 #include "base/nss_util.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 const std::string& credentials); 81 const std::string& credentials);
82 82
83 // Invoked after the tmpfs is successfully mounted. 83 // Invoked after the tmpfs is successfully mounted.
84 // Launches a browser in the off the record (incognito) mode. 84 // Launches a browser in the off the record (incognito) mode.
85 virtual void CompleteOffTheRecordLogin(); 85 virtual void CompleteOffTheRecordLogin();
86 86
87 // Creates and returns the authenticator to use. The caller owns the returned 87 // Creates and returns the authenticator to use. The caller owns the returned
88 // Authenticator and must delete it when done. 88 // Authenticator and must delete it when done.
89 virtual Authenticator* CreateAuthenticator(LoginStatusConsumer* consumer); 89 virtual Authenticator* CreateAuthenticator(LoginStatusConsumer* consumer);
90 90
91 // Used to postpone browser launch via DoBrowserLaunch() if some post
92 // login screen is to be shown.
93 virtual void EnableBrowserLaunch(bool enable);
94
95 // Returns if browser launch enabled now or not.
96 virtual bool IsBrowserLaunchEnabled() const;
97
98 // Returns auth token for 'cp' Contacts service.
99 virtual const std::string& GetAuthToken() const { return auth_token_; }
100
101 // NotificationObserver implementation. 91 // NotificationObserver implementation.
102 virtual void Observe(NotificationType type, 92 virtual void Observe(NotificationType type,
103 const NotificationSource& source, 93 const NotificationSource& source,
104 const NotificationDetails& details); 94 const NotificationDetails& details);
105 95
106 private: 96 private:
107 // Attempt to connect to the preferred network if available. 97 // Attempt to connect to the preferred network if available.
108 void ConnectToPreferredNetwork(); 98 void ConnectToPreferredNetwork();
109 99
110 NotificationRegistrar registrar_; 100 NotificationRegistrar registrar_;
111 bool wifi_connecting_; 101 bool wifi_connecting_;
112 base::Time wifi_connect_start_time_; 102 base::Time wifi_connect_start_time_;
113 103
114 // Indicates if DoBrowserLaunch will actually launch the browser or not.
115 bool browser_launch_enabled_;
116
117 // Auth token for Contacts service. Received by GoogleAuthenticator as
118 // part of ClientLogin response.
119 std::string auth_token_;
120
121 DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl); 104 DISALLOW_COPY_AND_ASSIGN(LoginUtilsImpl);
122 }; 105 };
123 106
124 class LoginUtilsWrapper { 107 class LoginUtilsWrapper {
125 public: 108 public:
126 LoginUtilsWrapper() {} 109 LoginUtilsWrapper() {}
127 110
128 LoginUtils* get() { 111 LoginUtils* get() {
129 AutoLock create(create_lock_); 112 AutoLock create(create_lock_);
130 if (!ptr_.get()) 113 if (!ptr_.get())
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 Profile* profile = profile_manager->GetDefaultProfile(user_data_dir); 168 Profile* profile = profile_manager->GetDefaultProfile(user_data_dir);
186 169
187 // Take the credentials passed in and try to exchange them for 170 // Take the credentials passed in and try to exchange them for
188 // full-fledged Google authentication cookies. This is 171 // full-fledged Google authentication cookies. This is
189 // best-effort; it's possible that we'll fail due to network 172 // best-effort; it's possible that we'll fail due to network
190 // troubles or some such. Either way, |cf| will call 173 // troubles or some such. Either way, |cf| will call
191 // DoBrowserLaunch on the UI thread when it's done, and then 174 // DoBrowserLaunch on the UI thread when it's done, and then
192 // delete itself. 175 // delete itself.
193 CookieFetcher* cf = new CookieFetcher(profile); 176 CookieFetcher* cf = new CookieFetcher(profile);
194 cf->AttemptFetch(credentials); 177 cf->AttemptFetch(credentials);
195 auth_token_ = get_auth_token(credentials); 178 std::string auth = get_auth_token(credentials);
179 if (!auth.empty())
180 new UserImageDownloader(username, auth);
196 } 181 }
197 182
198 void LoginUtilsImpl::CompleteOffTheRecordLogin() { 183 void LoginUtilsImpl::CompleteOffTheRecordLogin() {
199 LOG(INFO) << "Completing off the record login"; 184 LOG(INFO) << "Completing off the record login";
200 185
201 if (CrosLibrary::Get()->EnsureLoaded()) 186 if (CrosLibrary::Get()->EnsureLoaded())
202 CrosLibrary::Get()->GetLoginLibrary()->StartSession(kIncognitoUser, ""); 187 CrosLibrary::Get()->GetLoginLibrary()->StartSession(kIncognitoUser, "");
203 188
204 // Incognito flag is not set by default. 189 // Incognito flag is not set by default.
205 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kIncognito); 190 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kIncognito);
206 191
207 UserManager::Get()->OffTheRecordUserLoggedIn(); 192 UserManager::Get()->OffTheRecordUserLoggedIn();
208 ConnectToPreferredNetwork(); 193 ConnectToPreferredNetwork();
209 LoginUtils::DoBrowserLaunch( 194 LoginUtils::DoBrowserLaunch(
210 ProfileManager::GetDefaultProfile()->GetOffTheRecordProfile()); 195 ProfileManager::GetDefaultProfile()->GetOffTheRecordProfile());
211 } 196 }
212 197
213 Authenticator* LoginUtilsImpl::CreateAuthenticator( 198 Authenticator* LoginUtilsImpl::CreateAuthenticator(
214 LoginStatusConsumer* consumer) { 199 LoginStatusConsumer* consumer) {
215 return new GoogleAuthenticator(consumer); 200 return new GoogleAuthenticator(consumer);
216 } 201 }
217 202
218 void LoginUtilsImpl::EnableBrowserLaunch(bool enable) {
219 browser_launch_enabled_ = enable;
220 }
221
222 bool LoginUtilsImpl::IsBrowserLaunchEnabled() const {
223 return browser_launch_enabled_;
224 }
225
226 void LoginUtilsImpl::Observe(NotificationType type, 203 void LoginUtilsImpl::Observe(NotificationType type,
227 const NotificationSource& source, 204 const NotificationSource& source,
228 const NotificationDetails& details) { 205 const NotificationDetails& details) {
229 if (type == NotificationType::LOGIN_USER_CHANGED) 206 if (type == NotificationType::LOGIN_USER_CHANGED)
230 base::OpenPersistentNSSDB(); 207 base::OpenPersistentNSSDB();
231 } 208 }
232 209
233 void LoginUtilsImpl::ConnectToPreferredNetwork() { 210 void LoginUtilsImpl::ConnectToPreferredNetwork() {
234 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); 211 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
235 wifi_connecting_ = cros->ConnectToPreferredNetworkIfAvailable(); 212 wifi_connecting_ = cros->ConnectToPreferredNetworkIfAvailable();
(...skipping 11 matching lines...) Expand all
247 224
248 void LoginUtils::DoBrowserLaunch(Profile* profile) { 225 void LoginUtils::DoBrowserLaunch(Profile* profile) {
249 // If we should wait for wifi connection, post this task with a 100ms delay. 226 // If we should wait for wifi connection, post this task with a 100ms delay.
250 if (LoginUtils::Get()->ShouldWaitForWifi()) { 227 if (LoginUtils::Get()->ShouldWaitForWifi()) {
251 ChromeThread::PostDelayedTask( 228 ChromeThread::PostDelayedTask(
252 ChromeThread::UI, FROM_HERE, 229 ChromeThread::UI, FROM_HERE,
253 NewRunnableFunction(&LoginUtils::DoBrowserLaunch, profile), 100); 230 NewRunnableFunction(&LoginUtils::DoBrowserLaunch, profile), 100);
254 return; 231 return;
255 } 232 }
256 233
257 // Browser launch was disabled due to some post login screen.
258 if (!LoginUtils::Get()->IsBrowserLaunchEnabled())
259 return;
260
261 LOG(INFO) << "Launching browser..."; 234 LOG(INFO) << "Launching browser...";
262 BrowserInit browser_init; 235 BrowserInit browser_init;
263 int return_code; 236 int return_code;
264 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(), 237 browser_init.LaunchBrowser(*CommandLine::ForCurrentProcess(),
265 profile, 238 profile,
266 std::wstring(), 239 std::wstring(),
267 true, 240 true,
268 &return_code); 241 &return_code);
269 } 242 }
270 243
271 } // namespace chromeos 244 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/login_utils.h ('k') | chrome/browser/chromeos/login/mock_authenticator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698