Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / chromeos / app_mode / kiosk_profile_loader.h
blob9f28103f5e1d9567de9cce9e9dc51c28c4bbe79c
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_PROFILE_LOADER_H_
6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_PROFILE_LOADER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
14 #include "chrome/browser/chromeos/login/login_performer.h"
15 #include "chrome/browser/chromeos/login/login_utils.h"
17 class Profile;
19 namespace chromeos {
21 class KioskAppManager;
23 // 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
25 // successful, it prepares app profile then calls the delegate.
26 class KioskProfileLoader : public LoginPerformer::Delegate,
27 public LoginUtils::Delegate {
28 public:
29 class Delegate {
30 public:
31 virtual void OnProfileLoaded(Profile* profile) = 0;
32 virtual void OnProfileLoadFailed(KioskAppLaunchError::Error error) = 0;
34 protected:
35 virtual ~Delegate() {}
38 KioskProfileLoader(KioskAppManager* kiosk_app_manager,
39 const std::string& app_id,
40 Delegate* delegate);
42 virtual ~KioskProfileLoader();
44 // Starts profile load. Calls delegate on success or failure.
45 void Start();
47 private:
48 class CryptohomedChecker;
50 void LoginAsKioskAccount();
51 void ReportLaunchResult(KioskAppLaunchError::Error error);
53 // LoginPerformer::Delegate overrides
54 virtual void OnLoginSuccess(const UserContext& user_context) OVERRIDE;
55 virtual void OnLoginFailure(const LoginFailure& error) OVERRIDE;
56 virtual void WhiteListCheckFailed(const std::string& email) OVERRIDE;
57 virtual void PolicyLoadFailed() OVERRIDE;
58 virtual void OnOnlineChecked(
59 const std::string& email, bool success) OVERRIDE;
61 // LoginUtils::Delegate implementation:
62 virtual void OnProfilePrepared(Profile* profile) OVERRIDE;
64 KioskAppManager* kiosk_app_manager_;
65 const std::string app_id_;
66 std::string user_id_;
67 Delegate* delegate_;
68 scoped_ptr<CryptohomedChecker> cryptohomed_checker_;
69 scoped_ptr<LoginPerformer> login_performer_;
71 DISALLOW_COPY_AND_ASSIGN(KioskProfileLoader);
74 } // namespace chromeos
76 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_PROFILE_LOADER_H_