Commit ccc2add1 authored by xiyuan@chromium.org's avatar xiyuan@chromium.org

kiosk: Skip network check for offline enabled app.

BUG=333900

Review URL: https://codereview.chromium.org/149843004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250941 0039d316-1c4b-4281-b951-d872f2087c98
parent 4decf437
...@@ -39,6 +39,10 @@ class AppLaunchManager : public StartupAppLauncher::Delegate { ...@@ -39,6 +39,10 @@ class AppLaunchManager : public StartupAppLauncher::Delegate {
// network configure handling. // network configure handling.
startup_app_launcher_->ContinueWithNetworkReady(); startup_app_launcher_->ContinueWithNetworkReady();
} }
virtual bool IsNetworkReady() OVERRIDE {
// See comments above. Network is assumed to be online here.
return true;
}
virtual void OnLoadingOAuthFile() OVERRIDE {} virtual void OnLoadingOAuthFile() OVERRIDE {}
virtual void OnInitializingTokenService() OVERRIDE {} virtual void OnInitializingTokenService() OVERRIDE {}
virtual void OnInstallingApp() OVERRIDE {} virtual void OnInstallingApp() OVERRIDE {}
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/manifest_handlers/kiosk_mode_info.h" #include "extensions/common/manifest_handlers/kiosk_mode_info.h"
#include "extensions/common/manifest_handlers/offline_enabled_info.h"
#include "google_apis/gaia/gaia_auth_consumer.h" #include "google_apis/gaia/gaia_auth_consumer.h"
#include "google_apis/gaia/gaia_constants.h" #include "google_apis/gaia/gaia_constants.h"
#include "net/base/load_flags.h" #include "net/base/load_flags.h"
...@@ -134,10 +135,10 @@ class StartupAppLauncher::AppUpdateChecker ...@@ -134,10 +135,10 @@ class StartupAppLauncher::AppUpdateChecker
} }
const Version& existing_version = *GetInstalledApp()->version(); const Version& existing_version = *GetInstalledApp()->version();
Version update_version(update.version); const Version update_version(update.version);
if (existing_version.IsValid() && if (!update_version.IsValid() ||
update_version.IsValid() && (existing_version.IsValid() &&
update_version.CompareTo(existing_version) <= 0) { update_version.CompareTo(existing_version) <= 0)) {
launcher_->OnUpdateCheckNoUpdate(); launcher_->OnUpdateCheckNoUpdate();
return; return;
} }
...@@ -261,8 +262,23 @@ void StartupAppLauncher::OnOAuthFileLoaded(KioskOAuthParams* auth_params) { ...@@ -261,8 +262,23 @@ void StartupAppLauncher::OnOAuthFileLoaded(KioskOAuthParams* auth_params) {
InitializeTokenService(); InitializeTokenService();
} }
void StartupAppLauncher::InitializeNetwork() { void StartupAppLauncher::MaybeInitializeNetwork() {
delegate_->InitializeNetwork(); const Extension* extension = extensions::ExtensionSystem::Get(profile_)->
extension_service()->GetInstalledExtension(app_id_);
const bool requires_network = !extension ||
!extensions::OfflineEnabledInfo::IsOfflineEnabled(extension);
if (requires_network) {
delegate_->InitializeNetwork();
return;
}
// Offline enabled app attempts update if network is ready. Otherwise,
// go directly to launch.
if (delegate_->IsNetworkReady())
ContinueWithNetworkReady();
else
OnReadyToLaunch();
} }
void StartupAppLauncher::InitializeTokenService() { void StartupAppLauncher::InitializeTokenService() {
...@@ -275,7 +291,7 @@ void StartupAppLauncher::InitializeTokenService() { ...@@ -275,7 +291,7 @@ void StartupAppLauncher::InitializeTokenService() {
if (profile_token_service->RefreshTokenIsAvailable( if (profile_token_service->RefreshTokenIsAvailable(
signin_manager->GetAuthenticatedAccountId()) || signin_manager->GetAuthenticatedAccountId()) ||
auth_params_.refresh_token.empty()) { auth_params_.refresh_token.empty()) {
InitializeNetwork(); MaybeInitializeNetwork();
} else { } else {
// Pass oauth2 refresh token from the auth file. // Pass oauth2 refresh token from the auth file.
// TODO(zelidrag): We should probably remove this option after M27. // TODO(zelidrag): We should probably remove this option after M27.
...@@ -301,13 +317,13 @@ void StartupAppLauncher::OnRefreshTokenAvailable( ...@@ -301,13 +317,13 @@ void StartupAppLauncher::OnRefreshTokenAvailable(
const std::string& account_id) { const std::string& account_id) {
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_) ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)
->RemoveObserver(this); ->RemoveObserver(this);
InitializeNetwork(); MaybeInitializeNetwork();
} }
void StartupAppLauncher::OnRefreshTokensLoaded() { void StartupAppLauncher::OnRefreshTokensLoaded() {
ProfileOAuth2TokenServiceFactory::GetForProfile(profile_) ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)
->RemoveObserver(this); ->RemoveObserver(this);
InitializeNetwork(); MaybeInitializeNetwork();
} }
void StartupAppLauncher::LaunchApp() { void StartupAppLauncher::LaunchApp() {
......
...@@ -23,11 +23,12 @@ namespace chromeos { ...@@ -23,11 +23,12 @@ namespace chromeos {
// Launches the app at startup. The flow roughly looks like this: // Launches the app at startup. The flow roughly looks like this:
// First call Initialize(): // First call Initialize():
// - Checks if the app is installed in user profile (aka app profile); // - Attempts to load oauth token file. Stores the loaded tokens in
// - If the app is installed, launch it and finish the flow; // |auth_params_|.
// - If not installed, prepare to start install by checking network online // - Initialize token service and inject |auth_params_| if needed.
// state; // - Initialize network if app is not installed or not offline_enabled.
// - If network gets online, start to install the app from web store; // - If network is online, install or update the app as needed.
// - After the app is installed/updated, launch it and finish the flow;
// Report OnLauncherInitialized() or OnLaunchFailed() to observers: // Report OnLauncherInitialized() or OnLaunchFailed() to observers:
// - If all goes good, launches the app and finish the flow; // - If all goes good, launches the app and finish the flow;
class StartupAppLauncher class StartupAppLauncher
...@@ -40,6 +41,9 @@ class StartupAppLauncher ...@@ -40,6 +41,9 @@ class StartupAppLauncher
// launch flow is paused until ContinueWithNetworkReady is called. // launch flow is paused until ContinueWithNetworkReady is called.
virtual void InitializeNetwork() = 0; virtual void InitializeNetwork() = 0;
// Returns true if Internet is online.
virtual bool IsNetworkReady() = 0;
virtual void OnLoadingOAuthFile() = 0; virtual void OnLoadingOAuthFile() = 0;
virtual void OnInitializingTokenService() = 0; virtual void OnInitializingTokenService() = 0;
virtual void OnInstallingApp() = 0; virtual void OnInstallingApp() = 0;
...@@ -96,7 +100,7 @@ class StartupAppLauncher ...@@ -96,7 +100,7 @@ class StartupAppLauncher
void UpdateAppData(); void UpdateAppData();
void InitializeTokenService(); void InitializeTokenService();
void InitializeNetwork(); void MaybeInitializeNetwork();
void StartLoadingOAuthFile(); void StartLoadingOAuthFile();
static void LoadOAuthFileOnBlockingPool(KioskOAuthParams* auth_params); static void LoadOAuthFileOnBlockingPool(KioskOAuthParams* auth_params);
......
...@@ -304,6 +304,10 @@ void AppLaunchController::InitializeNetwork() { ...@@ -304,6 +304,10 @@ void AppLaunchController::InitializeNetwork() {
AppLaunchSplashScreenActor::APP_LAUNCH_STATE_PREPARING_NETWORK); AppLaunchSplashScreenActor::APP_LAUNCH_STATE_PREPARING_NETWORK);
} }
bool AppLaunchController::IsNetworkReady() {
return app_launch_splash_screen_actor_->IsNetworkReady();
}
void AppLaunchController::OnLoadingOAuthFile() { void AppLaunchController::OnLoadingOAuthFile() {
app_launch_splash_screen_actor_->UpdateAppLaunchState( app_launch_splash_screen_actor_->UpdateAppLaunchState(
AppLaunchSplashScreenActor::APP_LAUNCH_STATE_LOADING_AUTH_FILE); AppLaunchSplashScreenActor::APP_LAUNCH_STATE_LOADING_AUTH_FILE);
......
...@@ -91,6 +91,7 @@ class AppLaunchController ...@@ -91,6 +91,7 @@ class AppLaunchController
// StartupAppLauncher::Delegate overrides: // StartupAppLauncher::Delegate overrides:
virtual void InitializeNetwork() OVERRIDE; virtual void InitializeNetwork() OVERRIDE;
virtual bool IsNetworkReady() OVERRIDE;
virtual void OnLoadingOAuthFile() OVERRIDE; virtual void OnLoadingOAuthFile() OVERRIDE;
virtual void OnInitializingTokenService() OVERRIDE; virtual void OnInitializingTokenService() OVERRIDE;
virtual void OnInstallingApp() OVERRIDE; virtual void OnInstallingApp() OVERRIDE;
......
...@@ -59,6 +59,9 @@ class AppLaunchSplashScreenActor { ...@@ -59,6 +59,9 @@ class AppLaunchSplashScreenActor {
// Shows the network error and configure UI. // Shows the network error and configure UI.
virtual void ShowNetworkConfigureUI() = 0; virtual void ShowNetworkConfigureUI() = 0;
// Returns true if the default network has Internet access.
virtual bool IsNetworkReady() = 0;
}; };
} // namespace chromeos } // namespace chromeos
......
...@@ -178,6 +178,10 @@ void AppLaunchSplashScreenHandler::ShowNetworkConfigureUI() { ...@@ -178,6 +178,10 @@ void AppLaunchSplashScreenHandler::ShowNetworkConfigureUI() {
error_screen_actor_->Show(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH, NULL); error_screen_actor_->Show(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH, NULL);
} }
bool AppLaunchSplashScreenHandler::IsNetworkReady() {
return network_state_informer_->state() == NetworkStateInformer::ONLINE;
}
void AppLaunchSplashScreenHandler::OnNetworkReady() { void AppLaunchSplashScreenHandler::OnNetworkReady() {
// Purposely leave blank because the online case is handled in UpdateState // Purposely leave blank because the online case is handled in UpdateState
// call below. // call below.
......
...@@ -43,6 +43,7 @@ class AppLaunchSplashScreenHandler ...@@ -43,6 +43,7 @@ class AppLaunchSplashScreenHandler
virtual void SetDelegate( virtual void SetDelegate(
AppLaunchSplashScreenHandler::Delegate* delegate) OVERRIDE; AppLaunchSplashScreenHandler::Delegate* delegate) OVERRIDE;
virtual void ShowNetworkConfigureUI() OVERRIDE; virtual void ShowNetworkConfigureUI() OVERRIDE;
virtual bool IsNetworkReady() OVERRIDE;
// NetworkStateInformer::NetworkStateInformerObserver implementation: // NetworkStateInformer::NetworkStateInformerObserver implementation:
virtual void OnNetworkReady() OVERRIDE; virtual void OnNetworkReady() OVERRIDE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment