| 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_APP_LAUNCHER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_PROFILE_LOADER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_LAUNCHER_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 "third_party/cros_system_api/dbus/service_constants.h" | 14 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 15 | 15 |
| 16 class Profile; | 16 class Profile; |
| 17 | 17 |
| 18 namespace chromeos { | 18 namespace chromeos { |
| 19 | 19 |
| 20 class KioskAppManager; | 20 class KioskAppManager; |
| 21 | 21 |
| 22 // KioskAppLauncher launches a given app from login screen. It first attempts | 22 // KioskProfileLoader loads a special profile for a given app. It first attempts |
| 23 // to mount a cryptohome for the app. If the mount is successful, it prepares | 23 // to mount a cryptohome for the app. If the mount is successful, it prepares |
| 24 // app profile then calls StartupAppLauncher to finish the launch. If mount | 24 // app profile then calls the delegate. |
| 25 // fails, it sets relevant launch error and restart chrome to gets back to | 25 class KioskProfileLoader { |
| 26 // the login screen. Note that there should only be one launch attempt in | |
| 27 // progress. | |
| 28 class KioskAppLauncher { | |
| 29 public: | 26 public: |
| 30 KioskAppLauncher(KioskAppManager* kiosk_app_manager, | 27 class Delegate { |
| 31 const std::string& app_id); | 28 public: |
| 29 virtual void OnProfileLoaded(Profile* profile) = 0; |
| 30 virtual void OnProfileLoadFailed(KioskAppLaunchError::Error error) = 0; |
| 32 | 31 |
| 33 // Starts a launch attempt. Fails immediately if there is already a launch | 32 protected: |
| 34 // attempt running. | 33 virtual ~Delegate() {} |
| 34 }; |
| 35 |
| 36 KioskProfileLoader(KioskAppManager* kiosk_app_manager, |
| 37 const std::string& app_id, |
| 38 Delegate* delegate); |
| 39 |
| 40 ~KioskProfileLoader(); |
| 41 |
| 42 // Starts profile load. Calls delegate on success or failure. |
| 35 void Start(); | 43 void Start(); |
| 36 | 44 |
| 37 private: | 45 private: |
| 38 class CryptohomedChecker; | 46 class CryptohomedChecker; |
| 39 class ProfileLoader; | 47 class ProfileLoader; |
| 40 | 48 |
| 41 // Private dtor because this class manages its own lifetime. | |
| 42 ~KioskAppLauncher(); | |
| 43 | |
| 44 void ReportLaunchResult(KioskAppLaunchError::Error error); | 49 void ReportLaunchResult(KioskAppLaunchError::Error error); |
| 45 | 50 |
| 46 void StartMount(); | 51 void StartMount(); |
| 47 void MountCallback(bool mount_success, cryptohome::MountError mount_error); | 52 void MountCallback(bool mount_success, cryptohome::MountError mount_error); |
| 48 | 53 |
| 49 void AttemptRemove(); | 54 void AttemptRemove(); |
| 50 void RemoveCallback(bool success, | 55 void RemoveCallback(bool success, |
| 51 cryptohome::MountError return_code); | 56 cryptohome::MountError return_code); |
| 52 | 57 |
| 53 void OnProfilePrepared(Profile* profile); | 58 void OnProfilePrepared(Profile* profile); |
| 54 | 59 |
| 55 // The instance of the current running launch. | |
| 56 static KioskAppLauncher* running_instance_; | |
| 57 | |
| 58 KioskAppManager* kiosk_app_manager_; | 60 KioskAppManager* kiosk_app_manager_; |
| 59 const std::string app_id_; | 61 const std::string app_id_; |
| 60 std::string user_id_; | 62 std::string user_id_; |
| 63 Delegate* delegate_; |
| 61 | 64 |
| 62 scoped_ptr<CryptohomedChecker> crytohomed_checker; | 65 scoped_ptr<CryptohomedChecker> crytohomed_checker; |
| 63 scoped_ptr<ProfileLoader> profile_loader_; | 66 scoped_ptr<ProfileLoader> profile_loader_; |
| 64 | 67 |
| 65 // Whether remove existing cryptohome has attempted. | 68 // Whether remove existing cryptohome has attempted. |
| 66 bool remove_attempted_; | 69 bool remove_attempted_; |
| 67 | 70 |
| 68 DISALLOW_COPY_AND_ASSIGN(KioskAppLauncher); | 71 DISALLOW_COPY_AND_ASSIGN(KioskProfileLoader); |
| 69 }; | 72 }; |
| 70 | 73 |
| 71 } // namespace chromeos | 74 } // namespace chromeos |
| 72 | 75 |
| 73 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_LAUNCHER_H_ | 76 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_PROFILE_LOADER_H_ |
| OLD | NEW |