OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_UTILS_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_UTILS_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/callback_forward.h" | |
11 #include "base/memory/ref_counted.h" | |
12 | |
13 class PrefService; | |
14 class Profile; | |
15 | |
16 namespace base { | |
17 class CommandLine; | |
18 } | |
19 | |
20 namespace chromeos { | |
21 | |
22 class Authenticator; | |
23 class LoginDisplayHost; | |
24 class AuthStatusConsumer; | |
25 class UserContext; | |
26 | |
27 class LoginUtils { | |
28 public: | |
29 class Delegate { | |
30 public: | |
31 // Called after profile is loaded and prepared for the session. | |
32 // |browser_launched| will be true is browser has been launched, otherwise | |
33 // it will return false and client is responsible on launching browser. | |
34 virtual void OnProfilePrepared(Profile* profile, | |
35 bool browser_launched) = 0; | |
36 | |
37 protected: | |
38 virtual ~Delegate() {} | |
39 }; | |
40 | |
41 // Get LoginUtils singleton object. If it was not set before, new default | |
42 // instance will be created. | |
43 static LoginUtils* Get(); | |
44 | |
45 // Set LoginUtils singleton object for test purpose only! | |
46 static void Set(LoginUtils* ptr); | |
47 | |
48 // Checks if the given username is whitelisted and allowed to sign-in to | |
49 // this device. |wildcard_match| may be NULL. If it's present, it'll be set to | |
50 // true if the whitelist check was satisfied via a wildcard. | |
51 static bool IsWhitelisted(const std::string& username, bool* wildcard_match); | |
52 | |
53 virtual ~LoginUtils() {} | |
54 | |
55 // Thin wrapper around StartupBrowserCreator::LaunchBrowser(). Meant to be | |
56 // used in a Task posted to the UI thread. Once the browser is launched the | |
57 // login host is deleted. | |
58 virtual void DoBrowserLaunch(Profile* profile, | |
59 LoginDisplayHost* login_host) = 0; | |
60 | |
61 // Loads and prepares profile for the session. Fires |delegate| in the end. | |
62 // |user_context.username_hash| defines when user homedir is mounted. | |
63 // Also see DelegateDeleted method. | |
64 // If |has_active_session| is true than this is a case of restoring user | |
65 // session after browser crash so no need to start new session. | |
66 virtual void PrepareProfile( | |
67 const UserContext& user_context, | |
68 bool has_auth_cookies, | |
69 bool has_active_session, | |
70 Delegate* delegate) = 0; | |
71 | |
72 // Invalidates |delegate|, which was passed to PrepareProfile method call. | |
73 virtual void DelegateDeleted(Delegate* delegate) = 0; | |
74 | |
75 // Creates and returns the authenticator to use. | |
76 // Before WebUI login (Up to R14) the caller owned the returned | |
77 // Authenticator instance and had to delete it when done. | |
78 // New instance was created on each new login attempt. | |
79 // Starting with WebUI login (R15) single Authenticator instance is used for | |
80 // entire login process, even for multiple retries. Authenticator instance | |
81 // holds reference to login profile and is later used during fetching of | |
82 // OAuth tokens. | |
83 // TODO(nkostylev): Cleanup after WebUI login migration is complete. | |
84 virtual scoped_refptr<Authenticator> CreateAuthenticator( | |
85 AuthStatusConsumer* consumer) = 0; | |
86 }; | |
87 | |
88 } // namespace chromeos | |
89 | |
90 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_LOGIN_UTILS_H_ | |
OLD | NEW |