forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to show a demo app on OOBE if a machine is derelict.
If a machine has been idle for 8 hours+, we should start showing a demo app everytime the machine is idle for 5 minutes. This CL depends on https://chrome-internal-review.googlesource.com/#/c/154276/ R=xiyuan@chromium.org, zelidrag@chromium.org BUG=336585 TEST=Use the derelict-* flags to test demo mode app launching. Review URL: https://codereview.chromium.org/156493004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250666 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
rkc@chromium.org
committed
Feb 12, 2014
1 parent
8315a7e
commit eed749b
Showing
29 changed files
with
388 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// 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/idle_detector.h" | ||
|
||
#include "ash/shell.h" | ||
#include "ash/wm/user_activity_detector.h" | ||
#include "base/bind.h" | ||
#include "base/logging.h" | ||
|
||
namespace chromeos { | ||
|
||
IdleDetector::IdleDetector(const base::Closure& on_active_callback, | ||
const base::Closure& on_idle_callback) | ||
: active_callback_(on_active_callback), idle_callback_(on_idle_callback) {} | ||
|
||
IdleDetector::~IdleDetector() { | ||
if (ash::Shell::HasInstance() && | ||
ash::Shell::GetInstance()->user_activity_detector()->HasObserver(this)) | ||
ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this); | ||
} | ||
|
||
void IdleDetector::OnUserActivity(const ui::Event* event) { | ||
if (!active_callback_.is_null()) | ||
active_callback_.Run(); | ||
ResetTimer(); | ||
} | ||
|
||
void IdleDetector::Start(const base::TimeDelta& timeout) { | ||
timeout_ = timeout; | ||
if (!ash::Shell::GetInstance()->user_activity_detector()->HasObserver(this)) | ||
ash::Shell::GetInstance()->user_activity_detector()->AddObserver(this); | ||
ResetTimer(); | ||
} | ||
|
||
void IdleDetector::ResetTimer() { | ||
if (timer_.IsRunning()) { | ||
timer_.Reset(); | ||
} else { | ||
timer_.Start(FROM_HERE, timeout_, idle_callback_); | ||
} | ||
} | ||
|
||
} // namespace chromeos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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_IDLE_DETECTOR_H_ | ||
#define CHROME_BROWSER_CHROMEOS_IDLE_DETECTOR_H_ | ||
|
||
#include "ash/wm/user_activity_observer.h" | ||
#include "base/basictypes.h" | ||
#include "base/compiler_specific.h" | ||
#include "base/timer/timer.h" | ||
|
||
namespace chromeos { | ||
|
||
class IdleDetector : public ash::UserActivityObserver { | ||
public: | ||
IdleDetector(const base::Closure& on_active_callback, | ||
const base::Closure& on_idle_callback); | ||
virtual ~IdleDetector(); | ||
|
||
void Start(const base::TimeDelta& timeout); | ||
|
||
private: | ||
// UserActivityObserver overrides: | ||
virtual void OnUserActivity(const ui::Event* event) OVERRIDE; | ||
|
||
// Resets |timer_| to fire when we reach our idle timeout. | ||
void ResetTimer(); | ||
|
||
base::OneShotTimer<IdleDetector> timer_; | ||
|
||
base::Closure active_callback_; | ||
base::Closure idle_callback_; | ||
|
||
base::TimeDelta timeout_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(IdleDetector); | ||
}; | ||
|
||
} // namespace chromeos | ||
|
||
#endif // CHROME_BROWSER_CHROMEOS_IDLE_DETECTOR_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
chrome/browser/chromeos/login/demo_mode/demo_app_launcher.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// 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/demo_mode/demo_app_launcher.h" | ||
|
||
#include "base/command_line.h" | ||
#include "chrome/browser/chromeos/app_mode/app_session_lifetime.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/ui/extensions/application_launch.h" | ||
#include "chrome/common/chrome_switches.h" | ||
#include "extensions/browser/extension_system.h" | ||
#include "grit/browser_resources.h" | ||
|
||
namespace { | ||
|
||
const char kDemoAppUserId[] = "demouser@demo.app.local"; | ||
|
||
} | ||
|
||
namespace chromeos { | ||
|
||
DemoAppLauncher::DemoAppLauncher() : profile_(NULL) {} | ||
|
||
DemoAppLauncher::~DemoAppLauncher() {} | ||
|
||
void DemoAppLauncher::StartDemoAppLaunch() { | ||
DVLOG(1) << "Launching demo app..."; | ||
// user_id = DemoAppUserId, force_emphemeral = true, delegate = this. | ||
kiosk_profile_loader_.reset( | ||
new KioskProfileLoader(kDemoAppUserId, true, this)); | ||
kiosk_profile_loader_->Start(); | ||
} | ||
|
||
// static | ||
bool DemoAppLauncher::IsDemoAppSession(const std::string& user_id) { | ||
return user_id == kDemoAppUserId ? true : false; | ||
} | ||
|
||
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( | ||
IDR_DEMO_APP_MANIFEST, | ||
base::FilePath("/usr/share/chromeos-assets/demo_app")); | ||
|
||
const extensions::Extension* extension = | ||
extension_service->GetExtensionById(extension_id, true); | ||
|
||
CommandLine* command_line = CommandLine::ForCurrentProcess(); | ||
command_line->AppendSwitch(switches::kForceAppMode); | ||
command_line->AppendSwitchASCII(switches::kAppId, extension_id); | ||
|
||
OpenApplication(AppLaunchParams( | ||
profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW)); | ||
InitAppSession(profile_, extension_id); | ||
|
||
UserManager::Get()->SessionStarted(); | ||
|
||
LoginDisplayHostImpl::default_host()->Finalize(); | ||
} | ||
|
||
void DemoAppLauncher::OnProfileLoadFailed(KioskAppLaunchError::Error error) { | ||
LOG(ERROR) << "Loading the Kiosk Profile failed."; | ||
} | ||
|
||
} // namespace chromeos |
38 changes: 38 additions & 0 deletions
38
chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// 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_DEMO_MODE_DEMO_APP_LAUNCHER_H_ | ||
#define CHROME_BROWSER_CHROMEOS_LOGIN_DEMO_MODE_DEMO_APP_LAUNCHER_H_ | ||
|
||
#include "base/memory/scoped_ptr.h" | ||
#include "chrome/browser/chromeos/app_mode/kiosk_profile_loader.h" | ||
|
||
class Profile; | ||
|
||
namespace chromeos { | ||
|
||
// Class responsible for launching the demo app under a kiosk session. | ||
class DemoAppLauncher : public KioskProfileLoader::Delegate { | ||
public: | ||
DemoAppLauncher(); | ||
virtual ~DemoAppLauncher(); | ||
|
||
void StartDemoAppLaunch(); | ||
|
||
static bool IsDemoAppSession(const std::string& user_id); | ||
|
||
private: | ||
// KioskProfileLoader::Delegate overrides: | ||
virtual void OnProfileLoaded(Profile* profile) OVERRIDE; | ||
virtual void OnProfileLoadFailed(KioskAppLaunchError::Error error) OVERRIDE; | ||
|
||
Profile* profile_; | ||
scoped_ptr<KioskProfileLoader> kiosk_profile_loader_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(DemoAppLauncher); | ||
}; | ||
|
||
} // namespace chromeos | ||
|
||
#endif // CHROME_BROWSER_CHROMEOS_LOGIN_DEMO_MODE_DEMO_APP_LAUNCHER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.