| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/chromeos/login/demo_mode_detector.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/demo_mode_detector.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_registry_simple.h" | 8 #include "base/prefs/pref_registry_simple.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/sys_info.h" |
| 11 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 13 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 13 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 14 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 15 #include "chromeos/chromeos_switches.h" | 16 #include "chromeos/chromeos_switches.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 const int kDerelectDetectionTimeoutSeconds = 8 * 60 * 60; // 8 hours. | 19 const int kDerelectDetectionTimeoutSeconds = 8 * 60 * 60; // 8 hours. |
| 19 const int kDerelectIdleTimeoutSeconds = 5 * 60; // 5 minutes. | 20 const int kDerelectIdleTimeoutSeconds = 5 * 60; // 5 minutes. |
| 20 const int kOobeTimerUpdateIntervalSeconds = 5 * 60; // 5 minutes. | 21 const int kOobeTimerUpdateIntervalSeconds = 5 * 60; // 5 minutes. |
| 21 } // namespace | 22 } // namespace |
| 22 | 23 |
| 23 namespace chromeos { | 24 namespace chromeos { |
| 24 | 25 |
| 25 DemoModeDetector::DemoModeDetector() | 26 DemoModeDetector::DemoModeDetector() |
| 26 : demo_launched_(false), | 27 : demo_launched_(false), |
| 27 weak_ptr_factory_(this) { | 28 weak_ptr_factory_(this) { |
| 28 SetupTimeouts(); | 29 SetupTimeouts(); |
| 29 } | 30 } |
| 30 | 31 |
| 31 DemoModeDetector::~DemoModeDetector() { | 32 DemoModeDetector::~DemoModeDetector() { |
| 32 } | 33 } |
| 33 | 34 |
| 34 // Public methods. | 35 // Public methods. |
| 35 | 36 |
| 36 void DemoModeDetector::InitDetection() { | 37 void DemoModeDetector::InitDetection() { |
| 38 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableDemoMode)) |
| 39 return; |
| 40 |
| 41 if (base::SysInfo::IsRunningOnChromeOS()) { |
| 42 std::string track; |
| 43 // We're running on an actual device; if we cannot find our release track |
| 44 // value or if the track contains "testimage", don't start demo mode. |
| 45 if (!base::SysInfo::GetLsbReleaseValue("CHROMEOS_RELEASE_TRACK", &track) || |
| 46 track.find("testimage") != std::string::npos) |
| 47 return; |
| 48 } |
| 49 |
| 37 if (IsDerelict()) | 50 if (IsDerelict()) |
| 38 StartIdleDetection(); | 51 StartIdleDetection(); |
| 39 else | 52 else |
| 40 StartOobeTimer(); | 53 StartOobeTimer(); |
| 41 } | 54 } |
| 42 | 55 |
| 43 void DemoModeDetector::StopDetection() { | 56 void DemoModeDetector::StopDetection() { |
| 44 idle_detector_.reset(); | 57 idle_detector_.reset(); |
| 45 } | 58 } |
| 46 | 59 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 std::max(std::min(oobe_timer_update_interval_, | 147 std::max(std::min(oobe_timer_update_interval_, |
| 135 derelict_detection_timeout_ - time_on_oobe_), | 148 derelict_detection_timeout_ - time_on_oobe_), |
| 136 base::TimeDelta::FromSeconds(0)); | 149 base::TimeDelta::FromSeconds(0)); |
| 137 } | 150 } |
| 138 | 151 |
| 139 bool DemoModeDetector::IsDerelict() { | 152 bool DemoModeDetector::IsDerelict() { |
| 140 return time_on_oobe_ >= derelict_detection_timeout_; | 153 return time_on_oobe_ >= derelict_detection_timeout_; |
| 141 } | 154 } |
| 142 | 155 |
| 143 } // namespace chromeos | 156 } // namespace chromeos |
| OLD | NEW |