| OLD | NEW |
| (Empty) |
| 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 <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "base/time/time.h" | |
| 14 #include "base/timer/timer.h" | |
| 15 #include "chrome/browser/chromeos/idle_detector.h" | |
| 16 | |
| 17 class PrefRegistrySimple; | |
| 18 | |
| 19 namespace chromeos { | |
| 20 | |
| 21 // Helper for idle state and demo-mode detection. | |
| 22 // Should be initialized on OOBE start. | |
| 23 class DemoModeDetector { | |
| 24 public: | |
| 25 DemoModeDetector(); | |
| 26 virtual ~DemoModeDetector(); | |
| 27 | |
| 28 void InitDetection(); | |
| 29 void StopDetection(); | |
| 30 | |
| 31 // Registers the preference for derelict state. | |
| 32 static void RegisterPrefs(PrefRegistrySimple* registry); | |
| 33 | |
| 34 private: | |
| 35 void StartIdleDetection(); | |
| 36 void StartOobeTimer(); | |
| 37 void OnIdle(); | |
| 38 void OnOobeTimerUpdate(); | |
| 39 void SetupTimeouts(); | |
| 40 bool IsDerelict(); | |
| 41 | |
| 42 // Total time this machine has spent on OOBE. | |
| 43 base::TimeDelta time_on_oobe_; | |
| 44 | |
| 45 std::unique_ptr<IdleDetector> idle_detector_; | |
| 46 | |
| 47 base::RepeatingTimer oobe_timer_; | |
| 48 | |
| 49 // Timeout to detect if the machine is in a derelict state. | |
| 50 base::TimeDelta derelict_detection_timeout_; | |
| 51 | |
| 52 // Timeout before showing our demo app if the machine is in a derelict state. | |
| 53 base::TimeDelta derelict_idle_timeout_; | |
| 54 | |
| 55 // Time between updating our total time on oobe. | |
| 56 base::TimeDelta oobe_timer_update_interval_; | |
| 57 | |
| 58 bool demo_launched_; | |
| 59 | |
| 60 base::WeakPtrFactory<DemoModeDetector> weak_ptr_factory_; | |
| 61 | |
| 62 DISALLOW_COPY_AND_ASSIGN(DemoModeDetector); | |
| 63 }; | |
| 64 | |
| 65 } // namespace chromeos | |
| 66 | |
| 67 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_DEMO_MODE_DETECTOR_H_ | |
| OLD | NEW |