summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-08 19:17:19 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-08 19:17:19 +0000
commit5c04d3a953f95665b448a6d74fee79c22ac9d375 (patch)
tree4de5e4c5ffcc2158df3bef177529dd421d710f2c
parent00016895fdcf0a081d812369c13ae5b9a9f7f04f (diff)
downloadchromium_src-5c04d3a953f95665b448a6d74fee79c22ac9d375.zip
chromium_src-5c04d3a953f95665b448a6d74fee79c22ac9d375.tar.gz
chromium_src-5c04d3a953f95665b448a6d74fee79c22ac9d375.tar.bz2
Revert r227544, "chromeos: Move several power-related ..."
This broke the ASAN builders. BUG=none TBR=oshima@chromium.org Review URL: https://codereview.chromium.org/26561002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227562 0039d316-1c4b-4281-b951-d872f2087c98
-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.cc13
-rw-r--r--ash/shell.h12
-rw-r--r--ash/system/chromeos/power/user_activity_notifier.h40
-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/suspend_observer.cc (renamed from ash/system/chromeos/power/suspend_observer.cc)34
-rw-r--r--chrome/browser/chromeos/power/suspend_observer.h (renamed from ash/system/chromeos/power/suspend_observer.h)26
-rw-r--r--chrome/browser/chromeos/power/user_activity_notifier.cc (renamed from ash/system/chromeos/power/user_activity_notifier.cc)22
-rw-r--r--chrome/browser/chromeos/power/user_activity_notifier.h33
-rw-r--r--chrome/browser/chromeos/power/video_activity_notifier.cc (renamed from ash/system/chromeos/power/video_activity_notifier.cc)23
-rw-r--r--chrome/browser/chromeos/power/video_activity_notifier.h (renamed from ash/system/chromeos/power/video_activity_notifier.h)22
-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, 114 insertions, 167 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 29e136b..391b487 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -262,14 +262,8 @@
'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 5fdd8c5..f8219bd 100644
--- a/ash/session_state_delegate.h
+++ b/ash/session_state_delegate.h
@@ -50,10 +50,6 @@ 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 c794321..587d61f 100644
--- a/ash/session_state_delegate_stub.cc
+++ b/ash/session_state_delegate_stub.cc
@@ -37,10 +37,6 @@ 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 1da46fc..afd63dd 100644
--- a/ash/session_state_delegate_stub.h
+++ b/ash/session_state_delegate_stub.h
@@ -24,7 +24,6 @@ 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 94c0d4a..ff2e643 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -122,9 +122,6 @@
#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 {
@@ -542,7 +539,7 @@ Shell::Shell(ShellDelegate* delegate)
activation_client_(NULL),
#if defined(OS_CHROMEOS) && defined(USE_X11)
output_configurator_(new chromeos::OutputConfigurator()),
-#endif // defined(OS_CHROMEOS) && defined(USE_X11)
+#endif // defined(OS_CHROMEOS)
native_cursor_manager_(new AshNativeCursorManager),
cursor_manager_(scoped_ptr<views::corewm::NativeCursorManager>(
native_cursor_manager_)),
@@ -872,17 +869,11 @@ void Shell::Init() {
env_filter_->set_cursor_hidden_by_filter(true);
}
-#if defined(OS_CHROMEOS)
// Set accelerator controller delegates.
+#if defined(OS_CHROMEOS)
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 f04c511..0c8d7dd 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -129,12 +129,9 @@ class ScopedTargetRootWindow;
class ScreenPositionController;
class SlowAnimationEventFilter;
class StatusAreaWidget;
-class SuspendObserver;
class SystemGestureEventFilter;
class SystemModalContainerEventFilter;
class TouchObserverHUD;
-class UserActivityNotifier;
-class VideoActivityNotifier;
}
namespace shell {
@@ -625,11 +622,7 @@ class ASH_EXPORT Shell
scoped_ptr<internal::LocaleNotificationController>
locale_notification_controller_;
-#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)
+#if defined(OS_CHROMEOS) && defined(USE_X11)
// Controls video output device state.
scoped_ptr<chromeos::OutputConfigurator> output_configurator_;
scoped_ptr<internal::OutputConfiguratorAnimation>
@@ -638,8 +631,7 @@ class ASH_EXPORT Shell
// Listens for output changes and updates the display manager.
scoped_ptr<internal::DisplayChangeObserver> display_change_observer_;
-#endif // defined(USE_X11)
-#endif // defined(OS_CHROMEOS)
+#endif // defined(OS_CHROMEOS) && defined(USE_X11)
scoped_ptr<internal::ResolutionNotificationController>
resolution_notification_controller_;
diff --git a/ash/system/chromeos/power/user_activity_notifier.h b/ash/system/chromeos/power/user_activity_notifier.h
deleted file mode 100644
index 78b2c43..0000000
--- a/ash/system/chromeos/power/user_activity_notifier.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// 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/ash/test/test_session_state_delegate.cc b/ash/test/test_session_state_delegate.cc
index f956d8b..d61bb85 100644
--- a/ash/test/test_session_state_delegate.cc
+++ b/ash/test/test_session_state_delegate.cc
@@ -45,10 +45,6 @@ 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 8708cdf..40ba70d 100644
--- a/ash/test/test_session_state_delegate.h
+++ b/ash/test/test_session_state_delegate.h
@@ -27,7 +27,6 @@ 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 01f2ebc..fcbd489 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
@@ -58,6 +58,9 @@
#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"
@@ -603,6 +606,7 @@ 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,
@@ -671,6 +675,8 @@ 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();
@@ -712,6 +718,7 @@ 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();
@@ -734,6 +741,8 @@ 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 409e12c..6cce24f 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.h
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.h
@@ -32,7 +32,10 @@ class ResumeObserver;
class ScreenLockObserver;
class ScreensaverController;
class SessionManagerObserver;
+class SuspendObserver;
class SwapMetrics;
+class UserActivityNotifier;
+class VideoActivityNotifier;
namespace default_app_order {
class ExternalLoader;
@@ -70,6 +73,7 @@ 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_;
@@ -77,6 +81,8 @@ 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/ash/system/chromeos/power/suspend_observer.cc b/chrome/browser/chromeos/power/suspend_observer.cc
index 7e9119c..3ae7f11 100644
--- a/ash/system/chromeos/power/suspend_observer.cc
+++ b/chrome/browser/chromeos/power/suspend_observer.cc
@@ -1,24 +1,25 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright (c) 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 "ash/system/chromeos/power/suspend_observer.h"
+#include "chrome/browser/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 ash {
-namespace internal {
+namespace chromeos {
SuspendObserver::SuspendObserver()
- : power_client_(
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient()),
- session_client_(
- chromeos::DBusThreadManager::Get()->GetSessionManagerClient()),
+ : power_client_(DBusThreadManager::Get()->GetPowerManagerClient()),
+ session_client_(DBusThreadManager::Get()->GetSessionManagerClient()),
screen_locked_(false) {
power_client_->AddObserver(this);
session_client_->AddObserver(this);
@@ -32,20 +33,18 @@ 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.
- if (!screen_locked_ && delegate->ShouldLockScreenBeforeSuspending() &&
- delegate->CanLockScreen()) {
+ Profile* profile = ProfileManager::GetDefaultProfileOrOffTheRecord();
+ if (profile && profile->GetPrefs()->GetBoolean(prefs::kEnableScreenLock) &&
+ UserManager::Get()->CanCurrentUserLock() && !screen_locked_) {
screen_lock_callback_ = power_client_->GetSuspendReadinessCallback();
VLOG(1) << "Requesting screen lock from SuspendObserver";
session_client_->RequestLockScreen();
}
- shell->user_activity_detector()->OnDisplayPowerChanging();
- shell->output_configurator()->SuspendDisplays();
+ ash::Shell::GetInstance()->user_activity_detector()->OnDisplayPowerChanging();
+ ash::Shell::GetInstance()->output_configurator()->SuspendDisplays();
}
void SuspendObserver::ScreenIsLocked() {
@@ -68,5 +67,4 @@ void SuspendObserver::ScreenIsUnlocked() {
screen_locked_ = false;
}
-} // namespace internal
-} // namespace ash
+} // namespace chromeos
diff --git a/ash/system/chromeos/power/suspend_observer.h b/chrome/browser/chromeos/power/suspend_observer.h
index 17cc931..273b7dc 100644
--- a/ash/system/chromeos/power/suspend_observer.h
+++ b/chrome/browser/chromeos/power/suspend_observer.h
@@ -1,9 +1,9 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright (c) 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_SUSPEND_OBSERVER_H_
-#define ASH_SYSTEM_CHROMEOS_POWER_SUSPEND_OBSERVER_H_
+#ifndef CHROME_BROWSER_CHROMEOS_POWER_SUSPEND_OBSERVER_H_
+#define CHROME_BROWSER_CHROMEOS_POWER_SUSPEND_OBSERVER_H_
#include "base/basictypes.h"
#include "base/callback.h"
@@ -11,27 +11,26 @@
#include "chromeos/dbus/power_manager_client.h"
#include "chromeos/dbus/session_manager_client.h"
-namespace ash {
-namespace internal {
+namespace chromeos {
// A class to observe suspend events.
-class SuspendObserver : public chromeos::PowerManagerClient::Observer,
- public chromeos::SessionManagerClient::Observer {
+class SuspendObserver : public PowerManagerClient::Observer,
+ public SessionManagerClient::Observer {
public:
// This class registers/unregisters itself as an observer in ctor/dtor.
SuspendObserver();
virtual ~SuspendObserver();
- // chromeos::PowerManagerClient::Observer override.
+ // PowerManagerClient::Observer override.
virtual void SuspendImminent() OVERRIDE;
- // chromeos::SessionManagerClient::Observer overrides.
+ // SessionManagerClient::Observer overrides.
virtual void ScreenIsLocked() OVERRIDE;
virtual void ScreenIsUnlocked() OVERRIDE;
private:
- chromeos::PowerManagerClient* power_client_; // not owned
- chromeos::SessionManagerClient* session_client_; // not owned
+ PowerManagerClient* power_client_; // not owned
+ SessionManagerClient* session_client_; // not owned
// Is the screen currently locked?
bool screen_locked_;
@@ -43,7 +42,6 @@ class SuspendObserver : public chromeos::PowerManagerClient::Observer,
DISALLOW_COPY_AND_ASSIGN(SuspendObserver);
};
-} // namespace internal
-} // namespace ash
+} // namespace chromeos
-#endif // ASH_SYSTEM_CHROMEOS_POWER_SUSPEND_OBSERVER_H_
+#endif // CHROME_BROWSER_CHROMEOS_POWER_SUSPEND_OBSERVER_H_
diff --git a/ash/system/chromeos/power/user_activity_notifier.cc b/chrome/browser/chromeos/power/user_activity_notifier.cc
index 921363c..02aea36 100644
--- a/ash/system/chromeos/power/user_activity_notifier.cc
+++ b/chrome/browser/chromeos/power/user_activity_notifier.cc
@@ -1,8 +1,8 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// 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.
-#include "ash/system/chromeos/power/user_activity_notifier.h"
+#include "chrome/browser/chromeos/power/user_activity_notifier.h"
#include "ash/shell.h"
#include "ash/wm/user_activity_detector.h"
@@ -12,9 +12,6 @@
#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.
@@ -22,13 +19,14 @@ const int kNotifyIntervalSec = 5;
} // namespace
-UserActivityNotifier::UserActivityNotifier(UserActivityDetector* detector)
- : detector_(detector) {
- detector_->AddObserver(this);
+namespace chromeos {
+
+UserActivityNotifier::UserActivityNotifier() {
+ ash::Shell::GetInstance()->user_activity_detector()->AddObserver(this);
}
UserActivityNotifier::~UserActivityNotifier() {
- detector_->RemoveObserver(this);
+ ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this);
}
void UserActivityNotifier::OnUserActivity(const ui::Event* event) {
@@ -51,11 +49,9 @@ void UserActivityNotifier::OnUserActivity(const ui::Event* event) {
}
}
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
- NotifyUserActivity(type);
+ DBusThreadManager::Get()->GetPowerManagerClient()->NotifyUserActivity(type);
last_notify_time_ = now;
}
}
-} // namespace internal
-} // namespace ash
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/power/user_activity_notifier.h b/chrome/browser/chromeos/power/user_activity_notifier.h
new file mode 100644
index 0000000..e44a42b
--- /dev/null
+++ b/chrome/browser/chromeos/power/user_activity_notifier.h
@@ -0,0 +1,33 @@
+// 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/ash/system/chromeos/power/video_activity_notifier.cc b/chrome/browser/chromeos/power/video_activity_notifier.cc
index 0f9ec25..3f0698c 100644
--- a/ash/system/chromeos/power/video_activity_notifier.cc
+++ b/chrome/browser/chromeos/power/video_activity_notifier.cc
@@ -1,16 +1,13 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// 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.
-#include "ash/system/chromeos/power/video_activity_notifier.h"
+#include "chrome/browser/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.
@@ -18,24 +15,24 @@ const int kNotifyIntervalSec = 5;
} // namespace
-VideoActivityNotifier::VideoActivityNotifier(VideoDetector* detector)
- : detector_(detector) {
- detector_->AddObserver(this);
+namespace chromeos {
+
+VideoActivityNotifier::VideoActivityNotifier() {
+ ash::Shell::GetInstance()->video_detector()->AddObserver(this);
}
VideoActivityNotifier::~VideoActivityNotifier() {
- detector_->RemoveObserver(this);
+ ash::Shell::GetInstance()->video_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) {
- chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
- NotifyVideoActivity(is_fullscreen);
+ DBusThreadManager::Get()->GetPowerManagerClient()->NotifyVideoActivity(
+ is_fullscreen);
last_notify_time_ = now;
}
}
-} // namespace internal
-} // namespace ash
+} // namespace chromeos
diff --git a/ash/system/chromeos/power/video_activity_notifier.h b/chrome/browser/chromeos/power/video_activity_notifier.h
index 66569c4..ffe2a2c 100644
--- a/ash/system/chromeos/power/video_activity_notifier.h
+++ b/chrome/browser/chromeos/power/video_activity_notifier.h
@@ -1,37 +1,33 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// 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 ASH_SYSTEM_CHROMEOS_POWER_VIDEO_ACTIVITY_NOTIFIER_H_
-#define ASH_SYSTEM_CHROMEOS_POWER_VIDEO_ACTIVITY_NOTIFIER_H_
+#ifndef CHROME_BROWSER_CHROMEOS_POWER_VIDEO_ACTIVITY_NOTIFIER_H_
+#define CHROME_BROWSER_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 ash {
-namespace internal {
+namespace chromeos {
// Notifies the power manager when a video is playing.
-class VideoActivityNotifier : public VideoDetectorObserver {
+class VideoActivityNotifier : public ash::VideoDetectorObserver {
public:
- explicit VideoActivityNotifier(VideoDetector* detector);
+ VideoActivityNotifier();
virtual ~VideoActivityNotifier();
- // VideoDetectorObserver implementation.
+ // ash::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 internal
-} // namespace ash
+} // namespace chromeos
-#endif // ASH_SYSTEM_CHROMEOS_POWER_VIDEO_ACTIVITY_NOTIFIER_H_
+#endif // CHROME_BROWSER_CHROMEOS_POWER_VIDEO_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 154df7f..f95c40f 100644
--- a/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/session_state_delegate_chromeos.cc
@@ -7,14 +7,10 @@
#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"
@@ -48,11 +44,6 @@ 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 c9cd3fd..56fd9c3 100644
--- a/chrome/browser/ui/ash/session_state_delegate_chromeos.h
+++ b/chrome/browser/ui/ash/session_state_delegate_chromeos.h
@@ -28,7 +28,6 @@ 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 bc42053..499b3f9 100644
--- a/chrome/browser/ui/ash/session_state_delegate_views.cc
+++ b/chrome/browser/ui/ash/session_state_delegate_views.cc
@@ -40,10 +40,6 @@ 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 c5117d5..d8e5441 100644
--- a/chrome/browser/ui/ash/session_state_delegate_views.h
+++ b/chrome/browser/ui/ash/session_state_delegate_views.h
@@ -25,7 +25,6 @@ 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 6dae2ab..5037378 100644
--- a/chrome/chrome_browser_chromeos.gypi
+++ b/chrome/chrome_browser_chromeos.gypi
@@ -733,6 +733,12 @@
'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',