Chromium Code Reviews| Index: chrome/browser/chromeos/system/screen_locker_settings.cc |
| diff --git a/chrome/browser/chromeos/system/screen_locker_settings.cc b/chrome/browser/chromeos/system/screen_locker_settings.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..89ed954bd1b8af4fc78ac736ab5f38d9aff3c9fd |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/system/screen_locker_settings.cc |
| @@ -0,0 +1,52 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/chromeos/system/touchpad_settings.h" |
| + |
| +#include "base/bind.h" |
| +#include "base/file_path.h" |
| +#include "base/file_util.h" |
| +#include "base/stringprintf.h" |
| +#include "chrome/browser/chromeos/system/runtime_environment.h" |
| +#include "content/public/browser/browser_thread.h" |
| + |
| +using content::BrowserThread; |
| + |
| +namespace { |
| + |
| +const char kLockOnIdleSuspendPath[] = |
| + "/var/lib/power_manager/lock_on_idle_suspend"; |
| + |
| +void EnableScreenLockOnFileThread(bool enable) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE); |
| + |
| + if (system::runtime_environment::IsRunningOnChromeOS()) { |
| + std::string config = base::StringPrintf("%d", enable); |
| + file_util::WriteFile(FilePath(kLockOnIdleSuspendPath), |
| + config.c_str(), |
| + config.size()); |
| + } |
| +} |
| + |
| +} // namespace |
| + |
| +namespace chromeos { |
| +namespace system { |
| +namespace screen_locker_settings { |
| + |
| +void EnableScreenLock(bool enable) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + |
| + // Run this on the FILE thread. |
| + if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { |
|
satorux1
2011/11/18 19:11:48
Please remove this line. We know that we are on UI
Simon Que
2011/11/18 19:33:16
Done.
|
| + BrowserThread::PostTask( |
| + BrowserThread::FILE, FROM_HERE, |
| + base::Bind(&EnableScreenLockOnFileThread, enable)); |
| + return; |
| + } |
| +} |
| + |
| +} // namespace screen_locker_settings |
| +} // namespace system |
| +} // namespace chromeos |