Commit 625b1314 authored by rkc@chromium.org's avatar rkc@chromium.org

Add a basic demo mode browser test.

This CL adds a basic demo mode browser test that verifies that a machine with 0 derelict timeouts correctly brings up the demo app.
This CL also fixes a bunch of style issues pointed out in

R=bartfab@chromium.org, xiyuan@chromium.org
BUG=343574,355134

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260255 0039d316-1c4b-4281-b951-d872f2087c98
parent b82b38f7
......@@ -117,10 +117,10 @@ class KioskProfileLoader::CryptohomedChecker
// KioskProfileLoader
KioskProfileLoader::KioskProfileLoader(const std::string& app_user_id,
bool force_ephemeral,
bool use_guest_mount,
Delegate* delegate)
: user_id_(app_user_id),
force_ephemeral_(force_ephemeral),
use_guest_mount_(use_guest_mount),
delegate_(delegate) {}
KioskProfileLoader::~KioskProfileLoader() {}
......@@ -134,7 +134,7 @@ void KioskProfileLoader::Start() {
void KioskProfileLoader::LoginAsKioskAccount() {
login_performer_.reset(new LoginPerformer(this));
login_performer_->LoginAsKioskAccount(user_id_, force_ephemeral_);
login_performer_->LoginAsKioskAccount(user_id_, use_guest_mount_);
}
void KioskProfileLoader::ReportLaunchResult(KioskAppLaunchError::Error error) {
......
......@@ -18,8 +18,6 @@ class Profile;
namespace chromeos {
class KioskAppManager;
// KioskProfileLoader loads a special profile for a given app. It first
// attempts to login for the app's generated user id. If the login is
// successful, it prepares app profile then calls the delegate.
......@@ -36,7 +34,7 @@ class KioskProfileLoader : public LoginPerformer::Delegate,
};
KioskProfileLoader(const std::string& app_user_id,
bool force_ephemeral,
bool use_guest_mount,
Delegate* delegate);
virtual ~KioskProfileLoader();
......@@ -62,7 +60,7 @@ class KioskProfileLoader : public LoginPerformer::Delegate,
virtual void OnProfilePrepared(Profile* profile) OVERRIDE;
std::string user_id_;
bool force_ephemeral_;
bool use_guest_mount_;
Delegate* delegate_;
scoped_ptr<CryptohomedChecker> cryptohomed_checker_;
scoped_ptr<LoginPerformer> login_performer_;
......
......@@ -35,11 +35,10 @@ void IdleDetector::Start(const base::TimeDelta& timeout) {
}
void IdleDetector::ResetTimer() {
if (timer_.IsRunning()) {
if (timer_.IsRunning())
timer_.Reset();
} else {
else
timer_.Start(FROM_HERE, timeout_, idle_callback_);
}
}
} // namespace chromeos
......@@ -7,7 +7,9 @@
#include "ash/wm/user_activity_observer.h"
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
namespace chromeos {
......
......@@ -10,6 +10,7 @@
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/json/json_file_value_serializer.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/time/time.h"
......@@ -142,8 +143,8 @@ void AppLaunchController::StartAppLaunch() {
app_launch_splash_screen_actor_->Show(app_id_);
KioskAppManager::App app;
CHECK(KioskAppManager::Get() &&
KioskAppManager::Get()->GetApp(app_id_, &app));
CHECK(KioskAppManager::Get());
CHECK(KioskAppManager::Get()->GetApp(app_id_, &app));
kiosk_profile_loader_.reset(
new KioskProfileLoader(app.user_id, false, this));
kiosk_profile_loader_->Start();
......
......@@ -58,9 +58,10 @@ class Authenticator : public base::RefCountedThreadSafe<Authenticator> {
// Initiates login into kiosk mode account identified by |app_user_id|.
// The |app_user_id| is a generated username for the account.
// |force_ephemeral| specifies whether to force the session to be ephemeral.
virtual void LoginAsKioskAccount(
const std::string& app_user_id, bool force_ephemeral) = 0;
// |use_guest_mount| specifies whether to force the session to use a
// guest mount. If this is false, we use mount a public cryptohome.
virtual void LoginAsKioskAccount(const std::string& app_user_id,
bool use_guest_mount) = 0;
// Completes retail mode login.
virtual void OnRetailModeLoginSuccess() = 0;
......
......@@ -5,23 +5,40 @@
#include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "chrome/browser/chromeos/app_mode/app_session_lifetime.h"
#include "chrome/browser/chromeos/login/login_display_host.h"
#include "chrome/browser/chromeos/login/login_display_host_impl.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/extensions/component_loader.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
#include "grit/browser_resources.h"
#include "ui/base/window_open_disposition.h"
namespace chromeos {
const char DemoAppLauncher::kDemoUserName[] = "demouser@demo.app.local";
const base::FilePath::CharType kDefaultDemoAppPath[] =
FILE_PATH_LITERAL("/usr/share/chromeos-assets/demo_app");
DemoAppLauncher::DemoAppLauncher() : profile_(NULL) {}
// static
base::FilePath* DemoAppLauncher::demo_app_path_ = NULL;
DemoAppLauncher::DemoAppLauncher() {
if (!demo_app_path_)
demo_app_path_ = new base::FilePath(kDefaultDemoAppPath);
}
DemoAppLauncher::~DemoAppLauncher() {}
DemoAppLauncher::~DemoAppLauncher() {
delete demo_app_path_;
}
void DemoAppLauncher::StartDemoAppLaunch() {
DVLOG(1) << "Launching demo app...";
......@@ -33,21 +50,27 @@ void DemoAppLauncher::StartDemoAppLaunch() {
// static
bool DemoAppLauncher::IsDemoAppSession(const std::string& user_id) {
return user_id == kDemoUserName ? true : false;
return user_id == kDemoUserName;
}
// static
void DemoAppLauncher::SetDemoAppPathForTesting(const base::FilePath& path) {
delete demo_app_path_;
demo_app_path_ = new base::FilePath(path);
}
void DemoAppLauncher::OnProfileLoaded(Profile* profile) {
DVLOG(1) << "Profile loaded... Starting demo app launch.";
profile_ = profile;
kiosk_profile_loader_.reset();
// Load our demo app, then launch it.
ExtensionService* extension_service =
extensions::ExtensionSystem::Get(profile_)->extension_service();
std::string extension_id = extension_service->component_loader()->Add(
extensions::ExtensionSystem::Get(profile)->extension_service();
CHECK(demo_app_path_);
const std::string extension_id = extension_service->component_loader()->Add(
IDR_DEMO_APP_MANIFEST,
base::FilePath("/usr/share/chromeos-assets/demo_app"));
*demo_app_path_);
const extensions::Extension* extension =
extension_service->GetExtensionById(extension_id, true);
......@@ -57,8 +80,8 @@ void DemoAppLauncher::OnProfileLoaded(Profile* profile) {
command_line->AppendSwitchASCII(switches::kAppId, extension_id);
OpenApplication(AppLaunchParams(
profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW));
InitAppSession(profile_, extension_id);
profile, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW));
InitAppSession(profile, extension_id);
UserManager::Get()->SessionStarted();
......
......@@ -5,10 +5,16 @@
#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_DEMO_MODE_DEMO_APP_LAUNCHER_H_
#define CHROME_BROWSER_CHROMEOS_LOGIN_DEMO_MODE_DEMO_APP_LAUNCHER_H_
#include <string>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/chromeos/app_mode/kiosk_profile_loader.h"
class Profile;
namespace base {
class FilePath;
}
namespace chromeos {
......@@ -21,16 +27,21 @@ class DemoAppLauncher : public KioskProfileLoader::Delegate {
void StartDemoAppLaunch();
static bool IsDemoAppSession(const std::string& user_id);
static void SetDemoAppPathForTesting(const base::FilePath& path);
static const char kDemoUserName[];
private:
friend class DemoAppLauncherTest;
// KioskProfileLoader::Delegate overrides:
virtual void OnProfileLoaded(Profile* profile) OVERRIDE;
virtual void OnProfileLoadFailed(KioskAppLaunchError::Error error) OVERRIDE;
Profile* profile_;
scoped_ptr<KioskProfileLoader> kiosk_profile_loader_;
static base::FilePath* demo_app_path_;
DISALLOW_COPY_AND_ASSIGN(DemoAppLauncher);
};
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "apps/app_window_registry.h"
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h"
#include "chrome/browser/chromeos/login/test/app_window_waiter.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_paths.h"
#include "chromeos/chromeos_switches.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
namespace {
char kDemoAppId[] = "klimoghijjogocdbaikffefjfcfheiel";
base::FilePath GetTestDemoAppPath() {
base::FilePath test_data_dir;
EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir));
return test_data_dir.Append(FILE_PATH_LITERAL("chromeos/demo_app"));
}
Profile* WaitForProfile() {
chromeos::UserManager* user_manager = chromeos::UserManager::Get();
if (!user_manager || !user_manager->IsUserLoggedIn()) {
content::WindowedNotificationObserver(
chrome::NOTIFICATION_SESSION_STARTED,
content::NotificationService::AllSources()).Wait();
}
return ProfileManager::GetActiveUserProfile();
}
bool VerifyDemoAppLaunch() {
Profile* profile = WaitForProfile();
return AppWindowWaiter(apps::AppWindowRegistry::Get(profile),
kDemoAppId).Wait() != NULL;
}
} // namespace
class DemoAppLauncherTest : public ExtensionBrowserTest {
public:
DemoAppLauncherTest() {
set_exit_when_last_browser_closes(false);
}
virtual ~DemoAppLauncherTest() {}
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
command_line->AppendSwitch(switches::kLoginManager);
command_line->AppendSwitch(switches::kForceLoginManagerInTests);
command_line->AppendSwitchASCII(switches::kLoginProfile, "user");
command_line->AppendSwitchASCII(switches::kDerelictIdleTimeout, "0");
command_line->AppendSwitchASCII(switches::kOobeTimerInterval, "0");
command_line->AppendSwitchASCII(switches::kDerelictDetectionTimeout, "0");
}
virtual void SetUp() OVERRIDE {
chromeos::DemoAppLauncher::SetDemoAppPathForTesting(GetTestDemoAppPath());
ExtensionBrowserTest::SetUp();
}
private:
DISALLOW_COPY_AND_ASSIGN(DemoAppLauncherTest);
};
IN_PROC_BROWSER_TEST_F(DemoAppLauncherTest, Basic) {
// This test is fairly unique in the sense that the test actually starts as
// soon as Chrome launches, so there isn't any typical "launch this test"
// steps that we need to take. All we can do is verify that our demo app
// did launch.
EXPECT_TRUE(VerifyDemoAppLaunch());
}
} // namespace chromeos
......@@ -21,6 +21,7 @@
#include "chrome/browser/chromeos/login/mock_user_manager.h"
#include "chrome/browser/chromeos/login/oobe_base_test.h"
#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/test/app_window_waiter.h"
#include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
......@@ -227,48 +228,6 @@ class JsConditionWaiter {
} // namespace
// Helper class that monitors app windows to wait for a window to appear.
class AppWindowObserver : public apps::AppWindowRegistry::Observer {
public:
AppWindowObserver(apps::AppWindowRegistry* registry,
const std::string& app_id)
: registry_(registry), app_id_(app_id), window_(NULL), running_(false) {
registry_->AddObserver(this);
}
virtual ~AppWindowObserver() { registry_->RemoveObserver(this); }
apps::AppWindow* Wait() {
running_ = true;
message_loop_runner_ = new content::MessageLoopRunner;
message_loop_runner_->Run();
EXPECT_TRUE(window_);
return window_;
}
// AppWindowRegistry::Observer
virtual void OnAppWindowAdded(apps::AppWindow* app_window) OVERRIDE {
if (!running_)
return;
if (app_window->extension_id() == app_id_) {
window_ = app_window;
message_loop_runner_->Quit();
running_ = false;
}
}
virtual void OnAppWindowIconChanged(apps::AppWindow* app_window) OVERRIDE {}
virtual void OnAppWindowRemoved(apps::AppWindow* app_window) OVERRIDE {}
private:
apps::AppWindowRegistry* registry_;
std::string app_id_;
scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
apps::AppWindow* window_;
bool running_;
DISALLOW_COPY_AND_ASSIGN(AppWindowObserver);
};
class KioskTest : public OobeBaseTest {
public:
KioskTest() {
......@@ -415,7 +374,7 @@ class KioskTest : public OobeBaseTest {
apps::AppWindowRegistry* app_window_registry =
apps::AppWindowRegistry::Get(app_profile);
apps::AppWindow* window =
AppWindowObserver(app_window_registry, test_app_id_).Wait();
AppWindowWaiter(app_window_registry, test_app_id_).Wait();
EXPECT_TRUE(window);
// Login screen should be gone or fading out.
......@@ -1224,7 +1183,7 @@ IN_PROC_BROWSER_TEST_F(KioskEnterpriseTest, EnterpriseKioskApp) {
// Wait for the window to appear.
apps::AppWindow* window =
AppWindowObserver(
AppWindowWaiter(
apps::AppWindowRegistry::Get(ProfileManager::GetPrimaryUserProfile()),
kTestEnterpriseKioskApp).Wait();
ASSERT_TRUE(window);
......
......@@ -34,6 +34,7 @@
#include "chrome/browser/chromeos/input_method/input_method_util.h"
#include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
#include "chrome/browser/chromeos/language_preferences.h"
#include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h"
#include "chrome/browser/chromeos/login/existing_user_controller.h"
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/input_events_blocker.h"
......
......@@ -13,7 +13,6 @@
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/login/app_launch_controller.h"
#include "chrome/browser/chromeos/login/auth_prewarmer.h"
#include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h"
#include "chrome/browser/chromeos/login/existing_user_controller.h"
#include "chrome/browser/chromeos/login/login_display.h"
#include "chrome/browser/chromeos/login/login_display_host.h"
......@@ -35,6 +34,7 @@ class WebContents;
namespace chromeos {
class DemoAppLauncher;
class FocusRingController;
class KeyboardDrivenOobeKeyHandler;
class OobeUI;
......
......@@ -302,13 +302,13 @@ void LoginPerformer::LoginAsPublicAccount(const std::string& username) {
username));
}
void LoginPerformer::LoginAsKioskAccount(
const std::string& app_user_id, bool force_ephemeral) {
void LoginPerformer::LoginAsKioskAccount(const std::string& app_user_id,
bool use_guest_mount) {
authenticator_ = LoginUtils::Get()->CreateAuthenticator(this);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&Authenticator::LoginAsKioskAccount, authenticator_.get(),
app_user_id, force_ephemeral));
app_user_id, use_guest_mount));
}
void LoginPerformer::RecoverEncryptedData(const std::string& old_password) {
......
......@@ -85,7 +85,7 @@ class LoginPerformer : public LoginStatusConsumer,
// Performs a login into the kiosk mode account with |app_user_id|.
void LoginAsKioskAccount(const std::string& app_user_id,
bool force_ephemeral);
bool use_guest_mount);
// Migrates cryptohome using |old_password| specified.
void RecoverEncryptedData(const std::string& old_password);
......
......@@ -416,10 +416,9 @@ void LoginUtilsImpl::PrepareProfile(
delegate_ = delegate;
InitSessionRestoreStrategy();
base::FilePath profile_dir;
if (DemoAppLauncher::IsDemoAppSession(user_context.username)) {
g_browser_process->profile_manager()->CreateProfileAsync(
ProfileManager::GetGuestProfilePath(),
user_manager->GetUserProfileDir(user_context.username),
base::Bind(&LoginUtilsImpl::OnOTRProfileCreated, AsWeakPtr(),
user_context.username),
base::string16(), base::string16(), std::string());
......
......@@ -61,8 +61,8 @@ void MockAuthenticator::LoginAsPublicAccount(const std::string& username) {
expected_username_));
}
void MockAuthenticator::LoginAsKioskAccount(
const std::string& app_user_id, bool force_ephemeral) {
void MockAuthenticator::LoginAsKioskAccount(const std::string& app_user_id,
bool use_guest_mount) {
consumer_->OnLoginSuccess(UserContext(expected_username_,
std::string(),
std::string(),
......
......@@ -38,8 +38,8 @@ class MockAuthenticator : public Authenticator {
const UserContext& user_context) OVERRIDE;
virtual void LoginRetailMode() OVERRIDE;
virtual void LoginAsPublicAccount(const std::string& username) OVERRIDE;
virtual void LoginAsKioskAccount(
const std::string& app_user_id, bool force_ephemeral) OVERRIDE;
virtual void LoginAsKioskAccount(const std::string& app_user_id,
bool use_guest_mount) OVERRIDE;
virtual void LoginOffTheRecord() OVERRIDE;
virtual void OnRetailModeLoginSuccess() OVERRIDE;
......
......@@ -110,6 +110,24 @@ void MountGuest(AuthAttemptState* attempt,
resolver));
}
// Calls cryptohome's mount method for guest and also get the user hash from
// cryptohome.
void MountGuestAndGetHash(AuthAttemptState* attempt,
scoped_refptr<ParallelAuthenticator> resolver) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
attempt->UsernameHashRequested();
cryptohome::AsyncMethodCaller::GetInstance()->AsyncMountGuest(
base::Bind(&TriggerResolveWithLoginTimeMarker,
"CryptohomeMount-End",
attempt,
resolver));
cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername(
attempt->user_context.username,
base::Bind(&TriggerResolveHash,
attempt,
resolver));
}
// Calls cryptohome's MountPublic method
void MountPublic(AuthAttemptState* attempt,
scoped_refptr<ParallelAuthenticator> resolver,
......@@ -346,11 +364,12 @@ void ParallelAuthenticator::LoginAsPublicAccount(const std::string& username) {
}
void ParallelAuthenticator::LoginAsKioskAccount(
const std::string& app_user_id, bool force_ephemeral) {
const std::string& app_user_id,
bool use_guest_mount) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
std::string user_id =
force_ephemeral ? UserManager::kGuestUserName : app_user_id;
const std::string user_id =
use_guest_mount ? UserManager::kGuestUserName : app_user_id;
current_state_.reset(new AuthAttemptState(
UserContext(user_id,
std::string(), // password
......@@ -361,14 +380,14 @@ void ParallelAuthenticator::LoginAsKioskAccount(
false));
remove_user_data_on_failure_ = true;
if (!force_ephemeral) {
if (!use_guest_mount) {
MountPublic(current_state_.get(),
scoped_refptr<ParallelAuthenticator>(this),
cryptohome::CREATE_IF_MISSING);
} else {
ephemeral_mount_attempted_ = true;
MountGuest(current_state_.get(),
scoped_refptr<ParallelAuthenticator>(this));
MountGuestAndGetHash(current_state_.get(),
scoped_refptr<ParallelAuthenticator>(this));
}
}
......
......@@ -132,10 +132,12 @@ class ParallelAuthenticator : public Authenticator,
virtual void LoginAsPublicAccount(const std::string& username) OVERRIDE;
// Initiates login into the kiosk mode account identified by |app_user_id|.
// Mounts an public but non-ephemeral cryptohome and notifies consumer on the
// success/failure.
virtual void LoginAsKioskAccount(
const std::string& app_user_id, bool force_ephemeral) OVERRIDE;
// Mounts an ephemeral guest cryptohome if |use_guest_mount| is |true|.
// Otherwise, mounts a public cryptohome, which will be ephemeral if the
// |DeviceEphemeralUsersEnabled| policy is enabled and non-ephemeral
// otherwise.
virtual void LoginAsKioskAccount(const std::string& app_user_id,
bool use_guest_mount) OVERRIDE;
// These methods must be called on the UI thread, as they make DBus calls
// and also call back to the login UI.
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/login/test/app_window_waiter.h"
#include "apps/app_window.h"
namespace chromeos {
AppWindowWaiter::AppWindowWaiter(apps::AppWindowRegistry* registry,
const std::string& app_id)
: registry_(registry), app_id_(app_id), window_(NULL) {
registry_->AddObserver(this);
}
AppWindowWaiter::~AppWindowWaiter() {
registry_->RemoveObserver(this);
}
apps::AppWindow* AppWindowWaiter::Wait() {
window_ = registry_->GetCurrentAppWindowForApp(app_id_);
if (window_)
return window_;
run_loop_.Run();
return window_;
}
void AppWindowWaiter::OnAppWindowAdded(apps::AppWindow* app_window) {
if (!run_loop_.running())
return;
if (app_window->extension_id() == app_id_) {
window_ = app_window;
run_loop_.Quit();
}
}
void AppWindowWaiter::OnAppWindowIconChanged(apps::AppWindow* app_window) {}
void AppWindowWaiter::OnAppWindowRemoved(apps::AppWindow* app_window) {}
} // namespace chromeos
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_TEST_APP_WINDOW_WAITER_H_
#define CHROME_BROWSER_CHROMEOS_LOGIN_TEST_APP_WINDOW_WAITER_H_
#include <string>
#include "apps/app_window_registry.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/run_loop.h"
namespace apps {
class AppWindow;
}
namespace chromeos {
// Helper class that monitors app windows to wait for a window to appear.
// Use a new instance for each use, one instance will only work for one Wait.
class AppWindowWaiter : public apps::AppWindowRegistry::Observer {
public:
AppWindowWaiter(apps::AppWindowRegistry* registry,
const std::string& app_id);
virtual ~AppWindowWaiter();
apps::AppWindow* Wait();
// AppWindowRegistry::Observer:
virtual void OnAppWindowAdded(apps::AppWindow* app_window) OVERRIDE;
virtual void OnAppWindowIconChanged(apps::AppWindow* app_window) OVERRIDE;
virtual void OnAppWindowRemoved(apps::AppWindow* app_window) OVERRIDE;
private:
apps::AppWindowRegistry* registry_;
std::string app_id_;
base::RunLoop run_loop_;
apps::AppWindow* window_;
DISALLOW_COPY_AND_ASSIGN(AppWindowWaiter);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_LOGIN_TEST_APP_WINDOW_WAITER_H_
......@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
......@@ -18,11 +19,11 @@
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
#include "chrome/browser/chromeos/base/locale_util.h"
#include "chrome/browser/chromeos/idle_detector.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
#include "chrome/browser/chromeos/login/input_events_blocker.h"
#include "chrome/browser/chromeos/login/login_display_host.h"
#include "chrome/browser/chromeos/login/login_display_host_impl.h"
#include "chrome/browser/chromeos/login/screens/core_oobe_actor.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
......@@ -52,9 +53,9 @@ const char kJsApiNetworkOnTimezoneChanged[] = "networkOnTimezoneChanged";
const char kUSLayout[] = "xkb:us::eng";
const int kDerelectDetectionTimeoutSeconds = 8 * 60 * 60; // 8 hours.
const int kDerelectIdleTimeoutSeconds = 5 * 60; // 5 minutes.
const int kOobeTimerUpdateIntervalSeconds = 5 * 60; // 5 minutes.
const int kDerelectDetectionTimeoutSeconds = 8 * 60 * 60; // 8 hours.
const int kDerelectIdleTimeoutSeconds = 5 * 60; // 5 minutes.
const int kOobeTimerUpdateIntervalSeconds = 5 * 60; // 5 minutes.
// Returns true if element was inserted.
bool InsertString(const std::string& str, std::set<std::string>& to) {
......@@ -220,7 +221,7 @@ void NetworkScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) {
// NetworkScreenHandler, private: ----------------------------------------------
void NetworkScreenHandler::HandleOnExit() {
detector_.reset();
idle_detector_.reset();
ClearErrors();
if (screen_)
screen_->OnContinuePressed();
......@@ -299,13 +300,13 @@ void NetworkScreenHandler::OnSystemTimezoneChanged() {
}
void NetworkScreenHandler::StartIdleDetection() {
if (!detector_.get()) {
detector_.reset(
if (!idle_detector_.get()) {
idle_detector_.reset(
new IdleDetector(base::Closure(),
base::Bind(&NetworkScreenHandler::OnIdle,
weak_ptr_factory_.GetWeakPtr())));
}
detector_->Start(derelict_idle_timeout_);
idle_detector_->Start(derelict_idle_timeout_);
}
void NetworkScreenHandler::StartOobeTimer() {
......
......@@ -8,6 +8,7 @@
#include <string>
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "chrome/browser/chromeos/login/screens/network_screen_actor.h"
......@@ -117,13 +118,13 @@ class NetworkScreenHandler : public NetworkScreenActor,
scoped_ptr<CrosSettings::ObserverSubscription> timezone_subscription_;
scoped_ptr<IdleDetector> detector_;
scoped_ptr<IdleDetector> idle_detector_;
base::RepeatingTimer<NetworkScreenHandler> oobe_timer_;
// Timeout to detect if the machine is in a derelict state.
base::TimeDelta derelict_detection_timeout_;
// Timeout before showing our demo up if the machine is in a derelict state.
// Timeout before showing our demo app if the machine is in a derelict state.
base::TimeDelta derelict_idle_timeout_;
// Time between updating our total time on oobe.
base::TimeDelta oobe_timer_update_interval_;
......
......@@ -1007,6 +1007,7 @@
'browser/chromeos/kiosk_mode/mock_kiosk_mode_settings.h',
'browser/chromeos/login/captive_portal_window_browsertest.cc',
'browser/chromeos/login/crash_restore_browsertest.cc',
'browser/chromeos/login/demo_mode/demo_app_launcher_browsertest.cc',
'browser/chromeos/login/enrollment/enrollment_screen_browsertest.cc',
'browser/chromeos/login/enrollment/mock_enrollment_screen.cc',
'browser/chromeos/login/enrollment/mock_enrollment_screen.h',
......@@ -1040,6 +1041,8 @@
'browser/chromeos/login/screens/network_screen_browsertest.cc',
'browser/chromeos/login/screens/update_screen_browsertest.cc',
'browser/chromeos/login/simple_web_view_dialog_browsertest.cc',
'browser/chromeos/login/test/app_window_waiter.cc',
'browser/chromeos/login/test/app_window_waiter.h',
'browser/chromeos/login/test/https_forwarder.cc',
'browser/chromeos/login/test/https_forwarder.h',
'browser/chromeos/login/test_login_utils.cc',
......
<html>
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8"></meta>
</head>
<body bgcolor="#f00">
<!-- Intentionally blank HTML -->
</body>
</html>
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('html/main.html', {'state': 'fullscreen'});
});
......@@ -18,7 +18,7 @@ const char kAshWebUIInit[] = "ash-webui-init";
// Forces the stub implementation of dbus clients.
const char kDbusStub[] = "dbus-stub";
// Time before a machine at OOBE is considered derelict
// Time before a machine at OOBE is considered derelict.
const char kDerelictDetectionTimeout[] = "derelict-detection-timeout";
// Time before a derelict machines starts demo mode.
......
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