| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/chromeos/login/utils.h" | |
| 6 | |
| 7 #include "base/command_line.h" | |
| 8 #include "base/file_path.h" | |
| 9 #include "base/path_service.h" | |
| 10 #include "chrome/browser/browser_init.h" | |
| 11 #include "chrome/browser/browser_process.h" | |
| 12 #include "chrome/browser/chromeos/cros/login_library.h" | |
| 13 #include "chrome/browser/chromeos/external_cookie_handler.h" | |
| 14 #include "chrome/browser/chromeos/login/authentication_notification_details.h" | |
| 15 #include "chrome/browser/chromeos/login/google_authenticator.h" | |
| 16 #include "chrome/browser/chromeos/login/pam_google_authenticator.h" | |
| 17 #include "chrome/browser/chromeos/login/user_manager.h" | |
| 18 #include "chrome/browser/net/url_request_context_getter.h" | |
| 19 #include "chrome/browser/profile.h" | |
| 20 #include "chrome/browser/profile_manager.h" | |
| 21 #include "chrome/common/chrome_paths.h" | |
| 22 #include "chrome/common/chrome_switches.h" | |
| 23 #include "chrome/common/notification_service.h" | |
| 24 #include "googleurl/src/gurl.h" | |
| 25 #include "net/base/cookie_store.h" | |
| 26 #include "net/url_request/url_request_context.h" | |
| 27 #include "views/widget/widget_gtk.h" | |
| 28 | |
| 29 namespace chromeos { | |
| 30 | |
| 31 namespace login_utils { | |
| 32 | |
| 33 void CompleteLogin(const std::string& username, | |
| 34 std::vector<std::string> cookies) { | |
| 35 LOG(INFO) << "LoginManagerView: OnLoginSuccess()"; | |
| 36 | |
| 37 if (CrosLibrary::Get()->EnsureLoaded()) | |
| 38 CrosLibrary::Get()->GetLoginLibrary()->StartSession(username, ""); | |
| 39 | |
| 40 UserManager::Get()->UserLoggedIn(username); | |
| 41 | |
| 42 // Send notification of success | |
| 43 AuthenticationNotificationDetails details(true); | |
| 44 NotificationService::current()->Notify( | |
| 45 NotificationType::LOGIN_AUTHENTICATION, | |
| 46 NotificationService::AllSources(), | |
| 47 Details<AuthenticationNotificationDetails>(&details)); | |
| 48 | |
| 49 // Now launch the initial browser window. | |
| 50 BrowserInit browser_init; | |
| 51 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 52 FilePath user_data_dir; | |
| 53 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); | |
| 54 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 55 // The default profile will have been changed because the ProfileManager | |
| 56 // will process the notification that the UserManager sends out. | |
| 57 Profile* profile = profile_manager->GetDefaultProfile(user_data_dir); | |
| 58 int return_code; | |
| 59 | |
| 60 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kInChromeAuth)) { | |
| 61 ExternalCookieHandler::GetCookies(command_line, profile); | |
| 62 } else { | |
| 63 GURL url(ExternalCookieHandler::kGoogleAccountsUrl); | |
| 64 net::CookieOptions options; | |
| 65 options.set_include_httponly(); | |
| 66 profile->GetRequestContext()->GetCookieStore()->SetCookiesWithOptions( | |
| 67 url, cookies, options); | |
| 68 } | |
| 69 browser_init.LaunchBrowser(command_line, profile, std::wstring(), true, | |
| 70 &return_code); | |
| 71 } | |
| 72 | |
| 73 Authenticator* CreateAuthenticator(LoginStatusConsumer* consumer) { | |
| 74 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInChromeAuth)) | |
| 75 return new GoogleAuthenticator(consumer); | |
| 76 return new PamGoogleAuthenticator(consumer); | |
| 77 } | |
| 78 | |
| 79 } // namespace login_utils | |
| 80 | |
| 81 } // namespace chromeos | |
| OLD | NEW |