Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: trunk/src/chrome/browser/ui/webui/chromeos/login/demo_mode_detector.cc

Issue 335643003: Revert 276656 "Flag covering HID-detection OOBE screen removed." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: trunk/src/chrome/browser/ui/webui/chromeos/login/demo_mode_detector.cc
===================================================================
--- trunk/src/chrome/browser/ui/webui/chromeos/login/demo_mode_detector.cc (revision 276694)
+++ trunk/src/chrome/browser/ui/webui/chromeos/login/demo_mode_detector.cc (working copy)
@@ -1,133 +0,0 @@
-// 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/ui/webui/chromeos/login/demo_mode_detector.h"
-
-#include "base/command_line.h"
-#include "base/prefs/pref_service.h"
-#include "base/strings/string_number_conversions.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chromeos/login/ui/login_display_host.h"
-#include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
-#include "chrome/common/pref_names.h"
-#include "chromeos/chromeos_switches.h"
-
-namespace {
- const int kDerelectDetectionTimeoutSeconds = 8 * 60 * 60; // 8 hours.
- const int kDerelectIdleTimeoutSeconds = 5 * 60; // 5 minutes.
- const int kOobeTimerUpdateIntervalSeconds = 5 * 60; // 5 minutes.
-} // namespace
-
-namespace chromeos {
-
-DemoModeDetector::DemoModeDetector()
- : demo_launched_(false),
- weak_ptr_factory_(this) {
- SetupTimeouts();
-}
-
-DemoModeDetector::~DemoModeDetector() {
-}
-
-void DemoModeDetector::InitDetection() {
- if (IsDerelict())
- StartIdleDetection();
- else
- StartOobeTimer();
-}
-
-void DemoModeDetector::StopDetection() {
- idle_detector_.reset();
-}
-
-void DemoModeDetector::StartIdleDetection() {
- if (!idle_detector_.get()) {
- idle_detector_.reset(
- new IdleDetector(base::Closure(),
- base::Bind(&DemoModeDetector::OnIdle,
- weak_ptr_factory_.GetWeakPtr())));
- }
- idle_detector_->Start(derelict_idle_timeout_);
-}
-
-void DemoModeDetector::StartOobeTimer() {
- if (oobe_timer_.IsRunning())
- return;
- oobe_timer_.Start(FROM_HERE,
- oobe_timer_update_interval_,
- this,
- &DemoModeDetector::OnOobeTimerUpdate);
-}
-
-void DemoModeDetector::OnIdle() {
- if (demo_launched_)
- return;
- demo_launched_ = true;
- LoginDisplayHost* host = LoginDisplayHostImpl::default_host();
- host->StartDemoAppLaunch();
-}
-
-void DemoModeDetector::OnOobeTimerUpdate() {
- time_on_oobe_ += oobe_timer_update_interval_;
-
- PrefService* prefs = g_browser_process->local_state();
- prefs->SetInt64(prefs::kTimeOnOobe, time_on_oobe_.InSeconds());
-
- if (IsDerelict()) {
- oobe_timer_.Stop();
- StartIdleDetection();
- }
-}
-
-void DemoModeDetector::SetupTimeouts() {
- CommandLine* cmdline = CommandLine::ForCurrentProcess();
- DCHECK(cmdline);
-
- PrefService* prefs = g_browser_process->local_state();
- time_on_oobe_ =
- base::TimeDelta::FromSeconds(prefs->GetInt64(prefs::kTimeOnOobe));
-
- int derelict_detection_timeout;
- if (!cmdline->HasSwitch(switches::kDerelictDetectionTimeout) ||
- !base::StringToInt(
- cmdline->GetSwitchValueASCII(switches::kDerelictDetectionTimeout),
- &derelict_detection_timeout)) {
- derelict_detection_timeout = kDerelectDetectionTimeoutSeconds;
- }
- derelict_detection_timeout_ =
- base::TimeDelta::FromSeconds(derelict_detection_timeout);
-
- int derelict_idle_timeout;
- if (!cmdline->HasSwitch(switches::kDerelictIdleTimeout) ||
- !base::StringToInt(
- cmdline->GetSwitchValueASCII(switches::kDerelictIdleTimeout),
- &derelict_idle_timeout)) {
- derelict_idle_timeout = kDerelectIdleTimeoutSeconds;
- }
- derelict_idle_timeout_ = base::TimeDelta::FromSeconds(derelict_idle_timeout);
-
-
- int oobe_timer_update_interval;
- if (!cmdline->HasSwitch(switches::kOobeTimerInterval) ||
- !base::StringToInt(
- cmdline->GetSwitchValueASCII(switches::kOobeTimerInterval),
- &oobe_timer_update_interval)) {
- oobe_timer_update_interval = kOobeTimerUpdateIntervalSeconds;
- }
- oobe_timer_update_interval_ =
- base::TimeDelta::FromSeconds(oobe_timer_update_interval);
-
- // In case we'd be derelict before our timer is set to trigger, reduce
- // the interval so we check again when we're scheduled to go derelict.
- oobe_timer_update_interval_ =
- std::max(std::min(oobe_timer_update_interval_,
- derelict_detection_timeout_ - time_on_oobe_),
- base::TimeDelta::FromSeconds(0));
-}
-
-bool DemoModeDetector::IsDerelict() {
- return time_on_oobe_ >= derelict_detection_timeout_;
-}
-
-} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698