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 if (base::SysInfo::IsRunningOnChromeOS()) { | |
xiyuan
2014/08/28 19:25:51
nit: insert an empty line before this line
rkc
2014/08/28 19:38:19
Done.
| |
41 std::string track; | |
42 // We're running on an actual device; if we cannot find our release track | |
43 // value or if the track contains "testimage", don't start demo mode. | |
44 if (!base::SysInfo::GetLsbReleaseValue("CHROMEOS_RELEASE_TRACK", &track) || | |
45 track.find("testimage") != std::string::npos) | |
46 return; | |
47 } | |
48 | |
37 if (IsDerelict()) | 49 if (IsDerelict()) |
38 StartIdleDetection(); | 50 StartIdleDetection(); |
39 else | 51 else |
40 StartOobeTimer(); | 52 StartOobeTimer(); |
41 } | 53 } |
42 | 54 |
43 void DemoModeDetector::StopDetection() { | 55 void DemoModeDetector::StopDetection() { |
44 idle_detector_.reset(); | 56 idle_detector_.reset(); |
45 } | 57 } |
46 | 58 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 std::max(std::min(oobe_timer_update_interval_, | 146 std::max(std::min(oobe_timer_update_interval_, |
135 derelict_detection_timeout_ - time_on_oobe_), | 147 derelict_detection_timeout_ - time_on_oobe_), |
136 base::TimeDelta::FromSeconds(0)); | 148 base::TimeDelta::FromSeconds(0)); |
137 } | 149 } |
138 | 150 |
139 bool DemoModeDetector::IsDerelict() { | 151 bool DemoModeDetector::IsDerelict() { |
140 return time_on_oobe_ >= derelict_detection_timeout_; | 152 return time_on_oobe_ >= derelict_detection_timeout_; |
141 } | 153 } |
142 | 154 |
143 } // namespace chromeos | 155 } // namespace chromeos |
OLD | NEW |