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

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

Issue 816403003: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years 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
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"
(...skipping 17 matching lines...) Expand all
28 weak_ptr_factory_(this) { 28 weak_ptr_factory_(this) {
29 SetupTimeouts(); 29 SetupTimeouts();
30 } 30 }
31 31
32 DemoModeDetector::~DemoModeDetector() { 32 DemoModeDetector::~DemoModeDetector() {
33 } 33 }
34 34
35 // Public methods. 35 // Public methods.
36 36
37 void DemoModeDetector::InitDetection() { 37 void DemoModeDetector::InitDetection() {
38 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableDemoMode)) 38 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
39 switches::kDisableDemoMode))
39 return; 40 return;
40 41
41 if (base::SysInfo::IsRunningOnChromeOS()) { 42 if (base::SysInfo::IsRunningOnChromeOS()) {
42 std::string track; 43 std::string track;
43 // We're running on an actual device; if we cannot find our release track 44 // 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 // value or if the track contains "testimage", don't start demo mode.
45 if (!base::SysInfo::GetLsbReleaseValue("CHROMEOS_RELEASE_TRACK", &track) || 46 if (!base::SysInfo::GetLsbReleaseValue("CHROMEOS_RELEASE_TRACK", &track) ||
46 track.find("testimage") != std::string::npos) 47 track.find("testimage") != std::string::npos)
47 return; 48 return;
48 } 49 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 PrefService* prefs = g_browser_process->local_state(); 98 PrefService* prefs = g_browser_process->local_state();
98 prefs->SetInt64(prefs::kTimeOnOobe, time_on_oobe_.InSeconds()); 99 prefs->SetInt64(prefs::kTimeOnOobe, time_on_oobe_.InSeconds());
99 100
100 if (IsDerelict()) { 101 if (IsDerelict()) {
101 oobe_timer_.Stop(); 102 oobe_timer_.Stop();
102 StartIdleDetection(); 103 StartIdleDetection();
103 } 104 }
104 } 105 }
105 106
106 void DemoModeDetector::SetupTimeouts() { 107 void DemoModeDetector::SetupTimeouts() {
107 CommandLine* cmdline = CommandLine::ForCurrentProcess(); 108 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
108 DCHECK(cmdline); 109 DCHECK(cmdline);
109 110
110 PrefService* prefs = g_browser_process->local_state(); 111 PrefService* prefs = g_browser_process->local_state();
111 time_on_oobe_ = 112 time_on_oobe_ =
112 base::TimeDelta::FromSeconds(prefs->GetInt64(prefs::kTimeOnOobe)); 113 base::TimeDelta::FromSeconds(prefs->GetInt64(prefs::kTimeOnOobe));
113 114
114 int derelict_detection_timeout; 115 int derelict_detection_timeout;
115 if (!cmdline->HasSwitch(switches::kDerelictDetectionTimeout) || 116 if (!cmdline->HasSwitch(switches::kDerelictDetectionTimeout) ||
116 !base::StringToInt( 117 !base::StringToInt(
117 cmdline->GetSwitchValueASCII(switches::kDerelictDetectionTimeout), 118 cmdline->GetSwitchValueASCII(switches::kDerelictDetectionTimeout),
(...skipping 29 matching lines...) Expand all
147 std::max(std::min(oobe_timer_update_interval_, 148 std::max(std::min(oobe_timer_update_interval_,
148 derelict_detection_timeout_ - time_on_oobe_), 149 derelict_detection_timeout_ - time_on_oobe_),
149 base::TimeDelta::FromSeconds(0)); 150 base::TimeDelta::FromSeconds(0));
150 } 151 }
151 152
152 bool DemoModeDetector::IsDerelict() { 153 bool DemoModeDetector::IsDerelict() {
153 return time_on_oobe_ >= derelict_detection_timeout_; 154 return time_on_oobe_ >= derelict_detection_timeout_;
154 } 155 }
155 156
156 } // namespace chromeos 157 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc ('k') | chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698