1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DEMO_MODE_DETECTOR_H_ 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DEMO_MODE_DETECTOR_H_ 7 8 #include <string> 9 10 #include "base/memory/weak_ptr.h" 11 #include "base/time/time.h" 12 #include "base/timer/timer.h" 13 #include "chrome/browser/chromeos/idle_detector.h" 14 15 namespace chromeos { 16 17 // Helper for idle state and demo-mode detection. 18 // Should be initialized on OOBE start. 19 class DemoModeDetector { 20 public: 21 DemoModeDetector(); 22 virtual ~DemoModeDetector(); 23 24 void InitDetection(); 25 void StopDetection(); 26 27 private: 28 void StartIdleDetection(); 29 void StartOobeTimer(); 30 void OnIdle(); 31 void OnOobeTimerUpdate(); 32 void SetupTimeouts(); 33 bool IsDerelict(); 34 35 // Total time this machine has spent on OOBE. 36 base::TimeDelta time_on_oobe_; 37 38 scoped_ptr<IdleDetector> idle_detector_; 39 40 base::RepeatingTimer<DemoModeDetector> oobe_timer_; 41 42 // Timeout to detect if the machine is in a derelict state. 43 base::TimeDelta derelict_detection_timeout_; 44 45 // Timeout before showing our demo app if the machine is in a derelict state. 46 base::TimeDelta derelict_idle_timeout_; 47 48 // Time between updating our total time on oobe. 49 base::TimeDelta oobe_timer_update_interval_; 50 51 bool demo_launched_; 52 53 base::WeakPtrFactory<DemoModeDetector> weak_ptr_factory_; 54 55 DISALLOW_COPY_AND_ASSIGN(DemoModeDetector); 56 }; 57 58 } // namespace chromeos 59 60 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DEMO_MODE_DETECTOR_H_ 61