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.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_UTILS_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_UTILS_H_
10 #include "base/memory/ref_counted.h"
15 class PrefRegistrySimple;
21 class LoginDisplayHost;
22 class LoginStatusConsumer;
29 // Called after profile is loaded and prepared for the session.
30 virtual void OnProfilePrepared(Profile* profile) = 0;
32 #if defined(ENABLE_RLZ)
33 // Called after post-profile RLZ initialization.
34 virtual void OnRlzInitialized(Profile* profile) {}
37 virtual ~Delegate() {}
40 // Registers log-in related preferences.
41 static void RegisterPrefs(PrefRegistrySimple* registry);
43 // Get LoginUtils singleton object. If it was not set before, new default
44 // instance will be created.
45 static LoginUtils* Get();
47 // Set LoginUtils singleton object for test purpose only!
48 static void Set(LoginUtils* ptr);
50 // Checks if the given username is whitelisted and allowed to sign-in to
52 static bool IsWhitelisted(const std::string& username);
54 virtual ~LoginUtils() {}
56 // Thin wrapper around StartupBrowserCreator::LaunchBrowser(). Meant to be
57 // used in a Task posted to the UI thread. Once the browser is launched the
58 // login host is deleted.
59 virtual void DoBrowserLaunch(Profile* profile,
60 LoginDisplayHost* login_host) = 0;
62 // Loads and prepares profile for the session. Fires |delegate| in the end.
63 // If |pending_requests| is true, there's a pending online auth request.
64 // If |display_email| is not empty, user's displayed email will be set to
65 // this value, shown in UI.
66 // |user_context.username_hash| defines when user homedir is mounted.
67 // Also see DelegateDeleted method.
68 // If |has_active_session| is true than this is a case of restoring user
69 // session after browser crash so no need to start new session.
70 virtual void PrepareProfile(
71 const UserContext& user_context,
72 const std::string& display_email,
74 bool has_active_session,
75 Delegate* delegate) = 0;
77 // Invalidates |delegate|, which was passed to PrepareProfile method call.
78 virtual void DelegateDeleted(Delegate* delegate) = 0;
80 // Invoked after the tmpfs is successfully mounted.
81 // Asks session manager to restart Chrome in Browse Without Sign In mode.
82 // |start_url| is url for launched browser to open.
83 virtual void CompleteOffTheRecordLogin(const GURL& start_url) = 0;
85 // Invoked when the user is logging in for the first time, or is logging in as
87 virtual void SetFirstLoginPrefs(PrefService* prefs) = 0;
89 // Creates and returns the authenticator to use.
90 // Before WebUI login (Up to R14) the caller owned the returned
91 // Authenticator instance and had to delete it when done.
92 // New instance was created on each new login attempt.
93 // Starting with WebUI login (R15) single Authenticator instance is used for
94 // entire login process, even for multiple retries. Authenticator instance
95 // holds reference to login profile and is later used during fetching of
97 // TODO(nkostylev): Cleanup after WebUI login migration is complete.
98 virtual scoped_refptr<Authenticator> CreateAuthenticator(
99 LoginStatusConsumer* consumer) = 0;
101 // Restores authentication session after crash.
102 virtual void RestoreAuthenticationSession(Profile* profile) = 0;
105 virtual void InitRlzDelayed(Profile* user_profile) = 0;
108 } // namespace chromeos
110 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_UTILS_H_