Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/demo_mode_detector.cc

Issue 514273003: Check for channel and flag before allowing demo mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698