summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsidor@chromium.org <sidor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-10 07:54:50 +0000
committersidor@chromium.org <sidor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-10 07:54:50 +0000
commit80722b2de9e24617450c1727b4aa619ca5f8709d (patch)
tree824cf99f86da8f5c8de98cee1f0139be84d314bd
parent49a9c05b2eafc9b4ed09f9e7b54c8a3a1a269afe (diff)
downloadchromium_src-80722b2de9e24617450c1727b4aa619ca5f8709d.zip
chromium_src-80722b2de9e24617450c1727b4aa619ca5f8709d.tar.gz
chromium_src-80722b2de9e24617450c1727b4aa619ca5f8709d.tar.bz2
Fixing the bug, that caused UI to hang after unsupported device was inserted.
In the idle.h new synchronous method was added - IsWorkstationInLockedState. BUG=chromium-os:20261 TEST=None Review URL: http://codereview.chromium.org/7864022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100582 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/idle.cc25
-rw-r--r--chrome/browser/idle.h6
-rw-r--r--chrome/browser/idle_chromeos.cc9
-rw-r--r--chrome/browser/idle_linux.cc17
-rw-r--r--chrome/browser/idle_mac.mm10
-rw-r--r--chrome/browser/idle_win.cc6
-rw-r--r--chrome/browser/notifications/notification_ui_manager.cc3
-rw-r--r--chrome/chrome_browser.gypi1
8 files changed, 35 insertions, 42 deletions
diff --git a/chrome/browser/idle.cc b/chrome/browser/idle.cc
deleted file mode 100644
index 73b5613..0000000
--- a/chrome/browser/idle.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-// 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/idle.h"
-
-#include "base/bind.h"
-#include "base/synchronization/waitable_event.h"
-
-
-
-void IdleStateCallback(IdleState* return_state, base::WaitableEvent* done,
- IdleState state) {
- *return_state = state;
- done->Signal();
-}
-
-IdleState CalculateIdleStateSync(unsigned int idle_threshold) {
- IdleState return_state;
- base::WaitableEvent done(true, false);
- CalculateIdleState(idle_threshold, base::Bind(&IdleStateCallback,
- &return_state, &done));
- done.Wait();
- return return_state;
-}
diff --git a/chrome/browser/idle.h b/chrome/browser/idle.h
index 05b5066..dfda8d7 100644
--- a/chrome/browser/idle.h
+++ b/chrome/browser/idle.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -27,7 +27,7 @@ typedef base::Callback<void(IdleState)> IdleCallback;
// Calculate the Idle state and notify the callback.
void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify);
-// Calculate the Idle state synchronously and return the state.
-IdleState CalculateIdleStateSync(unsigned int idle_threshold);
+// Checks synchronously if Idle state is IDLE_STATE_LOCKED.
+bool CheckIdleStateIsLocked();
#endif // CHROME_BROWSER_IDLE_H_
diff --git a/chrome/browser/idle_chromeos.cc b/chrome/browser/idle_chromeos.cc
index 2971fb9..5cebff8 100644
--- a/chrome/browser/idle_chromeos.cc
+++ b/chrome/browser/idle_chromeos.cc
@@ -22,9 +22,18 @@ void CalculateIdleStateNotifier(unsigned int idle_treshold,
}
void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) {
+ if (CheckIdleStateIsLocked()) {
+ notify.Run(IDLE_STATE_LOCKED);
+ return;
+ }
chromeos::CalculateIdleTimeCallback* callback =
new base::Callback<void(int64_t)>(base::Bind(&CalculateIdleStateNotifier,
idle_threshold,
notify));
chromeos::CrosLibrary::Get()->GetPowerLibrary()->CalculateIdleTime(callback);
}
+
+bool CheckIdleStateIsLocked() {
+ // TODO(sidor): Make it work.
+ return false;
+}
diff --git a/chrome/browser/idle_linux.cc b/chrome/browser/idle_linux.cc
index eba7958..dacde8b 100644
--- a/chrome/browser/idle_linux.cc
+++ b/chrome/browser/idle_linux.cc
@@ -64,16 +64,10 @@ bool ScreensaverWindowExists() {
}
void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) {
- // Usually the screensaver is used to lock the screen, so we do not need to
- // check if the workstation is locked.
- gdk_error_trap_push();
- bool result = ScreensaverWindowExists();
- bool got_error = gdk_error_trap_pop();
- if (result && !got_error) {
+ if (CheckIdleStateIsLocked()) {
notify.Run(IDLE_STATE_LOCKED);
return;
}
-
browser::IdleQueryLinux idle_query;
unsigned int idle_time = idle_query.IdleTime();
if (idle_time >= idle_threshold)
@@ -81,3 +75,12 @@ void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) {
else
notify.Run(IDLE_STATE_ACTIVE);
}
+
+bool CheckIdleStateIsLocked() {
+ // Usually the screensaver is used to lock the screen, so we do not need to
+ // check if the workstation is locked.
+ gdk_error_trap_push();
+ bool result = ScreensaverWindowExists();
+ bool got_error = gdk_error_trap_pop();
+ return result && !got_error;
+}
diff --git a/chrome/browser/idle_mac.mm b/chrome/browser/idle_mac.mm
index e1ab476..481bc37 100644
--- a/chrome/browser/idle_mac.mm
+++ b/chrome/browser/idle_mac.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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.
@@ -85,8 +85,7 @@ void StopIdleMonitor() {
}
void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) {
- if ([g_screenMonitor isScreensaverRunning] ||
- [g_screenMonitor isScreenLocked]) {
+ if (CheckIdleStateIsLocked()) {
notify.Run(IDLE_STATE_LOCKED);
return;
}
@@ -99,3 +98,8 @@ void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) {
else
notify.Run(IDLE_STATE_ACTIVE);
}
+
+bool CheckIdleStateIsLocked() {
+ return [g_screenMonitor isScreensaverRunning] ||
+ [g_screenMonitor isScreenLocked];
+}
diff --git a/chrome/browser/idle_win.cc b/chrome/browser/idle_win.cc
index c745ca9..784bee7 100644
--- a/chrome/browser/idle_win.cc
+++ b/chrome/browser/idle_win.cc
@@ -11,7 +11,7 @@ static bool IsScreensaverRunning();
static bool IsWorkstationLocked();
void CalculateIdleState(unsigned int idle_threshold, IdleCallback notify) {
- if (IsScreensaverRunning() || IsWorkstationLocked()) {
+ if (CheckIdleStateIsLocked()) {
notify.Run(IDLE_STATE_LOCKED);
return;
}
@@ -67,3 +67,7 @@ bool IsWorkstationLocked() {
}
return is_locked;
}
+
+bool CheckIdleStateIsLocked() {
+ return IsWorkstationLocked() || IsScreensaverRunning();
+}
diff --git a/chrome/browser/notifications/notification_ui_manager.cc b/chrome/browser/notifications/notification_ui_manager.cc
index f4ed3d8..968d903 100644
--- a/chrome/browser/notifications/notification_ui_manager.cc
+++ b/chrome/browser/notifications/notification_ui_manager.cc
@@ -152,8 +152,7 @@ void NotificationUIManager::CheckAndShowNotifications() {
void NotificationUIManager::CheckUserState() {
bool is_user_active_previously = is_user_active_;
- is_user_active_ = CalculateIdleStateSync(0) != IDLE_STATE_LOCKED &&
- !IsFullScreenMode();
+ is_user_active_ = !CheckIdleStateIsLocked() && !IsFullScreenMode();
if (is_user_active_ == is_user_active_previously)
return;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index a6e97e5..f356351 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1311,7 +1311,6 @@
'browser/icon_manager_linux.cc',
'browser/icon_manager_mac.mm',
'browser/icon_manager_win.cc',
- 'browser/idle.cc',
'browser/idle_chromeos.cc',
'browser/idle_linux.cc',
'browser/idle_mac.mm',