1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_UTILS_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_UTILS_H_ 7 #pragma once 8 9 #include <string> 10 11 #include "chrome/common/net/gaia/gaia_auth_consumer.h" 12 13 class CommandLine; 14 class GURL; 15 class Profile; 16 class PrefService; 17 18 namespace { 19 class BrowserGuestSessionNavigatorTest; 20 } // namespace 21 22 namespace chromeos { 23 24 class Authenticator; 25 class BackgroundView; 26 class LoginStatusConsumer; 27 28 class LoginUtils { 29 public: 30 class Delegate { 31 public: 32 // Called after profile is loaded and prepared for the session. 33 virtual void OnProfilePrepared(Profile* profile) = 0; 34 }; 35 36 // Get LoginUtils singleton object. If it was not set before, new default 37 // instance will be created. 38 static LoginUtils* Get(); 39 40 // Set LoginUtils singleton object for test purpose only! 41 static void Set(LoginUtils* ptr); 42 43 // Thin wrapper around BrowserInit::LaunchBrowser(). Meant to be used in a 44 // Task posted to the UI thread. 45 static void DoBrowserLaunch(Profile* profile); 46 47 virtual ~LoginUtils() {} 48 49 // Loads and prepares profile for the session. Fires |delegate| in the end. 50 // If |pending_requests| is true, there's a pending online auth request. 51 virtual void PrepareProfile( 52 const std::string& username, 53 const std::string& password, 54 const GaiaAuthConsumer::ClientLoginResult& credentials, 55 bool pending_requests, 56 Delegate* delegate) = 0; 57 58 // Invoked after the tmpfs is successfully mounted. 59 // Asks session manager to restart Chrome in Browse Without Sign In mode. 60 // |start_url| is url for launched browser to open. 61 virtual void CompleteOffTheRecordLogin(const GURL& start_url) = 0; 62 63 // Invoked when the user is logging in for the first time, or is logging in as 64 // a guest user. 65 virtual void SetFirstLoginPrefs(PrefService* prefs) = 0; 66 67 // Creates and returns the authenticator to use. The caller owns the returned 68 // Authenticator and must delete it when done. 69 virtual Authenticator* CreateAuthenticator(LoginStatusConsumer* consumer) = 0; 70 71 // Prewarms the authentication network connection. 72 virtual void PrewarmAuthentication() = 0; 73 74 // Given the credentials try to exchange them for 75 // full-fledged Google authentication cookies. 76 virtual void FetchCookies( 77 Profile* profile, 78 const GaiaAuthConsumer::ClientLoginResult& credentials) = 0; 79 80 // Supply credentials for sync and others to use. 81 virtual void FetchTokens( 82 Profile* profile, 83 const GaiaAuthConsumer::ClientLoginResult& credentials) = 0; 84 85 // Sets the current background view. 86 virtual void SetBackgroundView(BackgroundView* background_view) = 0; 87 88 // Gets the current background view. 89 virtual BackgroundView* GetBackgroundView() = 0; 90 91 protected: 92 friend class ::BrowserGuestSessionNavigatorTest; 93 94 // Returns command line string to be used for the OTR process. Also modifies 95 // given command line. 96 virtual std::string GetOffTheRecordCommandLine( 97 const GURL& start_url, 98 const CommandLine& base_command_line, 99 CommandLine* command_line) = 0; 100 }; 101 102 } // namespace chromeos 103 104 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_UTILS_H_ 105