OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chromeos/system/screen_locker_settings.h" | 5 #include "chrome/browser/chromeos/system/screen_locker_settings.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/chromeos/chromeos_version.h" |
8 #include "base/file_path.h" | 9 #include "base/file_path.h" |
9 #include "base/file_util.h" | 10 #include "base/file_util.h" |
10 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
11 #include "chrome/browser/chromeos/system/runtime_environment.h" | |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 | 13 |
14 using content::BrowserThread; | 14 using content::BrowserThread; |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 const char kLockOnIdleSuspendPath[] = | 18 const char kLockOnIdleSuspendPath[] = |
19 "/var/lib/power_manager/lock_on_idle_suspend"; | 19 "/var/lib/power_manager/lock_on_idle_suspend"; |
20 | 20 |
21 void EnableScreenLockOnFileThread(bool enable) { | 21 void EnableScreenLockOnFileThread(bool enable) { |
22 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 22 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
23 | 23 |
24 if (chromeos::system::runtime_environment::IsRunningOnChromeOS()) { | 24 if (base::chromeos::IsRunningOnChromeOS()) { |
25 std::string config = base::StringPrintf("%d", enable); | 25 std::string config = base::StringPrintf("%d", enable); |
26 file_util::WriteFile(FilePath(kLockOnIdleSuspendPath), | 26 file_util::WriteFile(FilePath(kLockOnIdleSuspendPath), |
27 config.c_str(), | 27 config.c_str(), |
28 config.size()); | 28 config.size()); |
29 } | 29 } |
30 } | 30 } |
31 | 31 |
32 } // namespace | 32 } // namespace |
33 | 33 |
34 namespace chromeos { | 34 namespace chromeos { |
35 namespace system { | 35 namespace system { |
36 namespace screen_locker_settings { | 36 namespace screen_locker_settings { |
37 | 37 |
38 void EnableScreenLock(bool enable) { | 38 void EnableScreenLock(bool enable) { |
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
40 | 40 |
41 // Run this on the FILE thread. | 41 // Run this on the FILE thread. |
42 BrowserThread::PostTask( | 42 BrowserThread::PostTask( |
43 BrowserThread::FILE, FROM_HERE, | 43 BrowserThread::FILE, FROM_HERE, |
44 base::Bind(&EnableScreenLockOnFileThread, enable)); | 44 base::Bind(&EnableScreenLockOnFileThread, enable)); |
45 } | 45 } |
46 | 46 |
47 } // namespace screen_locker_settings | 47 } // namespace screen_locker_settings |
48 } // namespace system | 48 } // namespace system |
49 } // namespace chromeos | 49 } // namespace chromeos |
OLD | NEW |