OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_PROFILE_LOADER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_PROFILE_LOADER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_PROFILE_LOADER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_PROFILE_LOADER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" | 13 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" |
14 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 14 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
15 #include "chromeos/login/auth/login_performer.h" | 15 #include "chromeos/login/auth/login_performer.h" |
| 16 #include "components/signin/core/account_id/account_id.h" |
16 | 17 |
17 class Profile; | 18 class Profile; |
18 | 19 |
19 namespace chromeos { | 20 namespace chromeos { |
20 | 21 |
21 // KioskProfileLoader loads a special profile for a given app. It first | 22 // KioskProfileLoader loads a special profile for a given app. It first |
22 // attempts to login for the app's generated user id. If the login is | 23 // attempts to login for the app's generated user id. If the login is |
23 // successful, it prepares app profile then calls the delegate. | 24 // successful, it prepares app profile then calls the delegate. |
24 class KioskProfileLoader : public LoginPerformer::Delegate, | 25 class KioskProfileLoader : public LoginPerformer::Delegate, |
25 public UserSessionManagerDelegate { | 26 public UserSessionManagerDelegate { |
26 public: | 27 public: |
27 class Delegate { | 28 class Delegate { |
28 public: | 29 public: |
29 virtual void OnProfileLoaded(Profile* profile) = 0; | 30 virtual void OnProfileLoaded(Profile* profile) = 0; |
30 virtual void OnProfileLoadFailed(KioskAppLaunchError::Error error) = 0; | 31 virtual void OnProfileLoadFailed(KioskAppLaunchError::Error error) = 0; |
31 | 32 |
32 protected: | 33 protected: |
33 virtual ~Delegate() {} | 34 virtual ~Delegate() {} |
34 }; | 35 }; |
35 | 36 |
36 KioskProfileLoader(const std::string& app_user_id, | 37 KioskProfileLoader(const AccountId& app_account_id, |
37 bool use_guest_mount, | 38 bool use_guest_mount, |
38 Delegate* delegate); | 39 Delegate* delegate); |
39 | 40 |
40 ~KioskProfileLoader() override; | 41 ~KioskProfileLoader() override; |
41 | 42 |
42 // Starts profile load. Calls delegate on success or failure. | 43 // Starts profile load. Calls delegate on success or failure. |
43 void Start(); | 44 void Start(); |
44 | 45 |
45 private: | 46 private: |
46 class CryptohomedChecker; | 47 class CryptohomedChecker; |
47 | 48 |
48 void LoginAsKioskAccount(); | 49 void LoginAsKioskAccount(); |
49 void ReportLaunchResult(KioskAppLaunchError::Error error); | 50 void ReportLaunchResult(KioskAppLaunchError::Error error); |
50 | 51 |
51 // LoginPerformer::Delegate overrides: | 52 // LoginPerformer::Delegate overrides: |
52 void OnAuthSuccess(const UserContext& user_context) override; | 53 void OnAuthSuccess(const UserContext& user_context) override; |
53 void OnAuthFailure(const AuthFailure& error) override; | 54 void OnAuthFailure(const AuthFailure& error) override; |
54 void WhiteListCheckFailed(const std::string& email) override; | 55 void WhiteListCheckFailed(const std::string& email) override; |
55 void PolicyLoadFailed() override; | 56 void PolicyLoadFailed() override; |
56 void SetAuthFlowOffline(bool offline) override; | 57 void SetAuthFlowOffline(bool offline) override; |
57 | 58 |
58 // UserSessionManagerDelegate implementation: | 59 // UserSessionManagerDelegate implementation: |
59 void OnProfilePrepared(Profile* profile, bool browser_launched) override; | 60 void OnProfilePrepared(Profile* profile, bool browser_launched) override; |
60 | 61 |
61 std::string user_id_; | 62 const AccountId account_id_; |
62 bool use_guest_mount_; | 63 bool use_guest_mount_; |
63 Delegate* delegate_; | 64 Delegate* delegate_; |
64 scoped_ptr<CryptohomedChecker> cryptohomed_checker_; | 65 scoped_ptr<CryptohomedChecker> cryptohomed_checker_; |
65 scoped_ptr<LoginPerformer> login_performer_; | 66 scoped_ptr<LoginPerformer> login_performer_; |
66 | 67 |
67 DISALLOW_COPY_AND_ASSIGN(KioskProfileLoader); | 68 DISALLOW_COPY_AND_ASSIGN(KioskProfileLoader); |
68 }; | 69 }; |
69 | 70 |
70 } // namespace chromeos | 71 } // namespace chromeos |
71 | 72 |
72 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_PROFILE_LOADER_H_ | 73 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_PROFILE_LOADER_H_ |
OLD | NEW |