| OLD | NEW |
| 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/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/lock.h" | 10 #include "base/lock.h" |
| 11 #include "base/nss_util.h" | 11 #include "base/nss_util.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "base/singleton.h" | 14 #include "base/singleton.h" |
| 15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "chrome/browser/browser_init.h" | 16 #include "chrome/browser/browser_init.h" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/chrome_thread.h" |
| 18 #include "chrome/browser/chromeos/cros/login_library.h" | 19 #include "chrome/browser/chromeos/cros/login_library.h" |
| 19 #include "chrome/browser/chromeos/cros/network_library.h" | 20 #include "chrome/browser/chromeos/cros/network_library.h" |
| 20 #include "chrome/browser/chromeos/external_cookie_handler.h" | 21 #include "chrome/browser/chromeos/external_cookie_handler.h" |
| 21 #include "chrome/browser/chromeos/login/cookie_fetcher.h" | 22 #include "chrome/browser/chromeos/login/cookie_fetcher.h" |
| 22 #include "chrome/browser/chromeos/login/google_authenticator.h" | 23 #include "chrome/browser/chromeos/login/google_authenticator.h" |
| 23 #include "chrome/browser/chromeos/login/user_image_downloader.h" | 24 #include "chrome/browser/chromeos/login/user_image_downloader.h" |
| 24 #include "chrome/browser/chromeos/login/user_manager.h" | 25 #include "chrome/browser/chromeos/login/user_manager.h" |
| 25 #include "chrome/browser/chrome_thread.h" | 26 #include "chrome/browser/net/gaia/token_service.h" |
| 26 #include "chrome/browser/profile.h" | 27 #include "chrome/browser/profile.h" |
| 27 #include "chrome/browser/profile_manager.h" | 28 #include "chrome/browser/profile_manager.h" |
| 28 #include "chrome/common/logging_chrome.h" | 29 #include "chrome/common/logging_chrome.h" |
| 29 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
| 30 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
| 31 #include "chrome/common/net/url_request_context_getter.h" | 32 #include "chrome/common/net/url_request_context_getter.h" |
| 32 #include "chrome/common/notification_observer.h" | 33 #include "chrome/common/notification_observer.h" |
| 33 #include "chrome/common/notification_registrar.h" | 34 #include "chrome/common/notification_registrar.h" |
| 34 #include "chrome/common/notification_service.h" | 35 #include "chrome/common/notification_service.h" |
| 35 #include "chrome/common/notification_type.h" | 36 #include "chrome/common/notification_type.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 191 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 191 // The default profile will have been changed because the ProfileManager | 192 // The default profile will have been changed because the ProfileManager |
| 192 // will process the notification that the UserManager sends out. | 193 // will process the notification that the UserManager sends out. |
| 193 Profile* profile = profile_manager->GetDefaultProfile(user_data_dir); | 194 Profile* profile = profile_manager->GetDefaultProfile(user_data_dir); |
| 194 | 195 |
| 195 logging::RedirectChromeLogging( | 196 logging::RedirectChromeLogging( |
| 196 user_data_dir.Append(profile_manager->GetCurrentProfileDir()), | 197 user_data_dir.Append(profile_manager->GetCurrentProfileDir()), |
| 197 *(CommandLine::ForCurrentProcess()), | 198 *(CommandLine::ForCurrentProcess()), |
| 198 logging::DELETE_OLD_LOG_FILE); | 199 logging::DELETE_OLD_LOG_FILE); |
| 199 | 200 |
| 201 // Supply credentials for sync and others to use |
| 202 profile->GetTokenService()->SetClientLoginResult(credentials); |
| 200 | 203 |
| 201 // Take the credentials passed in and try to exchange them for | 204 // Take the credentials passed in and try to exchange them for |
| 202 // full-fledged Google authentication cookies. This is | 205 // full-fledged Google authentication cookies. This is |
| 203 // best-effort; it's possible that we'll fail due to network | 206 // best-effort; it's possible that we'll fail due to network |
| 204 // troubles or some such. Either way, |cf| will call | 207 // troubles or some such. Either way, |cf| will call |
| 205 // DoBrowserLaunch on the UI thread when it's done, and then | 208 // DoBrowserLaunch on the UI thread when it's done, and then |
| 206 // delete itself. | 209 // delete itself. |
| 207 CookieFetcher* cf = new CookieFetcher(profile); | 210 CookieFetcher* cf = new CookieFetcher(profile); |
| 208 cf->AttemptFetch(credentials.data); | 211 cf->AttemptFetch(credentials.data); |
| 209 auth_token_ = credentials.token; | 212 auth_token_ = credentials.token; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 if (start == std::string::npos) | 298 if (start == std::string::npos) |
| 296 return std::string(); | 299 return std::string(); |
| 297 start += param_prefix.size(); | 300 start += param_prefix.size(); |
| 298 size_t end = credentials.find(param_suffix, start); | 301 size_t end = credentials.find(param_suffix, start); |
| 299 if (end == std::string::npos) | 302 if (end == std::string::npos) |
| 300 return std::string(); | 303 return std::string(); |
| 301 return credentials.substr(start, end - start); | 304 return credentials.substr(start, end - start); |
| 302 } | 305 } |
| 303 | 306 |
| 304 } // namespace chromeos | 307 } // namespace chromeos |
| OLD | NEW |