summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ash/ash.gyp6
-rw-r--r--ash/session_state_delegate.h4
-rw-r--r--ash/session_state_delegate_stub.cc4
-rw-r--r--ash/session_state_delegate_stub.h1
-rw-r--r--ash/shell.cc18
-rw-r--r--ash/shell.h12
-rw-r--r--ash/system/chromeos/power/suspend_observer.cc (renamed from chrome/browser/chromeos/power/suspend_observer.cc)34
-rw-r--r--ash/system/chromeos/power/suspend_observer.h (renamed from chrome/browser/chromeos/power/suspend_observer.h)26
-rw-r--r--ash/system/chromeos/power/user_activity_notifier.cc (renamed from chrome/browser/chromeos/power/user_activity_notifier.cc)22
-rw-r--r--ash/system/chromeos/power/user_activity_notifier.h40
-rw-r--r--ash/system/chromeos/power/video_activity_notifier.cc (renamed from chrome/browser/chromeos/power/video_activity_notifier.cc)23
-rw-r--r--ash/system/chromeos/power/video_activity_notifier.h (renamed from chrome/browser/chromeos/power/video_activity_notifier.h)22
-rw-r--r--ash/test/test_session_state_delegate.cc4
-rw-r--r--ash/test/test_session_state_delegate.h1
-rw-r--r--chrome/browser/chromeos/chrome_browser_main_chromeos.cc9
-rw-r--r--chrome/browser/chromeos/chrome_browser_main_chromeos.h6
-rw-r--r--chrome/browser/chromeos/power/user_activity_notifier.h33
-rw-r--r--chrome/browser/ui/ash/session_state_delegate_chromeos.cc9
-rw-r--r--chrome/browser/ui/ash/session_state_delegate_chromeos.h1
-rw-r--r--chrome/browser/ui/ash/session_state_delegate_views.cc4
-rw-r--r--chrome/browser/ui/ash/session_state_delegate_views.h1
-rw-r--r--chrome/chrome_browser_chromeos.gypi6
22 files changed, 172 insertions, 114 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 391b487..29e136b 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -262,8 +262,14 @@
'system/chromeos/power/power_status.h',
'system/chromeos/power/power_status_view.cc',
'system/chromeos/power/power_status_view.h',
+ 'system/chromeos/power/suspend_observer.cc',
+ 'system/chromeos/power/suspend_observer.h',
'system/chromeos/power/tray_power.cc',
'system/chromeos/power/tray_power.h',
+ 'system/chromeos/power/user_activity_notifier.cc',
+ 'system/chromeos/power/user_activity_notifier.h',
+ 'system/chromeos/power/video_activity_notifier.cc',
+ 'system/chromeos/power/video_activity_notifier.h',
'system/chromeos/screen_security/screen_capture_observer.h',
'system/chromeos/screen_security/screen_capture_tray_item.cc',
'system/chromeos/screen_security/screen_capture_tray_item.h',
diff --git a/ash/session_state_delegate.h b/ash/session_state_delegate.h
index f8219bd..5fdd8c5 100644
--- a/ash/session_state_delegate.h
+++ b/ash/session_state_delegate.h
@@ -50,6 +50,10 @@ class ASH_EXPORT SessionStateDelegate {
// Returns true if the screen is currently locked.
virtual bool IsScreenLocked() const = 0;
+ // Returns true if the screen should be locked when the system is about to
+ // suspend.
+ virtual bool ShouldLockScreenBeforeSuspending() const = 0;
+
// Locks the screen. The locking happens asynchronously.
virtual void LockScreen() = 0;
diff --git a/ash/session_state_delegate_stub.cc b/ash/session_state_delegate_stub.cc
index 587d61f..c794321 100644
--- a/ash/session_state_delegate_stub.cc
+++ b/ash/session_state_delegate_stub.cc
@@ -37,6 +37,10 @@ bool SessionStateDelegateStub::IsScreenLocked() const {
return screen_locked_;
}
+bool SessionStateDelegateStub::ShouldLockScreenBeforeSuspending() const {
+ return false;
+}
+
void SessionStateDelegateStub::LockScreen() {
shell::CreateLockScreen();
screen_locked_ = true;
diff --git a/ash/session_state_delegate_stub.h b/ash/session_state_delegate_stub.h
index afd63dd..1da46fc 100644
--- a/ash/session_state_delegate_stub.h
+++ b/ash/session_state_delegate_stub.h
@@ -24,6 +24,7 @@ class SessionStateDelegateStub : public SessionStateDelegate {
virtual bool IsActiveUserSessionStarted() const OVERRIDE;
virtual bool CanLockScreen() const OVERRIDE;
virtual bool IsScreenLocked() const OVERRIDE;
+ virtual bool ShouldLockScreenBeforeSuspending() const OVERRIDE;
virtual void LockScreen() OVERRIDE;
virtual void UnlockScreen() OVERRIDE;
virtual bool IsUserSessionBlocked() const OVERRIDE;
diff --git a/ash/shell.cc b/ash/shell.cc
index ff2e643..8b0e939 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -122,6 +122,9 @@
#endif // defined(USE_X11)
#include "ash/system/chromeos/brightness/brightness_controller_chromeos.h"
#include "ash/system/chromeos/power/power_status.h"
+#include "ash/system/chromeos/power/suspend_observer.h"
+#include "ash/system/chromeos/power/user_activity_notifier.h"
+#include "ash/system/chromeos/power/video_activity_notifier.h"
#endif // defined(OS_CHROMEOS)
namespace ash {
@@ -539,7 +542,7 @@ Shell::Shell(ShellDelegate* delegate)
activation_client_(NULL),
#if defined(OS_CHROMEOS) && defined(USE_X11)
output_configurator_(new chromeos::OutputConfigurator()),
-#endif // defined(OS_CHROMEOS)
+#endif // defined(OS_CHROMEOS) && defined(USE_X11)
native_cursor_manager_(new AshNativeCursorManager),
cursor_manager_(scoped_ptr<views::corewm::NativeCursorManager>(
native_cursor_manager_)),
@@ -622,6 +625,11 @@ Shell::~Shell() {
// needs to remove observers from it.
system_tray_notifier_.reset();
+#if defined(OS_CHROMEOS)
+ // Destroy VideoActivityNotifier before destroying VideoDetector.
+ video_activity_notifier_.reset();
+#endif // defined(OS_CHROMEOS)
+
// These need a valid Shell instance to clean up properly, so explicitly
// delete them before invalidating the instance.
// Alphabetical. TODO(oshima): sort.
@@ -869,11 +877,17 @@ void Shell::Init() {
env_filter_->set_cursor_hidden_by_filter(true);
}
- // Set accelerator controller delegates.
#if defined(OS_CHROMEOS)
+ // Set accelerator controller delegates.
accelerator_controller_->SetBrightnessControlDelegate(
scoped_ptr<ash::BrightnessControlDelegate>(
new ash::system::BrightnessControllerChromeos).Pass());
+
+ suspend_observer_.reset(new internal::SuspendObserver());
+ user_activity_notifier_.reset(
+ new internal::UserActivityNotifier(user_activity_detector_.get()));
+ video_activity_notifier_.reset(
+ new internal::VideoActivityNotifier(video_detector_.get()));
#endif
// The compositor thread and main message loop have to be running in
diff --git a/ash/shell.h b/ash/shell.h
index 0c8d7dd..f04c511 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -129,9 +129,12 @@ class ScopedTargetRootWindow;
class ScreenPositionController;
class SlowAnimationEventFilter;
class StatusAreaWidget;
+class SuspendObserver;
class SystemGestureEventFilter;
class SystemModalContainerEventFilter;
class TouchObserverHUD;
+class UserActivityNotifier;
+class VideoActivityNotifier;
}
namespace shell {
@@ -622,7 +625,11 @@ class ASH_EXPORT Shell
scoped_ptr<internal::LocaleNotificationController>
locale_notification_controller_;
-#if defined(OS_CHROMEOS) && defined(USE_X11)
+#if defined(OS_CHROMEOS)
+ scoped_ptr<internal::SuspendObserver> suspend_observer_;
+ scoped_ptr<internal::UserActivityNotifier> user_activity_notifier_;
+ scoped_ptr<internal::VideoActivityNotifier> video_activity_notifier_;
+#if defined(USE_X11)
// Controls video output device state.
scoped_ptr<chromeos::OutputConfigurator> output_configurator_;
scoped_ptr<internal::OutputConfiguratorAnimation>
@@ -631,7 +638,8 @@ class ASH_EXPORT Shell
// Listens for output changes and updates the display manager.
scoped_ptr<internal::DisplayChangeObserver> display_change_observer_;
-#endif // defined(OS_CHROMEOS) && defined(USE_X11)
+#endif // defined(USE_X11)
+#endif // defined(OS_CHROMEOS)
scoped_ptr<internal::ResolutionNotificationController>
resolution_notification_controller_;
diff --git a/chrome/browser/chromeos/power/suspend_observer.cc b/ash/system/chromeos/power/suspend_observer.cc
index 3ae7f11..7e9119c 100644
--- a/chrome/browser/chromeos/power/suspend_observer.cc
+++ b/ash/system/chromeos/power/suspend_observer.cc
@@ -1,25 +1,24 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 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/power/suspend_observer.h"
+#include "ash/system/chromeos/power/suspend_observer.h"
+#include "ash/session_state_delegate.h"
#include "ash/shell.h"
#include "ash/wm/user_activity_detector.h"
#include "base/prefs/pref_service.h"
-#include "chrome/browser/chromeos/login/user_manager.h"
-#include "chrome/browser/extensions/api/system_private/system_private_api.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/common/pref_names.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/display/output_configurator.h"
-namespace chromeos {
+namespace ash {
+namespace internal {
SuspendObserver::SuspendObserver()
- : power_client_(DBusThreadManager::Get()->GetPowerManagerClient()),
- session_client_(DBusThreadManager::Get()->GetSessionManagerClient()),
+ : power_client_(
+ chromeos::DBusThreadManager::Get()->GetPowerManagerClient()),
+ session_client_(
+ chromeos::DBusThreadManager::Get()->GetSessionManagerClient()),
screen_locked_(false) {
power_client_->AddObserver(this);
session_client_->AddObserver(this);
@@ -33,18 +32,20 @@ SuspendObserver::~SuspendObserver() {
}
void SuspendObserver::SuspendImminent() {
+ Shell* shell = Shell::GetInstance();
+ SessionStateDelegate* delegate = shell->session_state_delegate();
+
// If the lock-before-suspending pref is set, get a callback to block
// suspend and ask the session manager to lock the screen.
- Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
- if (profile && profile->GetPrefs()->GetBoolean(prefs::kEnableScreenLock) &&
- UserManager::Get()->CanCurrentUserLock() && !screen_locked_) {
+ if (!screen_locked_ && delegate->ShouldLockScreenBeforeSuspending() &&
+ delegate->CanLockScreen()) {
screen_lock_callback_ = power_client_->GetSuspendReadinessCallback();
VLOG(1) << "Requesting screen lock from SuspendObserver";
session_client_->RequestLockScreen();
}
- ash::Shell::GetInstance()->user_activity_detector()->OnDisplayPowerChanging();
- ash::Shell::GetInstance()->output_configurator()->SuspendDisplays();
+ shell->user_activity_detector()->OnDisplayPowerChanging();
+ shell->output_configurator()->SuspendDisplays();
}
void SuspendObserver::ScreenIsLocked() {
@@ -67,4 +68,5 @@ void SuspendObserver::ScreenIsUnlocked() {
screen_locked_ = false;
}
-} // namespace chromeos
+} // namespace internal
+} // namespace ash
diff --git a/chrome/browser/chromeos/power/suspend_observer.h b/ash/system/chromeos/power/suspend_observer.h
index 273b7dc..17cc931 100644
--- a/chrome/browser/chromeos/power/suspend_observer.h
+++ b/ash/system/chromeos/power/suspend_observer.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2013 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.
-#ifndef CHROME_BROWSER_CHROMEOS_POWER_SUSPEND_OBSERVER_H_
-#define CHROME_BROWSER_CHROMEOS_POWER_SUSPEND_OBSERVER_H_
+#ifndef ASH_SYSTEM_CHROMEOS_POWER_SUSPEND_OBSERVER_H_
+#define ASH_SYSTEM_CHROMEOS_POWER_SUSPEND_OBSERVER_H_
#include "base/basictypes.h"
#include "base/callback.h"
@@ -11,26 +11,27 @@
#include "chromeos/dbus/power_manager_client.h"
#include "chromeos/dbus/session_manager_client.h"
-namespace chromeos {
+namespace ash {
+namespace internal {
// A class to observe suspend events.
-class SuspendObserver : public PowerManagerClient::Observer,
- public SessionManagerClient::Observer {
+class SuspendObserver : public chromeos::PowerManagerClient::Observer,
+ public chromeos::SessionManagerClient::Observer {
public:
// This class registers/unregisters itself as an observer in ctor/dtor.
SuspendObserver();
virtual ~SuspendObserver();
- // PowerManagerClient::Observer override.
+ // chromeos::PowerManagerClient::Observer override.
virtual void SuspendImminent() OVERRIDE;
- // SessionManagerClient::Observer overrides.
+ // chromeos::SessionManagerClient::Observer overrides.
virtual void ScreenIsLocked() OVERRIDE;
virtual void ScreenIsUnlocked() OVERRIDE;
private:
- PowerManagerClient* power_client_; // not owned
- SessionManagerClient* session_client_; // not owned
+ chromeos::PowerManagerClient* power_client_; // not owned
+ chromeos::SessionManagerClient* session_client_; // not owned
// Is the screen currently locked?
bool screen_locked_;
@@ -42,6 +43,7 @@ class SuspendObserver : public PowerManagerClient::Observer,
DISALLOW_COPY_AND_ASSIGN(SuspendObserver);
};
-} // namespace chromeos
+} // namespace internal
+} // namespace ash
-#endif // CHROME_BROWSER_CHROMEOS_POWER_SUSPEND_OBSERVER_H_
+#endif // ASH_SYSTEM_CHROMEOS_POWER_SUSPEND_OBSERVER_H_
diff --git a/chrome/browser/chromeos/power/user_activity_notifier.cc b/ash/system/chromeos/power/user_activity_notifier.cc
index 02aea36..921363c 100644
--- a/chrome/browser/chromeos/power/user_activity_notifier.cc
+++ b/ash/system/chromeos/power/user_activity_notifier.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2013 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/power/user_activity_notifier.h"
+#include "ash/system/chromeos/power/user_activity_notifier.h"
#include "ash/shell.h"
#include "ash/wm/user_activity_detector.h"
@@ -12,6 +12,9 @@
#include "ui/events/event_constants.h"
#include "ui/events/keycodes/keyboard_codes_posix.h"
+namespace ash {
+namespace internal {
+
namespace {
// Minimum number of seconds between notifications.
@@ -19,14 +22,13 @@ const int kNotifyIntervalSec = 5;
} // namespace
-namespace chromeos {
-
-UserActivityNotifier::UserActivityNotifier() {
- ash::Shell::GetInstance()->user_activity_detector()->AddObserver(this);
+UserActivityNotifier::UserActivityNotifier(UserActivityDetector* detector)
+ : detector_(detector) {
+ detector_->AddObserver(this);
}
UserActivityNotifier::~UserActivityNotifier() {
- ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this);
+ detector_->RemoveObserver(this);
}
void UserActivityNotifier::OnUserActivity(const ui::Event* event) {
@@ -49,9 +51,11 @@ void UserActivityNotifier::OnUserActivity(const ui::Event* event) {
}
}
- DBusThreadManager::Get()->GetPowerManagerClient()->NotifyUserActivity(type);
+ chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
+ NotifyUserActivity(type);
last_notify_time_ = now;
}
}
-} // namespace chromeos
+} // namespace internal
+} // namespace ash
diff --git a/ash/system/chromeos/power/user_activity_notifier.h b/ash/system/chromeos/power/user_activity_notifier.h
new file mode 100644
index 0000000..78b2c43
--- /dev/null
+++ b/ash/system/chromeos/power/user_activity_notifier.h
@@ -0,0 +1,40 @@
+// Copyright 2013 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.
+
+#ifndef ASH_SYSTEM_CHROMEOS_POWER_USER_ACTIVITY_NOTIFIER_H_
+#define ASH_SYSTEM_CHROMEOS_POWER_USER_ACTIVITY_NOTIFIER_H_
+
+#include "ash/wm/user_activity_observer.h"
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/time/time.h"
+
+namespace ash {
+
+class UserActivityDetector;
+
+namespace internal {
+
+// Notifies the power manager when the user is active.
+class UserActivityNotifier : public UserActivityObserver {
+ public:
+ explicit UserActivityNotifier(UserActivityDetector* detector);
+ virtual ~UserActivityNotifier();
+
+ // UserActivityObserver implementation.
+ virtual void OnUserActivity(const ui::Event* event) OVERRIDE;
+
+ private:
+ UserActivityDetector* detector_; // not owned
+
+ // Last time that the power manager was notified.
+ base::TimeTicks last_notify_time_;
+
+ DISALLOW_COPY_AND_ASSIGN(UserActivityNotifier);
+};
+
+} // namespace internal
+} // namespace ash
+
+#endif // ASH_SYSTEM_CHROMEOS_POWER_USER_ACTIVITY_NOTIFIER_H_
diff --git a/chrome/browser/chromeos/power/video_activity_notifier.cc b/ash/system/chromeos/power/video_activity_notifier.cc
index 3f0698c..0f9ec25 100644
--- a/chrome/browser/chromeos/power/video_activity_notifier.cc
+++ b/ash/system/chromeos/power/video_activity_notifier.cc
@@ -1,13 +1,16 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2013 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/power/video_activity_notifier.h"
+#include "ash/system/chromeos/power/video_activity_notifier.h"
#include "ash/shell.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_manager_client.h"
+namespace ash {
+namespace internal {
+
namespace {
// Minimum number of seconds between notifications.
@@ -15,24 +18,24 @@ const int kNotifyIntervalSec = 5;
} // namespace
-namespace chromeos {
-
-VideoActivityNotifier::VideoActivityNotifier() {
- ash::Shell::GetInstance()->video_detector()->AddObserver(this);
+VideoActivityNotifier::VideoActivityNotifier(VideoDetector* detector)
+ : detector_(detector) {
+ detector_->AddObserver(this);
}
VideoActivityNotifier::~VideoActivityNotifier() {
- ash::Shell::GetInstance()->video_detector()->RemoveObserver(this);
+ detector_->RemoveObserver(this);
}
void VideoActivityNotifier::OnVideoDetected(bool is_fullscreen) {
base::TimeTicks now = base::TimeTicks::Now();
if (last_notify_time_.is_null() ||
(now - last_notify_time_).InSeconds() >= kNotifyIntervalSec) {
- DBusThreadManager::Get()->GetPowerManagerClient()->NotifyVideoActivity(
- is_fullscreen);
+ chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
+ NotifyVideoActivity(is_fullscreen);
last_notify_time_ = now;
}
}
-} // namespace chromeos
+} // namespace internal
+} // namespace ash
diff --git a/chrome/browser/chromeos/power/video_activity_notifier.h b/ash/system/chromeos/power/video_activity_notifier.h
index ffe2a2c..66569c4 100644
--- a/chrome/browser/chromeos/power/video_activity_notifier.h
+++ b/ash/system/chromeos/power/video_activity_notifier.h
@@ -1,33 +1,37 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2013 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.
-#ifndef CHROME_BROWSER_CHROMEOS_POWER_VIDEO_ACTIVITY_NOTIFIER_H_
-#define CHROME_BROWSER_CHROMEOS_POWER_VIDEO_ACTIVITY_NOTIFIER_H_
+#ifndef ASH_SYSTEM_CHROMEOS_POWER_VIDEO_ACTIVITY_NOTIFIER_H_
+#define ASH_SYSTEM_CHROMEOS_POWER_VIDEO_ACTIVITY_NOTIFIER_H_
#include "ash/wm/video_detector.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/time/time.h"
-namespace chromeos {
+namespace ash {
+namespace internal {
// Notifies the power manager when a video is playing.
-class VideoActivityNotifier : public ash::VideoDetectorObserver {
+class VideoActivityNotifier : public VideoDetectorObserver {
public:
- VideoActivityNotifier();
+ explicit VideoActivityNotifier(VideoDetector* detector);
virtual ~VideoActivityNotifier();
- // ash::VideoDetectorObserver implementation.
+ // VideoDetectorObserver implementation.
virtual void OnVideoDetected(bool is_fullscreen) OVERRIDE;
private:
+ VideoDetector* detector_; // not owned
+
// Last time that the power manager was notified.
base::TimeTicks last_notify_time_;
DISALLOW_COPY_AND_ASSIGN(VideoActivityNotifier);
};
-} // namespace chromeos
+} // namespace internal
+} // namespace ash
-#endif // CHROME_BROWSER_CHROMEOS_POWER_VIDEO_ACTIVITY_NOTIFIER_H_
+#endif // ASH_SYSTEM_CHROMEOS_POWER_VIDEO_ACTIVITY_NOTIFIER_H_
diff --git a/ash/test/test_session_state_delegate.cc b/ash/test/test_session_state_delegate.cc
index d61bb85..f956d8b 100644
--- a/ash/test/test_session_state_delegate.cc
+++ b/ash/test/test_session_state_delegate.cc
@@ -45,6 +45,10 @@ bool TestSessionStateDelegate::IsScreenLocked() const {
return screen_locked_;
}
+bool TestSessionStateDelegate::ShouldLockScreenBeforeSuspending() const {
+ return false;
+}
+
void TestSessionStateDelegate::LockScreen() {
if (CanLockScreen())
screen_locked_ = true;
diff --git a/ash/test/test_session_state_delegate.h b/ash/test/test_session_state_delegate.h
index 40ba70d..8708cdf 100644
--- a/ash/test/test_session_state_delegate.h
+++ b/ash/test/test_session_state_delegate.h
@@ -27,6 +27,7 @@ class TestSessionStateDelegate : public SessionStateDelegate {
virtual bool IsActiveUserSessionStarted() const OVERRIDE;
virtual bool CanLockScreen() const OVERRIDE;
virtual bool IsScreenLocked() const OVERRIDE;
+ virtual bool ShouldLockScreenBeforeSuspending() const OVERRIDE;
virtual void LockScreen() OVERRIDE;
virtual void UnlockScreen() OVERRIDE;
virtual bool IsUserSessionBlocked() const OVERRIDE;
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
index fcbd489..01f2ebc 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
@@ -58,9 +58,6 @@
#include "chrome/browser/chromeos/power/power_prefs.h"
#include "chrome/browser/chromeos/power/resume_observer.h"
#include "chrome/browser/chromeos/power/screen_lock_observer.h"
-#include "chrome/browser/chromeos/power/suspend_observer.h"
-#include "chrome/browser/chromeos/power/user_activity_notifier.h"
-#include "chrome/browser/chromeos/power/video_activity_notifier.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/screensaver/screensaver_controller.h"
#include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h"
@@ -606,7 +603,6 @@ void ChromeBrowserMainPartsChromeos::PostProfileInit() {
switches::kEnableScreensaverExtensions)) {
screensaver_controller_.reset(new ScreensaverController());
}
- suspend_observer_.reset(new SuspendObserver());
if (KioskModeSettings::Get()->IsKioskModeEnabled()) {
retail_mode_power_save_blocker_ = content::PowerSaveBlocker::Create(
content::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
@@ -675,8 +671,6 @@ void ChromeBrowserMainPartsChromeos::PostBrowserStart() {
// These are dependent on the ash::Shell singleton already having been
// initialized.
power_button_observer_.reset(new PowerButtonObserver);
- user_activity_notifier_.reset(new UserActivityNotifier);
- video_activity_notifier_.reset(new VideoActivityNotifier);
data_promo_notification_.reset(new DataPromoNotification()),
ChromeBrowserMainPartsLinux::PostBrowserStart();
@@ -718,7 +712,6 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
// We should remove observers attached to D-Bus clients before
// DBusThreadManager is shut down.
screen_lock_observer_.reset();
- suspend_observer_.reset();
resume_observer_.reset();
brightness_observer_.reset();
retail_mode_power_save_blocker_.reset();
@@ -741,8 +734,6 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() {
// Let classes unregister themselves as observers of the ash::Shell singleton
// before the shell is destroyed.
- user_activity_notifier_.reset();
- video_activity_notifier_.reset();
display_configuration_observer_.reset();
// Detach D-Bus clients before DBusThreadManager is shut down.
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.h b/chrome/browser/chromeos/chrome_browser_main_chromeos.h
index 6cce24f..409e12c 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.h
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.h
@@ -32,10 +32,7 @@ class ResumeObserver;
class ScreenLockObserver;
class ScreensaverController;
class SessionManagerObserver;
-class SuspendObserver;
class SwapMetrics;
-class UserActivityNotifier;
-class VideoActivityNotifier;
namespace default_app_order {
class ExternalLoader;
@@ -73,7 +70,6 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux {
scoped_ptr<BrightnessObserver> brightness_observer_;
scoped_ptr<DisplayConfigurationObserver> display_configuration_observer_;
scoped_ptr<default_app_order::ExternalLoader> app_order_loader_;
- scoped_ptr<SuspendObserver> suspend_observer_;
scoped_ptr<ResumeObserver> resume_observer_;
scoped_ptr<ScreenLockObserver> screen_lock_observer_;
scoped_ptr<ScreensaverController> screensaver_controller_;
@@ -81,8 +77,6 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux {
scoped_ptr<PowerPrefs> power_prefs_;
scoped_ptr<PowerButtonObserver> power_button_observer_;
scoped_ptr<content::PowerSaveBlocker> retail_mode_power_save_blocker_;
- scoped_ptr<UserActivityNotifier> user_activity_notifier_;
- scoped_ptr<VideoActivityNotifier> video_activity_notifier_;
scoped_ptr<IdleActionWarningObserver> idle_action_warning_observer_;
scoped_ptr<DataPromoNotification> data_promo_notification_;
diff --git a/chrome/browser/chromeos/power/user_activity_notifier.h b/chrome/browser/chromeos/power/user_activity_notifier.h
deleted file mode 100644
index e44a42b..0000000
--- a/chrome/browser/chromeos/power/user_activity_notifier.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2012 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.
-
-#ifndef CHROME_BROWSER_CHROMEOS_POWER_USER_ACTIVITY_NOTIFIER_H_
-#define CHROME_BROWSER_CHROMEOS_POWER_USER_ACTIVITY_NOTIFIER_H_
-
-#include "ash/wm/user_activity_observer.h"
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "base/time/time.h"
-
-namespace chromeos {
-
-// Notifies the power manager when the user is active.
-class UserActivityNotifier : public ash::UserActivityObserver {
- public:
- UserActivityNotifier();
- virtual ~UserActivityNotifier();
-
- // ash::UserActivityObserver implementation.
- virtual void OnUserActivity(const ui::Event* event) OVERRIDE;
-
- private:
- // Last time that the power manager was notified.
- base::TimeTicks last_notify_time_;
-
- DISALLOW_COPY_AND_ASSIGN(UserActivityNotifier);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_CHROMEOS_POWER_USER_ACTIVITY_NOTIFIER_H_
diff --git a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
index f95c40f..154df7f 100644
--- a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
@@ -7,10 +7,14 @@
#include "ash/session_state_observer.h"
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/prefs/pref_service.h"
#include "chrome/browser/chromeos/login/screen_locker.h"
#include "chrome/browser/chromeos/login/user.h"
#include "chrome/browser/chromeos/login/user_adding_screen.h"
#include "chrome/browser/chromeos/login/user_manager.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/common/pref_names.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
@@ -44,6 +48,11 @@ bool SessionStateDelegateChromeos::IsScreenLocked() const {
chromeos::ScreenLocker::default_screen_locker()->locked();
}
+bool SessionStateDelegateChromeos::ShouldLockScreenBeforeSuspending() const {
+ Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
+ return profile && profile->GetPrefs()->GetBoolean(prefs::kEnableScreenLock);
+}
+
void SessionStateDelegateChromeos::LockScreen() {
if (!CanLockScreen())
return;
diff --git a/chrome/browser/ui/ash/session_state_delegate_chromeos.h b/chrome/browser/ui/ash/session_state_delegate_chromeos.h
index 56fd9c3..c9cd3fd 100644
--- a/chrome/browser/ui/ash/session_state_delegate_chromeos.h
+++ b/chrome/browser/ui/ash/session_state_delegate_chromeos.h
@@ -28,6 +28,7 @@ class SessionStateDelegateChromeos
virtual bool IsActiveUserSessionStarted() const OVERRIDE;
virtual bool CanLockScreen() const OVERRIDE;
virtual bool IsScreenLocked() const OVERRIDE;
+ virtual bool ShouldLockScreenBeforeSuspending() const OVERRIDE;
virtual void LockScreen() OVERRIDE;
virtual void UnlockScreen() OVERRIDE;
virtual bool IsUserSessionBlocked() const OVERRIDE;
diff --git a/chrome/browser/ui/ash/session_state_delegate_views.cc b/chrome/browser/ui/ash/session_state_delegate_views.cc
index 499b3f9..bc42053 100644
--- a/chrome/browser/ui/ash/session_state_delegate_views.cc
+++ b/chrome/browser/ui/ash/session_state_delegate_views.cc
@@ -40,6 +40,10 @@ bool SessionStateDelegate::IsScreenLocked() const {
return false;
}
+bool SessionStateDelegate::ShouldLockScreenBeforeSuspending() const {
+ return false;
+}
+
void SessionStateDelegate::LockScreen() {
}
diff --git a/chrome/browser/ui/ash/session_state_delegate_views.h b/chrome/browser/ui/ash/session_state_delegate_views.h
index d8e5441..c5117d5 100644
--- a/chrome/browser/ui/ash/session_state_delegate_views.h
+++ b/chrome/browser/ui/ash/session_state_delegate_views.h
@@ -25,6 +25,7 @@ class SessionStateDelegate : public ash::SessionStateDelegate {
virtual bool IsActiveUserSessionStarted() const OVERRIDE;
virtual bool CanLockScreen() const OVERRIDE;
virtual bool IsScreenLocked() const OVERRIDE;
+ virtual bool ShouldLockScreenBeforeSuspending() const OVERRIDE;
virtual void LockScreen() OVERRIDE;
virtual void UnlockScreen() OVERRIDE;
virtual bool IsUserSessionBlocked() const OVERRIDE;
diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi
index 88619be..40b0735 100644
--- a/chrome/chrome_browser_chromeos.gypi
+++ b/chrome/chrome_browser_chromeos.gypi
@@ -735,12 +735,6 @@
'browser/chromeos/power/screen_lock_observer.h',
'browser/chromeos/power/session_state_controller_delegate_chromeos.cc',
'browser/chromeos/power/session_state_controller_delegate_chromeos.h',
- 'browser/chromeos/power/suspend_observer.cc',
- 'browser/chromeos/power/suspend_observer.h',
- 'browser/chromeos/power/user_activity_notifier.cc',
- 'browser/chromeos/power/user_activity_notifier.h',
- 'browser/chromeos/power/video_activity_notifier.cc',
- 'browser/chromeos/power/video_activity_notifier.h',
'browser/chromeos/preferences.cc',
'browser/chromeos/preferences.h',
'browser/chromeos/prerender_condition_network.cc',