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 "base/sys_info.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 13 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
14 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | |
15 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
16 #include "chromeos/chromeos_switches.h" | 15 #include "chromeos/chromeos_switches.h" |
17 | 16 |
18 namespace { | 17 namespace { |
19 const int kDerelectDetectionTimeoutSeconds = 8 * 60 * 60; // 8 hours. | 18 const int kDerelectDetectionTimeoutSeconds = 8 * 60 * 60; // 8 hours. |
20 const int kDerelectIdleTimeoutSeconds = 5 * 60; // 5 minutes. | 19 const int kDerelectIdleTimeoutSeconds = 5 * 60; // 5 minutes. |
21 const int kOobeTimerUpdateIntervalSeconds = 5 * 60; // 5 minutes. | 20 const int kOobeTimerUpdateIntervalSeconds = 5 * 60; // 5 minutes. |
22 } // namespace | 21 } // namespace |
23 | 22 |
24 namespace chromeos { | 23 namespace chromeos { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 oobe_timer_.Start(FROM_HERE, | 86 oobe_timer_.Start(FROM_HERE, |
88 oobe_timer_update_interval_, | 87 oobe_timer_update_interval_, |
89 this, | 88 this, |
90 &DemoModeDetector::OnOobeTimerUpdate); | 89 &DemoModeDetector::OnOobeTimerUpdate); |
91 } | 90 } |
92 | 91 |
93 void DemoModeDetector::OnIdle() { | 92 void DemoModeDetector::OnIdle() { |
94 if (demo_launched_) | 93 if (demo_launched_) |
95 return; | 94 return; |
96 demo_launched_ = true; | 95 demo_launched_ = true; |
97 LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); | 96 LoginDisplayHost::default_host()->StartDemoAppLaunch(); |
98 host->StartDemoAppLaunch(); | |
99 } | 97 } |
100 | 98 |
101 void DemoModeDetector::OnOobeTimerUpdate() { | 99 void DemoModeDetector::OnOobeTimerUpdate() { |
102 time_on_oobe_ += oobe_timer_update_interval_; | 100 time_on_oobe_ += oobe_timer_update_interval_; |
103 | 101 |
104 PrefService* prefs = g_browser_process->local_state(); | 102 PrefService* prefs = g_browser_process->local_state(); |
105 prefs->SetInt64(prefs::kTimeOnOobe, time_on_oobe_.InSeconds()); | 103 prefs->SetInt64(prefs::kTimeOnOobe, time_on_oobe_.InSeconds()); |
106 | 104 |
107 if (IsDerelict()) { | 105 if (IsDerelict()) { |
108 oobe_timer_.Stop(); | 106 oobe_timer_.Stop(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 std::max(std::min(oobe_timer_update_interval_, | 152 std::max(std::min(oobe_timer_update_interval_, |
155 derelict_detection_timeout_ - time_on_oobe_), | 153 derelict_detection_timeout_ - time_on_oobe_), |
156 base::TimeDelta::FromSeconds(0)); | 154 base::TimeDelta::FromSeconds(0)); |
157 } | 155 } |
158 | 156 |
159 bool DemoModeDetector::IsDerelict() { | 157 bool DemoModeDetector::IsDerelict() { |
160 return time_on_oobe_ >= derelict_detection_timeout_; | 158 return time_on_oobe_ >= derelict_detection_timeout_; |
161 } | 159 } |
162 | 160 |
163 } // namespace chromeos | 161 } // namespace chromeos |
OLD | NEW |