X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fchrome%2Fbrowser%2Fchromeos%2Flogin%2Fapp_launch_controller.cc;h=7cda1fc3eb69eeecce5dbb5f1491bc5b6c0ace95;hb=ff3e2503a20db9193d323c1d19c38c68004dec4a;hp=e95078d51041f66a4399b8a31f43da9a231b1f47;hpb=7338fba38ba696536d1cc9d389afd716a6ab2fe6;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/chrome/browser/chromeos/login/app_launch_controller.cc b/src/chrome/browser/chromeos/login/app_launch_controller.cc index e95078d..7cda1fc 100644 --- a/src/chrome/browser/chromeos/login/app_launch_controller.cc +++ b/src/chrome/browser/chromeos/login/app_launch_controller.cc @@ -4,10 +4,14 @@ #include "chrome/browser/chromeos/login/app_launch_controller.h" -#include "apps/shell_window_registry.h" +#include "apps/app_window.h" +#include "apps/app_window_registry.h" +#include "base/bind.h" #include "base/callback.h" #include "base/files/file_path.h" #include "base/json/json_file_value_serializer.h" +#include "base/memory/weak_ptr.h" +#include "base/message_loop/message_loop.h" #include "base/time/time.h" #include "base/values.h" #include "chrome/browser/browser_process.h" @@ -51,31 +55,47 @@ AppLaunchController::ReturnBoolCallback* // AppLaunchController::AppWindowWatcher class AppLaunchController::AppWindowWatcher - : public apps::ShellWindowRegistry::Observer { + : public apps::AppWindowRegistry::Observer { public: - explicit AppWindowWatcher(AppLaunchController* controller) - : controller_(controller), - window_registry_(apps::ShellWindowRegistry::Get(controller->profile_)) { - window_registry_->AddObserver(this); + explicit AppWindowWatcher(AppLaunchController* controller, + const std::string& app_id) + : controller_(controller), + app_id_(app_id), + window_registry_(apps::AppWindowRegistry::Get(controller->profile_)), + weak_factory_(this) { + if (!window_registry_->GetAppWindowsForApp(app_id).empty()) { + base::MessageLoop::current()->PostTask( + FROM_HERE, + base::Bind(&AppWindowWatcher::NotifyAppWindowCreated, + weak_factory_.GetWeakPtr())); + return; + } else { + window_registry_->AddObserver(this); + } } virtual ~AppWindowWatcher() { window_registry_->RemoveObserver(this); } private: - // apps::ShellWindowRegistry::Observer overrides: - virtual void OnShellWindowAdded(apps::ShellWindow* shell_window) OVERRIDE { - if (controller_) { - controller_->OnAppWindowCreated(); - controller_= NULL; + // apps::AppWindowRegistry::Observer overrides: + virtual void OnAppWindowAdded(apps::AppWindow* app_window) OVERRIDE { + if (app_window->extension_id() == app_id_) { + window_registry_->RemoveObserver(this); + NotifyAppWindowCreated(); } } - virtual void OnShellWindowIconChanged( - apps::ShellWindow* shell_window) OVERRIDE {} - virtual void OnShellWindowRemoved(apps::ShellWindow* shell_window) OVERRIDE {} + virtual void OnAppWindowIconChanged(apps::AppWindow* app_window) OVERRIDE {} + virtual void OnAppWindowRemoved(apps::AppWindow* app_window) OVERRIDE {} + + void NotifyAppWindowCreated() { + controller_->OnAppWindowCreated(); + } AppLaunchController* controller_; - apps::ShellWindowRegistry* window_registry_; + std::string app_id_; + apps::AppWindowRegistry* window_registry_; + base::WeakPtrFactory weak_factory_; DISALLOW_COPY_AND_ASSIGN(AppWindowWatcher); }; @@ -84,10 +104,12 @@ class AppLaunchController::AppWindowWatcher // AppLaunchController AppLaunchController::AppLaunchController(const std::string& app_id, + bool diagnostic_mode, LoginDisplayHost* host, OobeDisplay* oobe_display) : profile_(NULL), app_id_(app_id), + diagnostic_mode_(diagnostic_mode), host_(host), oobe_display_(oobe_display), app_launch_splash_screen_actor_( @@ -118,8 +140,11 @@ void AppLaunchController::StartAppLaunch() { app_launch_splash_screen_actor_->SetDelegate(this); app_launch_splash_screen_actor_->Show(app_id_); + KioskAppManager::App app; + CHECK(KioskAppManager::Get() && + KioskAppManager::Get()->GetApp(app_id_, &app)); kiosk_profile_loader_.reset( - new KioskProfileLoader(KioskAppManager::Get(), app_id_, this)); + new KioskProfileLoader(app.user_id, false, this)); kiosk_profile_loader_->Start(); } @@ -206,7 +231,8 @@ void AppLaunchController::OnProfileLoaded(Profile* profile) { profile_ = profile; kiosk_profile_loader_.reset(); - startup_app_launcher_.reset(new StartupAppLauncher(profile_, app_id_, this)); + startup_app_launcher_.reset( + new StartupAppLauncher(profile_, app_id_, diagnostic_mode_, this)); startup_app_launcher_->Initialize(); } @@ -298,6 +324,10 @@ void AppLaunchController::InitializeNetwork() { AppLaunchSplashScreenActor::APP_LAUNCH_STATE_PREPARING_NETWORK); } +bool AppLaunchController::IsNetworkReady() { + return app_launch_splash_screen_actor_->IsNetworkReady(); +} + void AppLaunchController::OnLoadingOAuthFile() { app_launch_splash_screen_actor_->UpdateAppLaunchState( AppLaunchSplashScreenActor::APP_LAUNCH_STATE_LOADING_AUTH_FILE); @@ -358,7 +388,7 @@ void AppLaunchController::OnLaunchSucceeded() { AppLaunchSplashScreenActor::APP_LAUNCH_STATE_WAITING_APP_WINDOW); DCHECK(!app_window_watcher_); - app_window_watcher_.reset(new AppWindowWatcher(this)); + app_window_watcher_.reset(new AppWindowWatcher(this, app_id_)); } void AppLaunchController::OnLaunchFailed(KioskAppLaunchError::Error error) {