summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-01 05:20:51 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-01 05:20:51 +0000
commita8c118bfeeea1eb70a6215e0e90789d03d817e58 (patch)
treee03819336b75ec3bf4db84854009a06bacafe041 /chrome
parent3fda6cda9e170c4f75c8c15cc1082b4f6e42cfdb (diff)
downloadchromium_src-a8c118bfeeea1eb70a6215e0e90789d03d817e58.zip
chromium_src-a8c118bfeeea1eb70a6215e0e90789d03d817e58.tar.gz
chromium_src-a8c118bfeeea1eb70a6215e0e90789d03d817e58.tar.bz2
Rework BrightnessLibrary using DBusThreadManager.
This means we no longer use libcros to handle the screen brightness. The brightness changed signal is handled in power_manager_client.cc, rather than in libcros. TEST=confirm that brightness change keys work as before. BUG=chromium-os:18904 Review URL: http://codereview.chromium.org/8044034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103625 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chrome_browser_main.cc3
-rw-r--r--chrome/browser/chromeos/brightness_observer.h8
-rw-r--r--chrome/browser/chromeos/cros/brightness_library.cc110
-rw-r--r--chrome/browser/chromeos/cros/brightness_library.h35
-rw-r--r--chrome/browser/chromeos/cros/cros_library.cc3
-rw-r--r--chrome/browser/chromeos/cros/cros_library.h4
-rw-r--r--chrome/browser/chromeos/dbus/dbus_thread_manager.cc4
-rw-r--r--chrome/browser/chromeos/dbus/dbus_thread_manager.h10
-rw-r--r--chrome/browser/chromeos/dbus/power_manager_client.cc163
-rw-r--r--chrome/browser/chromeos/dbus/power_manager_client.h61
-rw-r--r--chrome/browser/chromeos/system_key_event_listener.cc18
-rw-r--r--chrome/chrome_browser.gypi4
12 files changed, 250 insertions, 173 deletions
diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc
index 45bc339..7c3f5d4 100644
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -134,6 +134,7 @@
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/screen_lock_library.h"
#include "chrome/browser/chromeos/customization_document.h"
+#include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
#include "chrome/browser/chromeos/external_metrics.h"
#include "chrome/browser/chromeos/login/authenticator.h"
#include "chrome/browser/chromeos/login/login_utils.h"
@@ -1794,7 +1795,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunInternal() {
// indication of brightness changes during login.
static chromeos::BrightnessObserver* brightness_observer =
new chromeos::BrightnessObserver();
- chromeos::CrosLibrary::Get()->GetBrightnessLibrary()->AddObserver(
+ chromeos::DBusThreadManager::Get()->power_manager_client()->AddObserver(
brightness_observer);
// Listen for system key events so that the user will be able to adjust the
diff --git a/chrome/browser/chromeos/brightness_observer.h b/chrome/browser/chromeos/brightness_observer.h
index 2d3b8b5..d8f5b66 100644
--- a/chrome/browser/chromeos/brightness_observer.h
+++ b/chrome/browser/chromeos/brightness_observer.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.
@@ -7,19 +7,19 @@
#pragma once
#include "base/basictypes.h"
-#include "chrome/browser/chromeos/cros/brightness_library.h"
+#include "chrome/browser/chromeos/dbus/power_manager_client.h"
namespace chromeos {
// This observer displays a bubble at the bottom of the screen showing the
// current brightness level whenever the user changes it.
-class BrightnessObserver : public BrightnessLibrary::Observer {
+class BrightnessObserver : public PowerManagerClient::Observer {
public:
BrightnessObserver() {}
virtual ~BrightnessObserver() {}
private:
- // BrightnessLibrary::Observer implementation.
+ // PowerManagerClient::Observer implementation.
virtual void BrightnessChanged(int level, bool user_initiated);
DISALLOW_COPY_AND_ASSIGN(BrightnessObserver);
diff --git a/chrome/browser/chromeos/cros/brightness_library.cc b/chrome/browser/chromeos/cros/brightness_library.cc
deleted file mode 100644
index fdf0c50..0000000
--- a/chrome/browser/chromeos/cros/brightness_library.cc
+++ /dev/null
@@ -1,110 +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/chromeos/cros/brightness_library.h"
-
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "base/logging.h"
-#include "base/message_loop.h"
-#include "base/observer_list.h"
-#include "chrome/browser/chromeos/cros/cros_library.h"
-#include "content/browser/browser_thread.h"
-#include "third_party/cros/chromeos_brightness.h"
-
-namespace chromeos {
-
-class BrightnessLibraryImpl : public BrightnessLibrary {
- public:
- BrightnessLibraryImpl() : brightness_connection_(NULL) {}
-
- virtual ~BrightnessLibraryImpl() {
- if (brightness_connection_) {
- chromeos::DisconnectBrightness(brightness_connection_);
- brightness_connection_ = NULL;
- }
- }
-
- // Begin BrightnessLibrary implementation.
- virtual void Init() OVERRIDE {
- DCHECK(CrosLibrary::Get()->libcros_loaded());
- CHECK(!brightness_connection_) << "Already intialized";
- brightness_connection_ =
- chromeos::MonitorBrightnessV2(&BrightnessChangedHandler, this);
- }
-
- virtual void AddObserver(Observer* observer) OVERRIDE {
- observers_.AddObserver(observer);
- }
-
- virtual void RemoveObserver(Observer* observer) OVERRIDE {
- observers_.RemoveObserver(observer);
- }
-
- virtual void DecreaseScreenBrightness(bool allow_off) OVERRIDE {
- chromeos::DecreaseScreenBrightness(allow_off);
- }
-
- virtual void IncreaseScreenBrightness() OVERRIDE {
- chromeos::IncreaseScreenBrightness();
- }
- // End BrightnessLibrary implementation.
-
- private:
- static void BrightnessChangedHandler(void* object,
- int brightness_level,
- bool user_initiated) {
- BrightnessLibraryImpl* self = static_cast<BrightnessLibraryImpl*>(object);
- self->OnBrightnessChanged(brightness_level, user_initiated);
- }
-
- void OnBrightnessChanged(int brightness_level, bool user_initiated) {
- // Make sure we run on the UI thread.
- if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- NewRunnableMethod(this,
- &BrightnessLibraryImpl::OnBrightnessChanged,
- brightness_level,
- user_initiated));
- return;
- }
-
- FOR_EACH_OBSERVER(Observer, observers_,
- BrightnessChanged(brightness_level, user_initiated));
- }
-
- chromeos::BrightnessConnection brightness_connection_;
-
- ObserverList<Observer> observers_;
-
- DISALLOW_COPY_AND_ASSIGN(BrightnessLibraryImpl);
-};
-
-class BrightnessLibraryStubImpl : public BrightnessLibrary {
- public:
- BrightnessLibraryStubImpl() {}
- virtual ~BrightnessLibraryStubImpl() {}
- virtual void Init() OVERRIDE {}
- virtual void AddObserver(Observer* observer) OVERRIDE {}
- virtual void RemoveObserver(Observer* observer) OVERRIDE {}
- virtual void DecreaseScreenBrightness(bool allow_off) OVERRIDE {}
- virtual void IncreaseScreenBrightness() OVERRIDE {}
-};
-
-// static
-BrightnessLibrary* BrightnessLibrary::GetImpl(bool stub) {
- BrightnessLibrary* impl;
- if (stub)
- impl = new BrightnessLibraryStubImpl();
- else
- impl = new BrightnessLibraryImpl();
- impl->Init();
- return impl;
-}
-
-} // namespace chromeos
-
-// Needed for NewRunnableMethod() call above.
-DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::BrightnessLibraryImpl);
diff --git a/chrome/browser/chromeos/cros/brightness_library.h b/chrome/browser/chromeos/cros/brightness_library.h
deleted file mode 100644
index bcd7f8b..0000000
--- a/chrome/browser/chromeos/cros/brightness_library.h
+++ /dev/null
@@ -1,35 +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.
-
-#ifndef CHROME_BROWSER_CHROMEOS_CROS_BRIGHTNESS_LIBRARY_H_
-#define CHROME_BROWSER_CHROMEOS_CROS_BRIGHTNESS_LIBRARY_H_
-#pragma once
-
-namespace chromeos {
-
-class BrightnessLibrary {
- public:
- class Observer {
- public:
- virtual void BrightnessChanged(int level, bool user_initiated) = 0;
- };
-
- virtual ~BrightnessLibrary() {}
-
- virtual void Init() = 0;
-
- virtual void AddObserver(Observer* observer) = 0;
- virtual void RemoveObserver(Observer* observer) = 0;
-
- virtual void DecreaseScreenBrightness(bool allow_off) = 0;
- virtual void IncreaseScreenBrightness() = 0;
-
- // Factory function, creates a new instance and returns ownership.
- // For normal usage, access the singleton via CrosLibrary::Get().
- static BrightnessLibrary* GetImpl(bool stub);
-};
-
-} // namespace chromeos
-
-#endif // CHROME_BROWSER_CHROMEOS_CROS_BRIGHTNESS_LIBRARY_H_
diff --git a/chrome/browser/chromeos/cros/cros_library.cc b/chrome/browser/chromeos/cros/cros_library.cc
index 9e4596f..63e61f1 100644
--- a/chrome/browser/chromeos/cros/cros_library.cc
+++ b/chrome/browser/chromeos/cros/cros_library.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/chromeos/cros/cros_library.h"
-#include "chrome/browser/chromeos/cros/brightness_library.h"
#include "chrome/browser/chromeos/cros/burn_library.h"
#include "chrome/browser/chromeos/cros/cert_library.h"
#include "chrome/browser/chromeos/cros/cryptohome_library.h"
@@ -82,7 +81,6 @@ CrosLibrary* CrosLibrary::Get() {
return g_cros_library;
}
-DEFINE_GET_LIBRARY_METHOD(Brightness, brightness);
DEFINE_GET_LIBRARY_METHOD(Burn, burn);
DEFINE_GET_LIBRARY_METHOD(Cert, cert);
DEFINE_GET_LIBRARY_METHOD(Cryptohome, crypto);
@@ -131,7 +129,6 @@ void CrosLibrary::TestApi::SetLibraryLoader(LibraryLoader* loader, bool own) {
library_->load_error_ = false;
}
-DEFINE_SET_LIBRARY_METHOD(Brightness, brightness);
DEFINE_SET_LIBRARY_METHOD(Cert, cert);
DEFINE_SET_LIBRARY_METHOD(Burn, burn);
DEFINE_SET_LIBRARY_METHOD(Cryptohome, crypto);
diff --git a/chrome/browser/chromeos/cros/cros_library.h b/chrome/browser/chromeos/cros/cros_library.h
index bc16426..2afa461 100644
--- a/chrome/browser/chromeos/cros/cros_library.h
+++ b/chrome/browser/chromeos/cros/cros_library.h
@@ -16,7 +16,6 @@ template <typename T> struct DefaultLazyInstanceTraits;
namespace chromeos {
-class BrightnessLibrary;
class BurnLibrary;
class CertLibrary;
class CryptohomeLibrary;
@@ -47,7 +46,6 @@ class CrosLibrary {
// when the CrosLibrary is deleted (or other mocks are set).
// Setter for LibraryLoader.
void SetLibraryLoader(LibraryLoader* loader, bool own);
- void SetBrightnessLibrary(BrightnessLibrary* library, bool own);
void SetCertLibrary(CertLibrary* library, bool own);
void SetBurnLibrary(BurnLibrary* library, bool own);
void SetCryptohomeLibrary(CryptohomeLibrary* library, bool own);
@@ -76,7 +74,6 @@ class CrosLibrary {
// called (or Shutdown() has been called).
static CrosLibrary* Get();
- BrightnessLibrary* GetBrightnessLibrary();
BurnLibrary* GetBurnLibrary();
CertLibrary* GetCertLibrary();
CryptohomeLibrary* GetCryptohomeLibrary();
@@ -150,7 +147,6 @@ class CrosLibrary {
bool own_;
};
- Library<BrightnessLibrary> brightness_lib_;
Library<BurnLibrary> burn_lib_;
Library<CertLibrary> cert_lib_;
Library<CryptohomeLibrary> crypto_lib_;
diff --git a/chrome/browser/chromeos/dbus/dbus_thread_manager.cc b/chrome/browser/chromeos/dbus/dbus_thread_manager.cc
index 009e846..05fa6e7 100644
--- a/chrome/browser/chromeos/dbus/dbus_thread_manager.cc
+++ b/chrome/browser/chromeos/dbus/dbus_thread_manager.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "base/threading/thread.h"
#include "chrome/browser/chromeos/dbus/cros_dbus_service.h"
+#include "chrome/browser/chromeos/dbus/power_manager_client.h"
#include "chrome/browser/chromeos/dbus/sensors_source.h"
#include "chrome/common/chrome_switches.h"
#include "dbus/bus.h"
@@ -40,6 +41,9 @@ DBusThreadManager::DBusThreadManager() {
sensors_source_ = new SensorsSource;
sensors_source_->Init(system_bus_.get());
}
+
+ // Create the power manager client.
+ power_manager_client_ = PowerManagerClient::Create(system_bus_.get());
}
DBusThreadManager::~DBusThreadManager() {
diff --git a/chrome/browser/chromeos/dbus/dbus_thread_manager.h b/chrome/browser/chromeos/dbus/dbus_thread_manager.h
index 65a7851..afadc2a 100644
--- a/chrome/browser/chromeos/dbus/dbus_thread_manager.h
+++ b/chrome/browser/chromeos/dbus/dbus_thread_manager.h
@@ -20,6 +20,7 @@ class Bus;
namespace chromeos {
class CrosDBusService;
+class PowerManagerClient;
class SensorsSource;
// DBusThreadManager manages the D-Bus thread, the thread dedicated to
@@ -53,8 +54,12 @@ class DBusThreadManager {
// Gets the global instance. Initialize() must be called first.
static DBusThreadManager* Get();
- // Returns the connection to the system bus.
- dbus::Bus* system_bus() { return system_bus_.get(); }
+ // Returns the power manager client, owned by DBusThreadManager.
+ // Do not cache this pointer and use it after DBusThreadManager is shut
+ // down.
+ PowerManagerClient* power_manager_client() {
+ return power_manager_client_.get();
+ }
private:
DBusThreadManager();
@@ -64,6 +69,7 @@ class DBusThreadManager {
scoped_refptr<dbus::Bus> system_bus_;
CrosDBusService* cros_dbus_service_;
scoped_refptr<SensorsSource> sensors_source_;
+ scoped_refptr<PowerManagerClient> power_manager_client_;
DISALLOW_COPY_AND_ASSIGN(DBusThreadManager);
};
diff --git a/chrome/browser/chromeos/dbus/power_manager_client.cc b/chrome/browser/chromeos/dbus/power_manager_client.cc
new file mode 100644
index 0000000..6224a90
--- /dev/null
+++ b/chrome/browser/chromeos/dbus/power_manager_client.cc
@@ -0,0 +1,163 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/dbus/power_manager_client.h"
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "chrome/browser/chromeos/system/runtime_environment.h"
+#include "dbus/bus.h"
+#include "dbus/message.h"
+#include "dbus/object_proxy.h"
+#include "third_party/cros_system_api/dbus/service_constants.h"
+
+namespace chromeos {
+
+// The PowerManagerClient implementation used in production.
+class PowerManagerClientImpl : public PowerManagerClient {
+ public:
+ explicit PowerManagerClientImpl(dbus::Bus* bus)
+ : power_manager_proxy_(NULL) {
+ power_manager_proxy_ = bus->GetObjectProxy(
+ power_manager::kPowerManagerServiceName,
+ power_manager::kPowerManagerServicePath);
+
+ // Monitor the D-Bus signal for brightness changes. Only the power
+ // manager knows the actual brightness level. We don't cache the
+ // brightness level in Chrome as it'll make things less reliable.
+ power_manager_proxy_->ConnectToSignal(
+ power_manager::kPowerManagerInterface,
+ power_manager::kBrightnessChangedSignal,
+ base::Bind(&PowerManagerClientImpl::BrightnessChangedReceived, this),
+ base::Bind(&PowerManagerClientImpl::BrightnessChangedConnected, this));
+ }
+
+ // PowerManagerClient override.
+ virtual void AddObserver(Observer* observer) {
+ observers_.AddObserver(observer);
+ }
+
+ // PowerManagerClient override.
+ virtual void RemoveObserver(Observer* observer) {
+ observers_.RemoveObserver(observer);
+ }
+
+ // PowerManagerClient override.
+ virtual void DecreaseScreenBrightness(bool allow_off) {
+ dbus::MethodCall method_call(
+ power_manager::kPowerManagerInterface,
+ power_manager::kDecreaseScreenBrightness);
+ dbus::MessageWriter writer(&method_call);
+ writer.AppendBool(allow_off);
+
+ power_manager_proxy_->CallMethod(
+ &method_call,
+ dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&PowerManagerClientImpl::OnDecreaseScreenBrightness,
+ this));
+ }
+
+ // PowerManagerClient override.
+ virtual void IncreaseScreenBrightness() {
+ dbus::MethodCall method_call(
+ power_manager::kPowerManagerInterface,
+ power_manager::kIncreaseScreenBrightness);
+ power_manager_proxy_->CallMethod(
+ &method_call,
+ dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&PowerManagerClientImpl::OnIncreaseScreenBrightness,
+ this));
+ }
+
+ private:
+ friend class base::RefCountedThreadSafe<PowerManagerClientImpl>;
+ virtual ~PowerManagerClientImpl() {
+ }
+
+ // Called when a brightness change signal is received.
+ void BrightnessChangedReceived(dbus::Signal* signal) {
+ dbus::MessageReader reader(signal);
+ int32 brightness_level = 0;
+ bool user_initiated = 0;
+ if (!(reader.PopInt32(&brightness_level) &&
+ reader.PopBool(&user_initiated))) {
+ LOG(ERROR) << "Brightness changed signal had incorrect parameters: "
+ << signal->ToString();
+ return;
+ }
+ VLOG(1) << "Brightness changed to " << brightness_level
+ << ": user initiated " << user_initiated;
+ FOR_EACH_OBSERVER(Observer, observers_,
+ BrightnessChanged(brightness_level, user_initiated));
+ }
+
+ // Called when the brightness change signal is initially connected.
+ void BrightnessChangedConnected(const std::string& interface_name,
+ const std::string& signal_name,
+ bool success) {
+ LOG_IF(WARNING, !success)
+ << "Failed to connect to brightness changed signal.";
+ }
+
+ // Called when a response for DecreaseScreenBrightness() is received.
+ void OnDecreaseScreenBrightness(dbus::Response* response) {
+ if (!response) {
+ LOG(ERROR) << "Failed to decrease screen brightness";
+ return;
+ }
+ VLOG(1) << "screen brightness increased: " << response->ToString();
+ }
+
+ // Called when a response for IncreaseScreenBrightness() is received.
+ void OnIncreaseScreenBrightness(dbus::Response* response) {
+ if (!response) {
+ LOG(ERROR) << "Failed to increase screen brightness";
+ return;
+ }
+ VLOG(1) << "screen brightness increased: " << response->ToString();
+ }
+
+ dbus::ObjectProxy* power_manager_proxy_;
+ ObserverList<Observer> observers_;
+
+ DISALLOW_COPY_AND_ASSIGN(PowerManagerClientImpl);
+};
+
+// The PowerManagerClient implementation used on Linux desktop,
+// which does nothing.
+class PowerManagerClientStubImpl : public PowerManagerClient {
+ // PowerManagerClient override.
+ virtual void AddObserver(Observer* observer) {
+ }
+
+ // PowerManagerClient override.
+ virtual void RemoveObserver(Observer* observer) {
+ }
+
+ // PowerManagerClient override.
+ virtual void DecreaseScreenBrightness(bool allow_off) {
+ VLOG(1) << "Requested to descrease screen brightness";
+ }
+
+ // PowerManagerClient override.
+ virtual void IncreaseScreenBrightness() {
+ VLOG(1) << "Requested to increase screen brightness";
+ }
+};
+
+PowerManagerClient::PowerManagerClient() {
+}
+
+PowerManagerClient::~PowerManagerClient() {
+}
+
+PowerManagerClient* PowerManagerClient::Create(dbus::Bus* bus) {
+ if (system::runtime_environment::IsRunningOnChromeOS()) {
+ return new PowerManagerClientImpl(bus);
+ } else {
+ return new PowerManagerClientStubImpl();
+ }
+}
+
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/dbus/power_manager_client.h b/chrome/browser/chromeos/dbus/power_manager_client.h
new file mode 100644
index 0000000..740f86e
--- /dev/null
+++ b/chrome/browser/chromeos/dbus/power_manager_client.h
@@ -0,0 +1,61 @@
+// 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.
+
+#ifndef CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_
+#define CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/observer_list.h"
+
+#include <string>
+
+namespace dbus {
+class Bus;
+class ObjectProxy;
+class Response;
+class Signal;
+} // namespace
+
+namespace chromeos {
+
+// PowerManagerClient is used to communicate with the power manager.
+class PowerManagerClient
+ : public base::RefCountedThreadSafe<PowerManagerClient> {
+ public:
+ // Interface for observing changes from the power manager.
+ class Observer {
+ public:
+ // Called when the brightness is changed.
+ // |level| is of the range [0, 100].
+ // |user_initiated| is true if the action is initiated by the user.
+ virtual void BrightnessChanged(int level, bool user_initiated) = 0;
+ };
+
+ // Adds and removes the observer.
+ virtual void AddObserver(Observer* observer) = 0;
+ virtual void RemoveObserver(Observer* observer) = 0;
+
+ // Decreases the screen brightness. |allow_off| controls whether or not
+ // it's allowed to turn off the back light.
+ virtual void DecreaseScreenBrightness(bool allow_off) = 0;
+
+ // Increases the screen brightness.
+ virtual void IncreaseScreenBrightness() = 0;
+
+ // Creates the instance.
+ static PowerManagerClient* Create(dbus::Bus* bus);
+
+ protected:
+ // These are protected, so we can define sub classes.
+ PowerManagerClient();
+ virtual ~PowerManagerClient();
+
+ private:
+ friend class base::RefCountedThreadSafe<PowerManagerClient>;
+ DISALLOW_COPY_AND_ASSIGN(PowerManagerClient);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_
diff --git a/chrome/browser/chromeos/system_key_event_listener.cc b/chrome/browser/chromeos/system_key_event_listener.cc
index fd8a428..4a168a9 100644
--- a/chrome/browser/chromeos/system_key_event_listener.cc
+++ b/chrome/browser/chromeos/system_key_event_listener.cc
@@ -11,8 +11,8 @@
#include "chrome/browser/accessibility_events.h"
#include "chrome/browser/chromeos/audio_handler.h"
#include "chrome/browser/chromeos/brightness_bubble.h"
-#include "chrome/browser/chromeos/cros/brightness_library.h"
-#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/dbus/dbus_thread_manager.h"
+#include "chrome/browser/chromeos/dbus/power_manager_client.h"
#include "chrome/browser/chromeos/input_method/hotkey_manager.h"
#include "chrome/browser/chromeos/input_method/input_method_manager.h"
#include "chrome/browser/chromeos/input_method/xkeyboard.h"
@@ -208,19 +208,13 @@ void SystemKeyEventListener::GrabKey(int32 key, uint32 mask) {
}
void SystemKeyEventListener::OnBrightnessDown() {
- if (!chromeos::CrosLibrary::Get()->EnsureLoaded())
- return;
- chromeos::BrightnessLibrary* cros =
- CrosLibrary::Get()->GetBrightnessLibrary();
- cros->DecreaseScreenBrightness(true);
+ DBusThreadManager::Get()->power_manager_client()->
+ DecreaseScreenBrightness(true);
}
void SystemKeyEventListener::OnBrightnessUp() {
- if (!chromeos::CrosLibrary::Get()->EnsureLoaded())
- return;
- chromeos::BrightnessLibrary* cros =
- CrosLibrary::Get()->GetBrightnessLibrary();
- cros->IncreaseScreenBrightness();
+ DBusThreadManager::Get()->power_manager_client()->
+ IncreaseScreenBrightness();
}
void SystemKeyEventListener::OnVolumeMute() {
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 96943ea..824e1859 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -369,8 +369,6 @@
'browser/chromeos/choose_mobile_network_dialog.h',
'browser/chromeos/chrome_browser_main_chromeos.cc',
'browser/chromeos/chrome_browser_main_chromeos.h',
- 'browser/chromeos/cros/brightness_library.cc',
- 'browser/chromeos/cros/brightness_library.h',
'browser/chromeos/cros/burn_library.cc',
'browser/chromeos/cros/burn_library.h',
'browser/chromeos/cros/cert_library.cc',
@@ -413,6 +411,8 @@
'browser/chromeos/dbus/cros_dbus_service.h',
'browser/chromeos/dbus/dbus_thread_manager.cc',
'browser/chromeos/dbus/dbus_thread_manager.h',
+ 'browser/chromeos/dbus/power_manager_client.cc',
+ 'browser/chromeos/dbus/power_manager_client.h',
'browser/chromeos/dbus/proxy_resolution_service_provider.cc',
'browser/chromeos/dbus/proxy_resolution_service_provider.h',
'browser/chromeos/dbus/sensors_source.cc',