summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/BUILD.gn3
-rw-r--r--chrome/browser/browser_process_impl.cc4
-rw-r--r--chrome/browser/chromeos/policy/device_status_collector.cc4
-rw-r--r--chrome/browser/chromeos/policy/device_status_collector.h4
-rw-r--r--chrome/browser/chromeos/policy/device_status_collector_browsertest.cc114
-rw-r--r--chrome/browser/extensions/api/idle/idle_api.cc2
-rw-r--r--chrome/browser/extensions/api/idle/idle_api.h4
-rw-r--r--chrome/browser/extensions/api/idle/idle_api_unittest.cc66
-rw-r--r--chrome/browser/extensions/api/idle/idle_manager.cc42
-rw-r--r--chrome/browser/extensions/api/idle/idle_manager.h18
-rw-r--r--chrome/browser/notifications/screen_lock_notification_blocker.cc4
-rw-r--r--chrome/browser/upgrade_detector.cc10
-rw-r--r--chrome/browser/upgrade_detector.h4
-rw-r--r--chrome/chrome_browser.gypi17
-rw-r--r--ui/base/BUILD.gn25
-rw-r--r--ui/base/idle/DEPS4
-rw-r--r--ui/base/idle/idle.cc (renamed from chrome/browser/idle.cc)5
-rw-r--r--ui/base/idle/idle.h (renamed from chrome/browser/idle.h)19
-rw-r--r--ui/base/idle/idle_chromeos.cc (renamed from chrome/browser/idle_chromeos.cc)6
-rw-r--r--ui/base/idle/idle_linux.cc (renamed from chrome/browser/idle_linux.cc)24
-rw-r--r--ui/base/idle/idle_mac.mm (renamed from chrome/browser/idle_mac.mm)9
-rw-r--r--ui/base/idle/idle_query_x11.cc (renamed from chrome/browser/idle_query_x11.cc)7
-rw-r--r--ui/base/idle/idle_query_x11.h (renamed from chrome/browser/idle_query_x11.h)10
-rw-r--r--ui/base/idle/idle_win.cc (renamed from chrome/browser/idle_win.cc)5
-rw-r--r--ui/base/idle/screensaver_window_finder_x11.cc (renamed from chrome/browser/screensaver_window_finder_x11.cc)6
-rw-r--r--ui/base/idle/screensaver_window_finder_x11.h (renamed from chrome/browser/screensaver_window_finder_x11.h)9
-rw-r--r--ui/base/ui_base.gyp24
27 files changed, 255 insertions, 194 deletions
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index faea696..535ea98 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -485,9 +485,6 @@ static_library("browser") {
if (use_x11) {
sources +=
rebase_path(gypi_values.chrome_browser_x11_sources, ".", "//chrome")
- if (!is_chromeos) {
- configs += [ "//build/config/linux:xscrnsaver" ]
- }
}
if (is_posix && !is_mac && !is_ios) {
sources += [
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 1f70dfd..880cf06 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -36,7 +36,6 @@
#include "chrome/browser/gpu/gl_string_manager.h"
#include "chrome/browser/gpu/gpu_mode_manager.h"
#include "chrome/browser/icon_manager.h"
-#include "chrome/browser/idle.h"
#include "chrome/browser/intranet_redirect_detector.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/lifetime/application_lifetime.h"
@@ -92,6 +91,7 @@
#include "extensions/common/constants.h"
#include "net/socket/client_socket_pool_manager.h"
#include "net/url_request/url_request_context_getter.h"
+#include "ui/base/idle/idle.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/message_center/message_center.h"
@@ -195,7 +195,7 @@ BrowserProcessImpl::BrowserProcessImpl(
chrome::kChromeSearchScheme);
#if defined(OS_MACOSX)
- InitIdleMonitor();
+ ui::InitIdleMonitor();
#endif
#if !defined(OS_ANDROID)
diff --git a/chrome/browser/chromeos/policy/device_status_collector.cc b/chrome/browser/chromeos/policy/device_status_collector.cc
index 4c2d631..9378b58 100644
--- a/chrome/browser/chromeos/policy/device_status_collector.cc
+++ b/chrome/browser/chromeos/policy/device_status_collector.cc
@@ -356,14 +356,14 @@ void DeviceStatusCollector::ClearCachedHardwareStatus() {
cpu_usage_percent_.clear();
}
-void DeviceStatusCollector::IdleStateCallback(IdleState state) {
+void DeviceStatusCollector::IdleStateCallback(ui::IdleState state) {
// Do nothing if device activity reporting is disabled.
if (!report_activity_times_)
return;
Time now = GetCurrentTime();
- if (state == IDLE_STATE_ACTIVE) {
+ if (state == ui::IDLE_STATE_ACTIVE) {
// If it's been too long since the last report, or if the activity is
// negative (which can happen when the clock changes), assume a single
// interval of activity.
diff --git a/chrome/browser/chromeos/policy/device_status_collector.h b/chrome/browser/chromeos/policy/device_status_collector.h
index df6b345..0780cff 100644
--- a/chrome/browser/chromeos/policy/device_status_collector.h
+++ b/chrome/browser/chromeos/policy/device_status_collector.h
@@ -20,12 +20,12 @@
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
-#include "chrome/browser/idle.h"
#include "chromeos/system/version_loader.h"
#include "components/policy/core/common/cloud/cloud_policy_client.h"
#include "content/public/browser/geolocation_provider.h"
#include "content/public/common/geoposition.h"
#include "policy/proto/device_management_backend.pb.h"
+#include "ui/base/idle/idle.h"
namespace chromeos {
class CrosSettings;
@@ -89,7 +89,7 @@ class DeviceStatusCollector : public CloudPolicyClient::StatusProvider {
virtual base::Time GetCurrentTime();
// Callback which receives the results of the idle state check.
- void IdleStateCallback(IdleState state);
+ void IdleStateCallback(ui::IdleState state);
// Samples the current CPU usage and updates our cache of samples.
void SampleCPUUsage();
diff --git a/chrome/browser/chromeos/policy/device_status_collector_browsertest.cc b/chrome/browser/chromeos/policy/device_status_collector_browsertest.cc
index 7bc7371..178c3ba 100644
--- a/chrome/browser/chromeos/policy/device_status_collector_browsertest.cc
+++ b/chrome/browser/chromeos/policy/device_status_collector_browsertest.cc
@@ -99,7 +99,7 @@ class TestingDeviceStatusCollector : public policy::DeviceStatusCollector {
SetBaselineTime(Time::Now().LocalMidnight() + TimeDelta::FromHours(1));
}
- void Simulate(IdleState* states, int len) {
+ void Simulate(ui::IdleState* states, int len) {
for (int i = 0; i < len; i++)
IdleStateCallback(states[i]);
}
@@ -354,10 +354,10 @@ class DeviceStatusCollectorTest : public testing::Test {
};
TEST_F(DeviceStatusCollectorTest, AllIdle) {
- IdleState test_states[] = {
- IDLE_STATE_IDLE,
- IDLE_STATE_IDLE,
- IDLE_STATE_IDLE
+ ui::IdleState test_states[] = {
+ ui::IDLE_STATE_IDLE,
+ ui::IDLE_STATE_IDLE,
+ ui::IDLE_STATE_IDLE
};
cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true);
@@ -374,17 +374,17 @@ TEST_F(DeviceStatusCollectorTest, AllIdle) {
// Test reporting with multiple consecutive idle samples.
status_collector_->Simulate(test_states,
- sizeof(test_states) / sizeof(IdleState));
+ sizeof(test_states) / sizeof(ui::IdleState));
GetStatus();
EXPECT_EQ(0, status_.active_period_size());
EXPECT_EQ(0, GetActiveMilliseconds(status_));
}
TEST_F(DeviceStatusCollectorTest, AllActive) {
- IdleState test_states[] = {
- IDLE_STATE_ACTIVE,
- IDLE_STATE_ACTIVE,
- IDLE_STATE_ACTIVE
+ ui::IdleState test_states[] = {
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_ACTIVE
};
cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true);
@@ -397,73 +397,73 @@ TEST_F(DeviceStatusCollectorTest, AllActive) {
// Test multiple consecutive active samples.
status_collector_->Simulate(test_states,
- sizeof(test_states) / sizeof(IdleState));
+ sizeof(test_states) / sizeof(ui::IdleState));
GetStatus();
EXPECT_EQ(1, status_.active_period_size());
EXPECT_EQ(4 * ActivePeriodMilliseconds(), GetActiveMilliseconds(status_));
}
TEST_F(DeviceStatusCollectorTest, MixedStates) {
- IdleState test_states[] = {
- IDLE_STATE_ACTIVE,
- IDLE_STATE_IDLE,
- IDLE_STATE_ACTIVE,
- IDLE_STATE_ACTIVE,
- IDLE_STATE_IDLE,
- IDLE_STATE_IDLE,
- IDLE_STATE_ACTIVE
+ ui::IdleState test_states[] = {
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_IDLE,
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_IDLE,
+ ui::IDLE_STATE_IDLE,
+ ui::IDLE_STATE_ACTIVE
};
cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true);
status_collector_->Simulate(test_states,
- sizeof(test_states) / sizeof(IdleState));
+ sizeof(test_states) / sizeof(ui::IdleState));
GetStatus();
EXPECT_EQ(4 * ActivePeriodMilliseconds(), GetActiveMilliseconds(status_));
}
TEST_F(DeviceStatusCollectorTest, StateKeptInPref) {
- IdleState test_states[] = {
- IDLE_STATE_ACTIVE,
- IDLE_STATE_IDLE,
- IDLE_STATE_ACTIVE,
- IDLE_STATE_ACTIVE,
- IDLE_STATE_IDLE,
- IDLE_STATE_IDLE
+ ui::IdleState test_states[] = {
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_IDLE,
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_IDLE,
+ ui::IDLE_STATE_IDLE
};
cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true);
status_collector_->Simulate(test_states,
- sizeof(test_states) / sizeof(IdleState));
+ sizeof(test_states) / sizeof(ui::IdleState));
// Process the list a second time after restarting the collector. It should be
// able to count the active periods found by the original collector, because
// the results are stored in a pref.
RestartStatusCollector(base::Bind(&GetEmptyVolumeInfo));
status_collector_->Simulate(test_states,
- sizeof(test_states) / sizeof(IdleState));
+ sizeof(test_states) / sizeof(ui::IdleState));
GetStatus();
EXPECT_EQ(6 * ActivePeriodMilliseconds(), GetActiveMilliseconds(status_));
}
TEST_F(DeviceStatusCollectorTest, Times) {
- IdleState test_states[] = {
- IDLE_STATE_ACTIVE,
- IDLE_STATE_IDLE,
- IDLE_STATE_ACTIVE,
- IDLE_STATE_ACTIVE,
- IDLE_STATE_IDLE,
- IDLE_STATE_IDLE
+ ui::IdleState test_states[] = {
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_IDLE,
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_IDLE,
+ ui::IDLE_STATE_IDLE
};
cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true);
status_collector_->Simulate(test_states,
- sizeof(test_states) / sizeof(IdleState));
+ sizeof(test_states) / sizeof(ui::IdleState));
GetStatus();
EXPECT_EQ(3 * ActivePeriodMilliseconds(), GetActiveMilliseconds(status_));
}
TEST_F(DeviceStatusCollectorTest, MaxStoredPeriods) {
- IdleState test_states[] = {
- IDLE_STATE_ACTIVE,
- IDLE_STATE_IDLE
+ ui::IdleState test_states[] = {
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_IDLE
};
const int kMaxDays = 10;
@@ -475,7 +475,7 @@ TEST_F(DeviceStatusCollectorTest, MaxStoredPeriods) {
// Simulate 12 active periods.
for (int i = 0; i < kMaxDays + 2; i++) {
status_collector_->Simulate(test_states,
- sizeof(test_states) / sizeof(IdleState));
+ sizeof(test_states) / sizeof(ui::IdleState));
// Advance the simulated clock by a day.
baseline += TimeDelta::FromDays(1);
status_collector_->SetBaselineTime(baseline);
@@ -488,7 +488,7 @@ TEST_F(DeviceStatusCollectorTest, MaxStoredPeriods) {
// Simulate some future times.
for (int i = 0; i < kMaxDays + 2; i++) {
status_collector_->Simulate(test_states,
- sizeof(test_states) / sizeof(IdleState));
+ sizeof(test_states) / sizeof(ui::IdleState));
// Advance the simulated clock by a day.
baseline += TimeDelta::FromDays(1);
status_collector_->SetBaselineTime(baseline);
@@ -508,13 +508,13 @@ TEST_F(DeviceStatusCollectorTest, MaxStoredPeriods) {
TEST_F(DeviceStatusCollectorTest, ActivityTimesEnabledByDefault) {
// Device activity times should be reported by default.
- IdleState test_states[] = {
- IDLE_STATE_ACTIVE,
- IDLE_STATE_ACTIVE,
- IDLE_STATE_ACTIVE
+ ui::IdleState test_states[] = {
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_ACTIVE
};
status_collector_->Simulate(test_states,
- sizeof(test_states) / sizeof(IdleState));
+ sizeof(test_states) / sizeof(ui::IdleState));
GetStatus();
EXPECT_EQ(1, status_.active_period_size());
EXPECT_EQ(3 * ActivePeriodMilliseconds(), GetActiveMilliseconds(status_));
@@ -524,21 +524,21 @@ TEST_F(DeviceStatusCollectorTest, ActivityTimesOff) {
// Device activity times should not be reported if explicitly disabled.
cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, false);
- IdleState test_states[] = {
- IDLE_STATE_ACTIVE,
- IDLE_STATE_ACTIVE,
- IDLE_STATE_ACTIVE
+ ui::IdleState test_states[] = {
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_ACTIVE
};
status_collector_->Simulate(test_states,
- sizeof(test_states) / sizeof(IdleState));
+ sizeof(test_states) / sizeof(ui::IdleState));
GetStatus();
EXPECT_EQ(0, status_.active_period_size());
EXPECT_EQ(0, GetActiveMilliseconds(status_));
}
TEST_F(DeviceStatusCollectorTest, ActivityCrossingMidnight) {
- IdleState test_states[] = {
- IDLE_STATE_ACTIVE
+ ui::IdleState test_states[] = {
+ ui::IDLE_STATE_ACTIVE
};
cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true);
@@ -568,9 +568,9 @@ TEST_F(DeviceStatusCollectorTest, ActivityCrossingMidnight) {
}
TEST_F(DeviceStatusCollectorTest, ActivityTimesKeptUntilSubmittedSuccessfully) {
- IdleState test_states[] = {
- IDLE_STATE_ACTIVE,
- IDLE_STATE_ACTIVE,
+ ui::IdleState test_states[] = {
+ ui::IDLE_STATE_ACTIVE,
+ ui::IDLE_STATE_ACTIVE,
};
cros_settings_->SetBoolean(chromeos::kReportDeviceActivityTimes, true);
diff --git a/chrome/browser/extensions/api/idle/idle_api.cc b/chrome/browser/extensions/api/idle/idle_api.cc
index 5bbbacd..38d461c 100644
--- a/chrome/browser/extensions/api/idle/idle_api.cc
+++ b/chrome/browser/extensions/api/idle/idle_api.cc
@@ -42,7 +42,7 @@ bool IdleQueryStateFunction::RunAsync() {
return true;
}
-void IdleQueryStateFunction::IdleStateCallback(IdleState state) {
+void IdleQueryStateFunction::IdleStateCallback(ui::IdleState state) {
SetResult(IdleManager::CreateIdleValue(state));
SendResponse(true);
}
diff --git a/chrome/browser/extensions/api/idle/idle_api.h b/chrome/browser/extensions/api/idle/idle_api.h
index bf0dcc5..6df79fe 100644
--- a/chrome/browser/extensions/api/idle/idle_api.h
+++ b/chrome/browser/extensions/api/idle/idle_api.h
@@ -5,8 +5,8 @@
#ifndef CHROME_BROWSER_EXTENSIONS_API_IDLE_IDLE_API_H_
#define CHROME_BROWSER_EXTENSIONS_API_IDLE_IDLE_API_H_
-#include "chrome/browser/idle.h"
#include "extensions/browser/extension_function.h"
+#include "ui/base/idle/idle.h"
namespace extensions {
@@ -22,7 +22,7 @@ class IdleQueryStateFunction : public AsyncExtensionFunction {
bool RunAsync() override;
private:
- void IdleStateCallback(IdleState state);
+ void IdleStateCallback(ui::IdleState state);
};
// Implementation of the chrome.idle.setDetectionInterval API.
diff --git a/chrome/browser/extensions/api/idle/idle_api_unittest.cc b/chrome/browser/extensions/api/idle/idle_api_unittest.cc
index b62a880..4f55eb3 100644
--- a/chrome/browser/extensions/api/idle/idle_api_unittest.cc
+++ b/chrome/browser/extensions/api/idle/idle_api_unittest.cc
@@ -34,7 +34,7 @@ class MockEventDelegate : public IdleManager::EventDelegate {
public:
MockEventDelegate() {}
virtual ~MockEventDelegate() {}
- MOCK_METHOD2(OnStateChanged, void(const std::string&, IdleState));
+ MOCK_METHOD2(OnStateChanged, void(const std::string&, ui::IdleState));
virtual void RegisterObserver(EventRouter::Observer* observer) {}
virtual void UnregisterObserver(EventRouter::Observer* observer) {}
};
@@ -43,8 +43,8 @@ class TestIdleProvider : public IdleManager::IdleTimeProvider {
public:
TestIdleProvider();
~TestIdleProvider() override;
- void CalculateIdleState(int idle_threshold, IdleCallback notify) override;
- void CalculateIdleTime(IdleTimeCallback notify) override;
+ void CalculateIdleState(int idle_threshold, ui::IdleCallback notify) override;
+ void CalculateIdleTime(ui::IdleTimeCallback notify) override;
bool CheckIdleStateIsLocked() override;
void set_idle_time(int idle_time);
@@ -64,19 +64,19 @@ TestIdleProvider::~TestIdleProvider() {
}
void TestIdleProvider::CalculateIdleState(int idle_threshold,
- IdleCallback notify) {
+ ui::IdleCallback notify) {
if (locked_) {
- notify.Run(IDLE_STATE_LOCKED);
+ notify.Run(ui::IDLE_STATE_LOCKED);
} else {
if (idle_time_ >= idle_threshold) {
- notify.Run(IDLE_STATE_IDLE);
+ notify.Run(ui::IDLE_STATE_IDLE);
} else {
- notify.Run(IDLE_STATE_ACTIVE);
+ notify.Run(ui::IDLE_STATE_ACTIVE);
}
}
}
-void TestIdleProvider::CalculateIdleTime(IdleTimeCallback notify) {
+void TestIdleProvider::CalculateIdleTime(ui::IdleTimeCallback notify) {
notify.Run(idle_time_);
}
@@ -291,7 +291,7 @@ TEST_F(IdleTest, ActiveToIdle) {
idle_provider_->set_idle_time(60);
- EXPECT_CALL(*event_delegate_, OnStateChanged("test", IDLE_STATE_IDLE));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("test", ui::IDLE_STATE_IDLE));
idle_manager_->UpdateIdleState();
testing::Mock::VerifyAndClearExpectations(event_delegate_);
@@ -309,7 +309,7 @@ TEST_F(IdleTest, ActiveToLocked) {
idle_provider_->set_locked(true);
idle_provider_->set_idle_time(5);
- EXPECT_CALL(*event_delegate_, OnStateChanged("test", IDLE_STATE_LOCKED));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("test", ui::IDLE_STATE_LOCKED));
idle_manager_->UpdateIdleState();
}
@@ -320,12 +320,12 @@ TEST_F(IdleTest, IdleToActive) {
idle_provider_->set_locked(false);
idle_provider_->set_idle_time(75);
- EXPECT_CALL(*event_delegate_, OnStateChanged("test", IDLE_STATE_IDLE));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("test", ui::IDLE_STATE_IDLE));
idle_manager_->UpdateIdleState();
testing::Mock::VerifyAndClearExpectations(event_delegate_);
idle_provider_->set_idle_time(0);
- EXPECT_CALL(*event_delegate_, OnStateChanged("test", IDLE_STATE_ACTIVE));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("test", ui::IDLE_STATE_ACTIVE));
idle_manager_->UpdateIdleState();
}
@@ -336,12 +336,12 @@ TEST_F(IdleTest, IdleToLocked) {
idle_provider_->set_locked(false);
idle_provider_->set_idle_time(75);
- EXPECT_CALL(*event_delegate_, OnStateChanged("test", IDLE_STATE_IDLE));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("test", ui::IDLE_STATE_IDLE));
idle_manager_->UpdateIdleState();
testing::Mock::VerifyAndClearExpectations(event_delegate_);
idle_provider_->set_locked(true);
- EXPECT_CALL(*event_delegate_, OnStateChanged("test", IDLE_STATE_LOCKED));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("test", ui::IDLE_STATE_LOCKED));
idle_manager_->UpdateIdleState();
}
@@ -352,12 +352,12 @@ TEST_F(IdleTest, LockedToActive) {
idle_provider_->set_locked(true);
idle_provider_->set_idle_time(0);
- EXPECT_CALL(*event_delegate_, OnStateChanged("test", IDLE_STATE_LOCKED));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("test", ui::IDLE_STATE_LOCKED));
idle_manager_->UpdateIdleState();
idle_provider_->set_locked(false);
idle_provider_->set_idle_time(5);
- EXPECT_CALL(*event_delegate_, OnStateChanged("test", IDLE_STATE_ACTIVE));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("test", ui::IDLE_STATE_ACTIVE));
idle_manager_->UpdateIdleState();
}
@@ -367,12 +367,12 @@ TEST_F(IdleTest, LockedToIdle) {
idle_provider_->set_locked(true);
idle_provider_->set_idle_time(75);
- EXPECT_CALL(*event_delegate_, OnStateChanged("test", IDLE_STATE_LOCKED));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("test", ui::IDLE_STATE_LOCKED));
idle_manager_->UpdateIdleState();
testing::Mock::VerifyAndClearExpectations(event_delegate_);
idle_provider_->set_locked(false);
- EXPECT_CALL(*event_delegate_, OnStateChanged("test", IDLE_STATE_IDLE));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("test", ui::IDLE_STATE_IDLE));
idle_manager_->UpdateIdleState();
}
@@ -383,8 +383,8 @@ TEST_F(IdleTest, MultipleExtensions) {
ScopedListen listen_2(idle_manager_, "2");
idle_provider_->set_locked(true);
- EXPECT_CALL(*event_delegate_, OnStateChanged("1", IDLE_STATE_LOCKED));
- EXPECT_CALL(*event_delegate_, OnStateChanged("2", IDLE_STATE_LOCKED));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("1", ui::IDLE_STATE_LOCKED));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("2", ui::IDLE_STATE_LOCKED));
idle_manager_->UpdateIdleState();
testing::Mock::VerifyAndClearExpectations(event_delegate_);
@@ -392,16 +392,16 @@ TEST_F(IdleTest, MultipleExtensions) {
ScopedListen listen_2prime(idle_manager_, "2");
ScopedListen listen_3(idle_manager_, "3");
idle_provider_->set_locked(false);
- EXPECT_CALL(*event_delegate_, OnStateChanged("1", IDLE_STATE_ACTIVE));
- EXPECT_CALL(*event_delegate_, OnStateChanged("2", IDLE_STATE_ACTIVE));
- EXPECT_CALL(*event_delegate_, OnStateChanged("3", IDLE_STATE_ACTIVE));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("1", ui::IDLE_STATE_ACTIVE));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("2", ui::IDLE_STATE_ACTIVE));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("3", ui::IDLE_STATE_ACTIVE));
idle_manager_->UpdateIdleState();
testing::Mock::VerifyAndClearExpectations(event_delegate_);
}
idle_provider_->set_locked(true);
- EXPECT_CALL(*event_delegate_, OnStateChanged("1", IDLE_STATE_LOCKED));
- EXPECT_CALL(*event_delegate_, OnStateChanged("2", IDLE_STATE_LOCKED));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("1", ui::IDLE_STATE_LOCKED));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("2", ui::IDLE_STATE_LOCKED));
idle_manager_->UpdateIdleState();
}
@@ -422,14 +422,14 @@ TEST_F(IdleTest, SetDetectionInterval) {
idle_provider_->set_idle_time(45);
EXPECT_CALL(*event_delegate_,
- OnStateChanged(extension()->id(), IDLE_STATE_IDLE));
+ OnStateChanged(extension()->id(), ui::IDLE_STATE_IDLE));
idle_manager_->UpdateIdleState();
// Verify that the expectation has been fulfilled before incrementing the
// time again.
testing::Mock::VerifyAndClearExpectations(event_delegate_);
idle_provider_->set_idle_time(60);
- EXPECT_CALL(*event_delegate_, OnStateChanged("default", IDLE_STATE_IDLE));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("default", ui::IDLE_STATE_IDLE));
idle_manager_->UpdateIdleState();
}
@@ -448,7 +448,7 @@ TEST_F(IdleTest, SetDetectionIntervalBeforeListener) {
idle_provider_->set_idle_time(45);
EXPECT_CALL(*event_delegate_,
- OnStateChanged(extension()->id(), IDLE_STATE_IDLE));
+ OnStateChanged(extension()->id(), ui::IDLE_STATE_IDLE));
idle_manager_->UpdateIdleState();
}
@@ -467,7 +467,7 @@ TEST_F(IdleTest, SetDetectionIntervalMaximum) {
idle_provider_->set_idle_time(4*60*60);
EXPECT_CALL(*event_delegate_,
- OnStateChanged(extension()->id(), IDLE_STATE_IDLE));
+ OnStateChanged(extension()->id(), ui::IDLE_STATE_IDLE));
idle_manager_->UpdateIdleState();
}
@@ -486,7 +486,7 @@ TEST_F(IdleTest, SetDetectionIntervalMinimum) {
idle_provider_->set_idle_time(15);
EXPECT_CALL(*event_delegate_,
- OnStateChanged(extension()->id(), IDLE_STATE_IDLE));
+ OnStateChanged(extension()->id(), ui::IDLE_STATE_IDLE));
idle_manager_->UpdateIdleState();
}
@@ -506,7 +506,7 @@ TEST_F(IdleTest, UnloadCleanup) {
ScopedListen listen(idle_manager_, extension()->id());
idle_provider_->set_idle_time(16);
EXPECT_CALL(*event_delegate_,
- OnStateChanged(extension()->id(), IDLE_STATE_IDLE));
+ OnStateChanged(extension()->id(), ui::IDLE_STATE_IDLE));
idle_manager_->UpdateIdleState();
testing::Mock::VerifyAndClearExpectations(event_delegate_);
}
@@ -523,7 +523,7 @@ TEST_F(IdleTest, UnloadCleanup) {
idle_provider_->set_idle_time(61);
EXPECT_CALL(*event_delegate_,
- OnStateChanged(extension()->id(), IDLE_STATE_IDLE));
+ OnStateChanged(extension()->id(), ui::IDLE_STATE_IDLE));
idle_manager_->UpdateIdleState();
}
}
@@ -553,7 +553,7 @@ TEST_F(IdleTest, ReAddListener) {
// Fire idle event.
ScopedListen listen(idle_manager_, "test");
idle_provider_->set_idle_time(60);
- EXPECT_CALL(*event_delegate_, OnStateChanged("test", IDLE_STATE_IDLE));
+ EXPECT_CALL(*event_delegate_, OnStateChanged("test", ui::IDLE_STATE_IDLE));
idle_manager_->UpdateIdleState();
testing::Mock::VerifyAndClearExpectations(event_delegate_);
}
diff --git a/chrome/browser/extensions/api/idle/idle_manager.cc b/chrome/browser/extensions/api/idle/idle_manager.cc
index 56fed80..0966a76 100644
--- a/chrome/browser/extensions/api/idle/idle_manager.cc
+++ b/chrome/browser/extensions/api/idle/idle_manager.cc
@@ -31,7 +31,7 @@ class DefaultEventDelegate : public IdleManager::EventDelegate {
~DefaultEventDelegate() override;
void OnStateChanged(const std::string& extension_id,
- IdleState new_state) override;
+ ui::IdleState new_state) override;
void RegisterObserver(EventRouter::Observer* observer) override;
void UnregisterObserver(EventRouter::Observer* observer) override;
@@ -47,7 +47,7 @@ DefaultEventDelegate::~DefaultEventDelegate() {
}
void DefaultEventDelegate::OnStateChanged(const std::string& extension_id,
- IdleState new_state) {
+ ui::IdleState new_state) {
scoped_ptr<base::ListValue> args(new base::ListValue());
args->Append(IdleManager::CreateIdleValue(new_state));
scoped_ptr<Event> event(new Event(idle::OnStateChanged::kEventName,
@@ -72,8 +72,8 @@ class DefaultIdleProvider : public IdleManager::IdleTimeProvider {
DefaultIdleProvider();
~DefaultIdleProvider() override;
- void CalculateIdleState(int idle_threshold, IdleCallback notify) override;
- void CalculateIdleTime(IdleTimeCallback notify) override;
+ void CalculateIdleState(int idle_threshold, ui::IdleCallback notify) override;
+ void CalculateIdleTime(ui::IdleTimeCallback notify) override;
bool CheckIdleStateIsLocked() override;
};
@@ -84,34 +84,36 @@ DefaultIdleProvider::~DefaultIdleProvider() {
}
void DefaultIdleProvider::CalculateIdleState(int idle_threshold,
- IdleCallback notify) {
- ::CalculateIdleState(idle_threshold, notify);
+ ui::IdleCallback notify) {
+ ui::CalculateIdleState(idle_threshold, notify);
}
-void DefaultIdleProvider::CalculateIdleTime(IdleTimeCallback notify) {
- ::CalculateIdleTime(notify);
+void DefaultIdleProvider::CalculateIdleTime(ui::IdleTimeCallback notify) {
+ ui::CalculateIdleTime(notify);
}
bool DefaultIdleProvider::CheckIdleStateIsLocked() {
- return ::CheckIdleStateIsLocked();
+ return ui::CheckIdleStateIsLocked();
}
-IdleState IdleTimeToIdleState(bool locked, int idle_time, int idle_threshold) {
- IdleState state;
+ui::IdleState IdleTimeToIdleState(bool locked,
+ int idle_time,
+ int idle_threshold) {
+ ui::IdleState state;
if (locked) {
- state = IDLE_STATE_LOCKED;
+ state = ui::IDLE_STATE_LOCKED;
} else if (idle_time >= idle_threshold) {
- state = IDLE_STATE_IDLE;
+ state = ui::IDLE_STATE_IDLE;
} else {
- state = IDLE_STATE_ACTIVE;
+ state = ui::IDLE_STATE_ACTIVE;
}
return state;
}
} // namespace
-IdleMonitor::IdleMonitor(IdleState initial_state)
+IdleMonitor::IdleMonitor(ui::IdleState initial_state)
: last_state(initial_state),
listeners(0),
threshold(kDefaultIdleThreshold) {
@@ -119,7 +121,7 @@ IdleMonitor::IdleMonitor(IdleState initial_state)
IdleManager::IdleManager(content::BrowserContext* context)
: context_(context),
- last_state_(IDLE_STATE_ACTIVE),
+ last_state_(ui::IDLE_STATE_ACTIVE),
idle_time_provider_(new DefaultIdleProvider()),
event_delegate_(new DefaultEventDelegate(context)),
extension_registry_observer_(this),
@@ -180,12 +182,12 @@ void IdleManager::SetThreshold(const std::string& extension_id,
}
// static
-base::StringValue* IdleManager::CreateIdleValue(IdleState idle_state) {
+base::StringValue* IdleManager::CreateIdleValue(ui::IdleState idle_state) {
const char* description;
- if (idle_state == IDLE_STATE_ACTIVE) {
+ if (idle_state == ui::IDLE_STATE_ACTIVE) {
description = keys::kStateActive;
- } else if (idle_state == IDLE_STATE_IDLE) {
+ } else if (idle_state == ui::IDLE_STATE_IDLE) {
description = keys::kStateIdle;
} else {
description = keys::kStateLocked;
@@ -253,7 +255,7 @@ void IdleManager::UpdateIdleStateCallback(int idle_time) {
for (MonitorMap::iterator it = monitors_.begin();
it != monitors_.end(); ++it) {
IdleMonitor& monitor = it->second;
- IdleState new_state =
+ ui::IdleState new_state =
IdleTimeToIdleState(locked, idle_time, monitor.threshold);
// TODO(kalman): Use EventRouter::HasListeners for these sorts of checks.
if (monitor.listeners > 0 && monitor.last_state != new_state)
diff --git a/chrome/browser/extensions/api/idle/idle_manager.h b/chrome/browser/extensions/api/idle/idle_manager.h
index 38e8741..6c8ae5e 100644
--- a/chrome/browser/extensions/api/idle/idle_manager.h
+++ b/chrome/browser/extensions/api/idle/idle_manager.h
@@ -14,10 +14,10 @@
#include "base/scoped_observer.h"
#include "base/threading/thread_checker.h"
#include "base/timer/timer.h"
-#include "chrome/browser/idle.h"
#include "components/keyed_service/core/keyed_service.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_registry_observer.h"
+#include "ui/base/idle/idle.h"
namespace base {
class StringValue;
@@ -30,12 +30,12 @@ class BrowserContext;
namespace extensions {
class ExtensionRegistry;
-typedef base::Callback<void(IdleState)> QueryStateCallback;
+typedef base::Callback<void(ui::IdleState)> QueryStateCallback;
struct IdleMonitor {
- explicit IdleMonitor(IdleState initial_state);
+ explicit IdleMonitor(ui::IdleState initial_state);
- IdleState last_state;
+ ui::IdleState last_state;
int listeners;
int threshold;
};
@@ -49,8 +49,8 @@ class IdleManager : public ExtensionRegistryObserver,
IdleTimeProvider() {}
virtual ~IdleTimeProvider() {}
virtual void CalculateIdleState(int idle_threshold,
- IdleCallback notify) = 0;
- virtual void CalculateIdleTime(IdleTimeCallback notify) = 0;
+ ui::IdleCallback notify) = 0;
+ virtual void CalculateIdleTime(ui::IdleTimeCallback notify) = 0;
virtual bool CheckIdleStateIsLocked() = 0;
private:
@@ -62,7 +62,7 @@ class IdleManager : public ExtensionRegistryObserver,
EventDelegate() {}
virtual ~EventDelegate() {}
virtual void OnStateChanged(const std::string& extension_id,
- IdleState new_state) = 0;
+ ui::IdleState new_state) = 0;
virtual void RegisterObserver(EventRouter::Observer* observer) = 0;
virtual void UnregisterObserver(EventRouter::Observer* observer) = 0;
@@ -89,7 +89,7 @@ class IdleManager : public ExtensionRegistryObserver,
void QueryState(int threshold, QueryStateCallback notify);
void SetThreshold(const std::string& extension_id, int threshold);
- static base::StringValue* CreateIdleValue(IdleState idle_state);
+ static base::StringValue* CreateIdleValue(ui::IdleState idle_state);
// Override default event class. Callee assumes ownership. Used for testing.
void SetEventDelegateForTest(scoped_ptr<EventDelegate> event_delegate);
@@ -123,7 +123,7 @@ class IdleManager : public ExtensionRegistryObserver,
content::BrowserContext* const context_;
- IdleState last_state_;
+ ui::IdleState last_state_;
MonitorMap monitors_;
base::RepeatingTimer<IdleManager> poll_timer_;
diff --git a/chrome/browser/notifications/screen_lock_notification_blocker.cc b/chrome/browser/notifications/screen_lock_notification_blocker.cc
index 802c96e..a41b2a8 100644
--- a/chrome/browser/notifications/screen_lock_notification_blocker.cc
+++ b/chrome/browser/notifications/screen_lock_notification_blocker.cc
@@ -5,7 +5,7 @@
#include "chrome/browser/notifications/screen_lock_notification_blocker.h"
#include "base/time/time.h"
-#include "chrome/browser/idle.h"
+#include "ui/base/idle/idle.h"
namespace {
const int kUserStatePollingIntervalSeconds = 1;
@@ -22,7 +22,7 @@ ScreenLockNotificationBlocker::~ScreenLockNotificationBlocker() {
void ScreenLockNotificationBlocker::CheckState() {
bool was_locked = is_locked_;
- is_locked_ = CheckIdleStateIsLocked();
+ is_locked_ = ui::CheckIdleStateIsLocked();
if (is_locked_ != was_locked)
NotifyBlockingStateChanged();
diff --git a/chrome/browser/upgrade_detector.cc b/chrome/browser/upgrade_detector.cc
index fee2cb7..5f10b96 100644
--- a/chrome/browser/upgrade_detector.cc
+++ b/chrome/browser/upgrade_detector.cc
@@ -109,25 +109,25 @@ void UpgradeDetector::TriggerNotification(chrome::NotificationType type) {
content::NotificationService::NoDetails());
}
-void UpgradeDetector::IdleCallback(IdleState state) {
+void UpgradeDetector::IdleCallback(ui::IdleState state) {
// Don't proceed while an incognito window is open. The timer will still
// keep firing, so this function will get a chance to re-evaluate this.
if (chrome::IsOffTheRecordSessionActive())
return;
switch (state) {
- case IDLE_STATE_LOCKED:
+ case ui::IDLE_STATE_LOCKED:
// Computer is locked, auto-restart.
idle_check_timer_.Stop();
chrome::AttemptRestart();
break;
- case IDLE_STATE_IDLE:
+ case ui::IDLE_STATE_IDLE:
// Computer has been idle for long enough, show warning.
idle_check_timer_.Stop();
TriggerNotification(chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED);
break;
- case IDLE_STATE_ACTIVE:
- case IDLE_STATE_UNKNOWN:
+ case ui::IDLE_STATE_ACTIVE:
+ case ui::IDLE_STATE_UNKNOWN:
break;
default:
NOTREACHED(); // Need to add any new value above (either providing
diff --git a/chrome/browser/upgrade_detector.h b/chrome/browser/upgrade_detector.h
index 4beef3d..53e8ee3 100644
--- a/chrome/browser/upgrade_detector.h
+++ b/chrome/browser/upgrade_detector.h
@@ -7,7 +7,7 @@
#include "base/timer/timer.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/idle.h"
+#include "ui/base/idle/idle.h"
#include "ui/gfx/image/image.h"
class PrefRegistrySimple;
@@ -137,7 +137,7 @@ class UpgradeDetector {
// The callback for the IdleCheck. Tells us whether Chrome has received any
// input events since the specified time.
- void IdleCallback(IdleState state);
+ void IdleCallback(ui::IdleState state);
// Triggers a global notification of the specified |type|.
void TriggerNotification(chrome::NotificationType type);
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 4b54ca3..394a5b1 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -391,10 +391,6 @@
'browser/icon_loader_win.cc',
'browser/icon_manager.cc',
'browser/icon_manager.h',
- 'browser/idle.h',
- 'browser/idle_chromeos.cc',
- 'browser/idle_mac.mm',
- 'browser/idle_win.cc',
'browser/image_decoder.cc',
'browser/image_decoder.h',
'browser/image_holder.cc',
@@ -773,14 +769,9 @@
'browser/first_run/upgrade_util_linux.h',
'browser/fullscreen_aurax11.cc',
'browser/icon_loader_auralinux.cc',
- 'browser/idle_linux.cc',
- 'browser/idle_query_x11.cc',
- 'browser/idle_query_x11.h',
'browser/password_manager/native_backend_kwallet_x.cc',
'browser/password_manager/native_backend_kwallet_x.h',
'browser/platform_util_linux.cc',
- 'browser/screensaver_window_finder_x11.cc',
- 'browser/screensaver_window_finder_x11.h',
'browser/shell_integration_linux.cc',
'browser/shell_integration_linux.h',
'browser/speech/tts_linux.cc',
@@ -884,7 +875,6 @@
'browser/first_run/upgrade_util_win.h',
'browser/font_family_cache.cc',
'browser/font_family_cache.h',
- 'browser/idle.cc',
'browser/importer/external_process_importer_client.cc',
'browser/importer/external_process_importer_client.h',
'browser/importer/external_process_importer_host.cc',
@@ -3292,13 +3282,6 @@
}],
['use_x11==1', {
'sources': [ '<@(chrome_browser_x11_sources)' ],
- 'conditions': [
- ['chromeos==0', {
- 'dependencies': [
- '../build/linux/system.gyp:xscrnsaver',
- ],
- }],
- ],
}],
['os_posix == 1 and OS != "mac" and OS != "ios"', {
'sources': [
diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn
index 6b034af..d3f64b6 100644
--- a/ui/base/BUILD.gn
+++ b/ui/base/BUILD.gn
@@ -148,6 +148,12 @@ component("base") {
"font_helper_chromeos.cc",
"font_helper_chromeos.h",
"hit_test.h",
+ "idle/idle.cc",
+ "idle/idle_chromeos.cc",
+ "idle/idle.h",
+ "idle/idle_linux.cc",
+ "idle/idle_mac.mm",
+ "idle/idle_win.cc",
"l10n/formatter.cc",
"l10n/formatter.h",
"l10n/l10n_font_util.cc",
@@ -487,6 +493,15 @@ component("base") {
"x/x11_util.h",
"x/x11_util_internal.h",
]
+ if (!is_chromeos) {
+ sources += [
+ "idle/idle_query_x11.cc",
+ "idle/idle_query_x11.h",
+ "idle/screensaver_window_finder_x11.cc",
+ "idle/screensaver_window_finder_x11.h",
+ ]
+ configs += [ "//build/config/linux:xscrnsaver" ]
+ }
deps += [ "//ui/gfx/x" ]
}
@@ -514,6 +529,10 @@ component("base") {
}
}
+ if (is_chromeos) {
+ sources -= [ "idle/idle_linux.cc" ]
+ }
+
if (is_chromeos || (use_aura && is_linux && !use_x11)) {
sources += [
"dragdrop/os_exchange_data_provider_aura.cc",
@@ -669,7 +688,11 @@ component("base") {
}
if (is_android || is_ios) {
- sources -= [ "device_form_factor_desktop.cc" ]
+ sources -= [
+ "device_form_factor_desktop.cc",
+ "idle/idle.cc",
+ "idle/idle.h",
+ ]
}
}
diff --git a/ui/base/idle/DEPS b/ui/base/idle/DEPS
new file mode 100644
index 0000000..27b08e5
--- /dev/null
+++ b/ui/base/idle/DEPS
@@ -0,0 +1,4 @@
+include_rules = [
+ "+chromeos/dbus/dbus_thread_manager.h",
+ "+chromeos/dbus/session_manager_client.h",
+]
diff --git a/chrome/browser/idle.cc b/ui/base/idle/idle.cc
index 7a19943..67432e0 100644
--- a/chrome/browser/idle.cc
+++ b/ui/base/idle/idle.cc
@@ -2,10 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/idle.h"
+#include "ui/base/idle/idle.h"
#include "base/bind.h"
+namespace ui {
namespace {
void CalculateIdleStateCallback(int idle_threshold,
@@ -29,3 +30,5 @@ void CalculateIdleState(int idle_threshold, IdleCallback notify) {
idle_threshold,
notify));
}
+
+} // namespace ui
diff --git a/chrome/browser/idle.h b/ui/base/idle/idle.h
index d558960..7ecdbff 100644
--- a/chrome/browser/idle.h
+++ b/ui/base/idle/idle.h
@@ -2,10 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_IDLE_H_
-#define CHROME_BROWSER_IDLE_H_
+#ifndef UI_BASE_IDLE_IDLE_H_
+#define UI_BASE_IDLE_IDLE_H_
#include "base/callback.h"
+#include "ui/base/ui_base_export.h"
+
+namespace ui {
enum IdleState {
IDLE_STATE_ACTIVE = 0,
@@ -17,7 +20,7 @@ enum IdleState {
// For MacOSX, InitIdleMonitor needs to be called first to setup the monitor.
#if defined(OS_MACOSX)
-void InitIdleMonitor();
+UI_BASE_EXPORT void InitIdleMonitor();
#endif
typedef base::Callback<void(IdleState)> IdleCallback;
@@ -26,12 +29,14 @@ typedef base::Callback<void(int)> IdleTimeCallback;
// Calculate the Idle state and notify the callback. |idle_threshold| is the
// amount of time (in seconds) before considered idle. |notify| is
// asynchronously called on some platforms.
-void CalculateIdleState(int idle_threshold, IdleCallback notify);
+UI_BASE_EXPORT void CalculateIdleState(int idle_threshold, IdleCallback notify);
// Calculate Idle time in seconds and notify the callback
-void CalculateIdleTime(IdleTimeCallback notify);
+UI_BASE_EXPORT void CalculateIdleTime(IdleTimeCallback notify);
// Checks synchronously if Idle state is IDLE_STATE_LOCKED.
-bool CheckIdleStateIsLocked();
+UI_BASE_EXPORT bool CheckIdleStateIsLocked();
+
+} // namespace ui
-#endif // CHROME_BROWSER_IDLE_H_
+#endif // UI_BASE_IDLE_IDLE_H_
diff --git a/chrome/browser/idle_chromeos.cc b/ui/base/idle/idle_chromeos.cc
index 7c289a7..0a38284 100644
--- a/chrome/browser/idle_chromeos.cc
+++ b/ui/base/idle/idle_chromeos.cc
@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/idle.h"
+#include "ui/base/idle/idle.h"
#include "base/time/time.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
#include "ui/base/user_activity/user_activity_detector.h"
+namespace ui {
+
void CalculateIdleTime(IdleTimeCallback notify) {
base::TimeDelta idle_time = base::TimeTicks::Now() -
ui::UserActivityDetector::Get()->last_activity_time();
@@ -19,3 +21,5 @@ bool CheckIdleStateIsLocked() {
return chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
IsScreenLocked();
}
+
+} // namespace ui
diff --git a/chrome/browser/idle_linux.cc b/ui/base/idle/idle_linux.cc
index efcbb6d..622ae8d 100644
--- a/chrome/browser/idle_linux.cc
+++ b/ui/base/idle/idle_linux.cc
@@ -2,33 +2,31 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/idle.h"
+#include "ui/base/idle/idle.h"
#include "base/basictypes.h"
#if defined(USE_X11)
-#include "chrome/browser/idle_query_x11.h"
+#include "ui/base/idle/idle_query_x11.h"
+#include "ui/base/idle/screensaver_window_finder_x11.h"
#endif
-#if !defined(OS_CHROMEOS)
-#include "chrome/browser/screensaver_window_finder_x11.h"
-#endif
+namespace ui {
void CalculateIdleTime(IdleTimeCallback notify) {
#if defined(USE_X11)
- chrome::IdleQueryX11 idle_query;
+ IdleQueryX11 idle_query;
notify.Run(idle_query.IdleTime());
#endif
}
bool CheckIdleStateIsLocked() {
- // Usually the screensaver is used to lock the screen, so we do not need to
- // check if the workstation is locked.
-#if defined(OS_CHROMEOS)
- return false;
-#elif defined(USE_OZONE)
- return false;
-#else
+#if defined(USE_X11)
+ // Usually the screensaver is used to lock the screen.
return ScreensaverWindowFinder::ScreensaverWindowExists();
+#else
+ return false;
#endif
}
+
+} // namespace ui
diff --git a/chrome/browser/idle_mac.mm b/ui/base/idle/idle_mac.mm
index 1825c83..4d9e37a 100644
--- a/chrome/browser/idle_mac.mm
+++ b/ui/base/idle/idle_mac.mm
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/idle.h"
+#include "ui/base/idle/idle.h"
#include <ApplicationServices/ApplicationServices.h>
#import <Cocoa/Cocoa.h>
@@ -72,8 +72,13 @@
@end
+namespace ui {
+namespace {
+
static MacScreenMonitor* g_screenMonitor = nil;
+} // namespace
+
void InitIdleMonitor() {
if (!g_screenMonitor)
g_screenMonitor = [[MacScreenMonitor alloc] init];
@@ -90,3 +95,5 @@ bool CheckIdleStateIsLocked() {
return [g_screenMonitor isScreensaverRunning] ||
[g_screenMonitor isScreenLocked];
}
+
+} // namespace ui
diff --git a/chrome/browser/idle_query_x11.cc b/ui/base/idle/idle_query_x11.cc
index 845ec5b..30bdeb6 100644
--- a/chrome/browser/idle_query_x11.cc
+++ b/ui/base/idle/idle_query_x11.cc
@@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/idle_query_x11.h"
+#include "ui/base/idle/idle_query_x11.h"
#include <X11/extensions/scrnsaver.h>
+
#include "ui/gfx/x/x11_types.h"
-namespace chrome {
+namespace ui {
class IdleData {
public:
@@ -47,4 +48,4 @@ int IdleQueryX11::IdleTime() {
}
}
-} // namespace chrome
+} // namespace ui
diff --git a/chrome/browser/idle_query_x11.h b/ui/base/idle/idle_query_x11.h
index 5f20648..56588e6 100644
--- a/chrome/browser/idle_query_x11.h
+++ b/ui/base/idle/idle_query_x11.h
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_IDLE_QUERY_X11_H_
-#define CHROME_BROWSER_IDLE_QUERY_X11_H_
+#ifndef UI_BASE_IDLE_IDLE_QUERY_X11_H_
+#define UI_BASE_IDLE_IDLE_QUERY_X11_H_
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
-namespace chrome {
+namespace ui {
class IdleData;
@@ -25,6 +25,6 @@ class IdleQueryX11 {
DISALLOW_COPY_AND_ASSIGN(IdleQueryX11);
};
-} // namespace chrome
+} // namespace ui
-#endif // CHROME_BROWSER_IDLE_QUERY_X11_H_
+#endif // UI_BASE_IDLE_IDLE_QUERY_X11_H_
diff --git a/chrome/browser/idle_win.cc b/ui/base/idle/idle_win.cc
index 0457ed9..f151537 100644
--- a/chrome/browser/idle_win.cc
+++ b/ui/base/idle/idle_win.cc
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/idle.h"
+#include "ui/base/idle/idle.h"
#include <limits.h>
#include <windows.h>
#include "ui/base/win/lock_state.h"
+namespace ui {
namespace {
DWORD CalculateIdleTimeInternal() {
@@ -52,3 +53,5 @@ void CalculateIdleTime(IdleTimeCallback notify) {
bool CheckIdleStateIsLocked() {
return ui::IsWorkstationLocked() || IsScreensaverRunning();
}
+
+} // namespace ui
diff --git a/chrome/browser/screensaver_window_finder_x11.cc b/ui/base/idle/screensaver_window_finder_x11.cc
index 589ec2e..b6e3be2 100644
--- a/chrome/browser/screensaver_window_finder_x11.cc
+++ b/ui/base/idle/screensaver_window_finder_x11.cc
@@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/screensaver_window_finder_x11.h"
+#include "ui/base/idle/screensaver_window_finder_x11.h"
#include "base/basictypes.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/x/x11_error_tracker.h"
+namespace ui {
+
ScreensaverWindowFinder::ScreensaverWindowFinder()
: exists_(false) {
}
@@ -43,3 +45,5 @@ bool ScreensaverWindowFinder::IsScreensaverWindow(XID window) const {
return value.find("screensaver") != std::string::npos;
}
+
+} // namespace ui
diff --git a/chrome/browser/screensaver_window_finder_x11.h b/ui/base/idle/screensaver_window_finder_x11.h
index 2793497..1383b59 100644
--- a/chrome/browser/screensaver_window_finder_x11.h
+++ b/ui/base/idle/screensaver_window_finder_x11.h
@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_SCREENSAVER_WINDOW_FINDER_X11_H_
-#define CHROME_BROWSER_SCREENSAVER_WINDOW_FINDER_X11_H_
+#ifndef UI_BASE_IDLE_SCREENSAVER_WINDOW_FINDER_X11_H_
+#define UI_BASE_IDLE_SCREENSAVER_WINDOW_FINDER_X11_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/base/x/x11_util.h"
+namespace ui {
+
class ScreensaverWindowFinder : public ui::EnumerateWindowsDelegate {
public:
static bool ScreensaverWindowExists();
@@ -26,5 +28,6 @@ class ScreensaverWindowFinder : public ui::EnumerateWindowsDelegate {
DISALLOW_COPY_AND_ASSIGN(ScreensaverWindowFinder);
};
+} // namespace ui
-#endif // CHROME_BROWSER_SCREENSAVER_WINDOW_FINDER_X11_H_
+#endif // UI_BASE_IDLE_SCREENSAVER_WINDOW_FINDER_X11_H_
diff --git a/ui/base/ui_base.gyp b/ui/base/ui_base.gyp
index 1c8af2c..1115a09 100644
--- a/ui/base/ui_base.gyp
+++ b/ui/base/ui_base.gyp
@@ -191,6 +191,16 @@
'font_helper_chromeos.cc',
'font_helper_chromeos.h',
'hit_test.h',
+ 'idle/idle.cc',
+ 'idle/idle_chromeos.cc',
+ 'idle/idle.h',
+ 'idle/idle_linux.cc',
+ 'idle/idle_mac.mm',
+ 'idle/idle_query_x11.cc',
+ 'idle/idle_query_x11.h',
+ 'idle/idle_win.cc',
+ 'idle/screensaver_window_finder_x11.cc',
+ 'idle/screensaver_window_finder_x11.h',
'ime/candidate_window.cc',
'ime/candidate_window.h',
'ime/chromeos/character_composer.cc',
@@ -616,6 +626,11 @@
'../events/platform/x11/x11_events_platform.gyp:x11_events_platform',
],
}],
+ ['use_x11==1 and chromeos==0', {
+ 'dependencies': [
+ '../../build/linux/system.gyp:xscrnsaver',
+ ],
+ }],
['toolkit_views==0', {
'sources!': [
'dragdrop/drag_drop_types.h',
@@ -634,6 +649,8 @@
'default_theme_provider.cc',
'dragdrop/drag_utils.cc',
'dragdrop/drag_utils.h',
+ 'idle/idle.cc',
+ 'idle/idle.h',
'l10n/l10n_font_util.cc',
'models/button_menu_item_model.cc',
'models/dialog_model.cc',
@@ -694,6 +711,13 @@
'dependencies': [
'../../chromeos/chromeos.gyp:chromeos',
],
+ 'sources!': [
+ 'idle/idle_linux.cc',
+ 'idle/idle_query_x11.cc',
+ 'idle/idle_query_x11.h',
+ 'idle/screensaver_window_finder_x11.cc',
+ 'idle/screensaver_window_finder_x11.h',
+ ],
}],
['OS!="win"', {
'sources!': [