| 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_STARTUP_APP_LAUNCHER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_STARTUP_APP_LAUNCHER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_STARTUP_APP_LAUNCHER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_STARTUP_APP_LAUNCHER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_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/app_mode/kiosk_app_manager_observer.h" | 14 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h" |
| 15 #include "chrome/browser/extensions/install_observer.h" | 15 #include "chrome/browser/extensions/install_observer.h" |
| 16 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" |
| 16 #include "google_apis/gaia/oauth2_token_service.h" | 18 #include "google_apis/gaia/oauth2_token_service.h" |
| 17 | 19 |
| 18 class Profile; | 20 class Profile; |
| 19 | 21 |
| 20 namespace chromeos { | 22 namespace chromeos { |
| 21 | 23 |
| 22 // Launches the app at startup. The flow roughly looks like this: | 24 // Launches the app at startup. The flow roughly looks like this: |
| 23 // First call Initialize(): | 25 // First call Initialize(): |
| 24 // - Attempts to load oauth token file. Stores the loaded tokens in | 26 // - Attempts to load oauth token file. Stores the loaded tokens in |
| 25 // |auth_params_|. | 27 // |auth_params_|. |
| 26 // - Initialize token service and inject |auth_params_| if needed. | 28 // - Initialize token service and inject |auth_params_| if needed. |
| 27 // - Initialize network if app is not installed or not offline_enabled. | 29 // - Initialize network if app is not installed or not offline_enabled. |
| 28 // - If network is online, install or update the app as needed. | 30 // - If network is online, install or update the app as needed. |
| 29 // - After the app is installed/updated, launch it and finish the flow; | 31 // - After the app is installed/updated, launch it and finish the flow; |
| 30 // Report OnLauncherInitialized() or OnLaunchFailed() to observers: | 32 // Report OnLauncherInitialized() or OnLaunchFailed() to observers: |
| 31 // - If all goes good, launches the app and finish the flow; | 33 // - If all goes good, launches the app and finish the flow; |
| 32 class StartupAppLauncher : public base::SupportsWeakPtr<StartupAppLauncher>, | 34 class StartupAppLauncher : public base::SupportsWeakPtr<StartupAppLauncher>, |
| 33 public OAuth2TokenService::Observer, | 35 public OAuth2TokenService::Observer, |
| 34 public extensions::InstallObserver, | 36 public extensions::InstallObserver, |
| 35 public KioskAppManagerObserver { | 37 public KioskAppManagerObserver, |
| 38 public content::NotificationObserver { |
| 36 public: | 39 public: |
| 37 class Delegate { | 40 class Delegate { |
| 38 public: | 41 public: |
| 39 // Invoked to perform actual network initialization work. Note the app | 42 // Invoked to perform actual network initialization work. Note the app |
| 40 // launch flow is paused until ContinueWithNetworkReady is called. | 43 // launch flow is paused until ContinueWithNetworkReady is called. |
| 41 virtual void InitializeNetwork() = 0; | 44 virtual void InitializeNetwork() = 0; |
| 42 | 45 |
| 43 // Returns true if Internet is online. | 46 // Returns true if Internet is online. |
| 44 virtual bool IsNetworkReady() = 0; | 47 virtual bool IsNetworkReady() = 0; |
| 45 | 48 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 90 |
| 88 void BeginInstall(); | 91 void BeginInstall(); |
| 89 void OnReadyToLaunch(); | 92 void OnReadyToLaunch(); |
| 90 void UpdateAppData(); | 93 void UpdateAppData(); |
| 91 | 94 |
| 92 void InitializeTokenService(); | 95 void InitializeTokenService(); |
| 93 void MaybeInitializeNetwork(); | 96 void MaybeInitializeNetwork(); |
| 94 void MaybeInstallSecondaryApps(); | 97 void MaybeInstallSecondaryApps(); |
| 95 void MaybeLaunchApp(); | 98 void MaybeLaunchApp(); |
| 96 | 99 |
| 100 void MaybeCheckExtensionUpdate(); |
| 101 void OnExtensionUpdateCheckFinished(); |
| 102 |
| 97 void StartLoadingOAuthFile(); | 103 void StartLoadingOAuthFile(); |
| 98 static void LoadOAuthFileOnBlockingPool(KioskOAuthParams* auth_params); | 104 static void LoadOAuthFileOnBlockingPool(KioskOAuthParams* auth_params); |
| 99 void OnOAuthFileLoaded(KioskOAuthParams* auth_params); | 105 void OnOAuthFileLoaded(KioskOAuthParams* auth_params); |
| 100 | 106 |
| 101 void OnKioskAppDataLoadStatusChanged(const std::string& app_id); | 107 void OnKioskAppDataLoadStatusChanged(const std::string& app_id); |
| 102 | 108 |
| 103 // Returns true if any secondary app is pending. | 109 // Returns true if any secondary app is pending. |
| 104 bool IsAnySecondaryAppPending() const; | 110 bool IsAnySecondaryAppPending() const; |
| 105 | 111 |
| 106 // Returns true if all secondary apps have been installed. | 112 // Returns true if all secondary apps have been installed. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 121 void OnRefreshTokensLoaded() override; | 127 void OnRefreshTokensLoaded() override; |
| 122 | 128 |
| 123 // extensions::InstallObserver overrides. | 129 // extensions::InstallObserver overrides. |
| 124 void OnFinishCrxInstall(const std::string& extension_id, | 130 void OnFinishCrxInstall(const std::string& extension_id, |
| 125 bool success) override; | 131 bool success) override; |
| 126 | 132 |
| 127 // KioskAppManagerObserver overrides. | 133 // KioskAppManagerObserver overrides. |
| 128 void OnKioskExtensionLoadedInCache(const std::string& app_id) override; | 134 void OnKioskExtensionLoadedInCache(const std::string& app_id) override; |
| 129 void OnKioskExtensionDownloadFailed(const std::string& app_id) override; | 135 void OnKioskExtensionDownloadFailed(const std::string& app_id) override; |
| 130 | 136 |
| 137 // content::NotificationObserver implementation. |
| 138 void Observe(int type, |
| 139 const content::NotificationSource& source, |
| 140 const content::NotificationDetails& details) override; |
| 141 |
| 131 Profile* profile_; | 142 Profile* profile_; |
| 132 const std::string app_id_; | 143 const std::string app_id_; |
| 133 const bool diagnostic_mode_; | 144 const bool diagnostic_mode_; |
| 134 Delegate* delegate_; | 145 Delegate* delegate_; |
| 135 bool network_ready_handled_; | 146 bool network_ready_handled_ = false; |
| 136 int launch_attempt_; | 147 int launch_attempt_ = 0; |
| 137 bool ready_to_launch_; | 148 bool ready_to_launch_ = false; |
| 138 bool wait_for_crx_update_; | 149 bool wait_for_crx_update_ = false; |
| 139 bool secondary_apps_updated_; | 150 bool secondary_apps_installed_ = false; |
| 151 bool extension_update_found_ = false; |
| 140 | 152 |
| 141 KioskOAuthParams auth_params_; | 153 KioskOAuthParams auth_params_; |
| 154 content::NotificationRegistrar registrar_; |
| 142 | 155 |
| 143 DISALLOW_COPY_AND_ASSIGN(StartupAppLauncher); | 156 DISALLOW_COPY_AND_ASSIGN(StartupAppLauncher); |
| 144 }; | 157 }; |
| 145 | 158 |
| 146 } // namespace chromeos | 159 } // namespace chromeos |
| 147 | 160 |
| 148 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_STARTUP_APP_LAUNCHER_H_ | 161 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_STARTUP_APP_LAUNCHER_H_ |
| OLD | NEW |