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/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.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/login_performer.h" | 14 #include "chrome/browser/chromeos/login/login_performer.h" |
15 #include "chrome/browser/chromeos/login/login_utils.h" | 15 #include "chrome/browser/chromeos/login/login_utils.h" |
16 | 16 |
17 class Profile; | 17 class Profile; |
18 | 18 |
19 namespace chromeos { | 19 namespace chromeos { |
20 | 20 |
21 class KioskAppManager; | |
22 | |
23 // KioskProfileLoader loads a special profile for a given app. It first | 21 // KioskProfileLoader loads a special profile for a given app. It first |
24 // attempts to login for the app's generated user id. If the login is | 22 // attempts to login for the app's generated user id. If the login is |
25 // successful, it prepares app profile then calls the delegate. | 23 // successful, it prepares app profile then calls the delegate. |
26 class KioskProfileLoader : public LoginPerformer::Delegate, | 24 class KioskProfileLoader : public LoginPerformer::Delegate, |
27 public LoginUtils::Delegate { | 25 public LoginUtils::Delegate { |
28 public: | 26 public: |
29 class Delegate { | 27 class Delegate { |
30 public: | 28 public: |
31 virtual void OnProfileLoaded(Profile* profile) = 0; | 29 virtual void OnProfileLoaded(Profile* profile) = 0; |
32 virtual void OnProfileLoadFailed(KioskAppLaunchError::Error error) = 0; | 30 virtual void OnProfileLoadFailed(KioskAppLaunchError::Error error) = 0; |
33 | 31 |
34 protected: | 32 protected: |
35 virtual ~Delegate() {} | 33 virtual ~Delegate() {} |
36 }; | 34 }; |
37 | 35 |
38 KioskProfileLoader(const std::string& app_user_id, | 36 KioskProfileLoader(const std::string& app_user_id, |
39 bool force_ephemeral, | 37 bool use_guest_mount, |
40 Delegate* delegate); | 38 Delegate* delegate); |
41 | 39 |
42 virtual ~KioskProfileLoader(); | 40 virtual ~KioskProfileLoader(); |
43 | 41 |
44 // Starts profile load. Calls delegate on success or failure. | 42 // Starts profile load. Calls delegate on success or failure. |
45 void Start(); | 43 void Start(); |
46 | 44 |
47 private: | 45 private: |
48 class CryptohomedChecker; | 46 class CryptohomedChecker; |
49 | 47 |
50 void LoginAsKioskAccount(); | 48 void LoginAsKioskAccount(); |
51 void ReportLaunchResult(KioskAppLaunchError::Error error); | 49 void ReportLaunchResult(KioskAppLaunchError::Error error); |
52 | 50 |
53 // LoginPerformer::Delegate overrides | 51 // LoginPerformer::Delegate overrides |
54 virtual void OnLoginSuccess(const UserContext& user_context) OVERRIDE; | 52 virtual void OnLoginSuccess(const UserContext& user_context) OVERRIDE; |
55 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE; | 53 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE; |
56 virtual void WhiteListCheckFailed(const std::string& email) OVERRIDE; | 54 virtual void WhiteListCheckFailed(const std::string& email) OVERRIDE; |
57 virtual void PolicyLoadFailed() OVERRIDE; | 55 virtual void PolicyLoadFailed() OVERRIDE; |
58 virtual void OnOnlineChecked( | 56 virtual void OnOnlineChecked( |
59 const std::string& email, bool success) OVERRIDE; | 57 const std::string& email, bool success) OVERRIDE; |
60 | 58 |
61 // LoginUtils::Delegate implementation: | 59 // LoginUtils::Delegate implementation: |
62 virtual void OnProfilePrepared(Profile* profile) OVERRIDE; | 60 virtual void OnProfilePrepared(Profile* profile) OVERRIDE; |
63 | 61 |
64 std::string user_id_; | 62 std::string user_id_; |
65 bool force_ephemeral_; | 63 bool use_guest_mount_; |
66 Delegate* delegate_; | 64 Delegate* delegate_; |
67 scoped_ptr<CryptohomedChecker> cryptohomed_checker_; | 65 scoped_ptr<CryptohomedChecker> cryptohomed_checker_; |
68 scoped_ptr<LoginPerformer> login_performer_; | 66 scoped_ptr<LoginPerformer> login_performer_; |
69 | 67 |
70 DISALLOW_COPY_AND_ASSIGN(KioskProfileLoader); | 68 DISALLOW_COPY_AND_ASSIGN(KioskProfileLoader); |
71 }; | 69 }; |
72 | 70 |
73 } // namespace chromeos | 71 } // namespace chromeos |
74 | 72 |
75 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_PROFILE_LOADER_H_ | 73 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_PROFILE_LOADER_H_ |
OLD | NEW |