Index: chrome/browser/chromeos/cros/brightness_library.cc |
diff --git a/chrome/browser/chromeos/cros/brightness_library.cc b/chrome/browser/chromeos/cros/brightness_library.cc |
index ba8066352cf9a0dd73595910effd63eeb66ef371..3e3e98edd6f5026803f61aff4454c97efa072a2a 100644 |
--- a/chrome/browser/chromeos/cros/brightness_library.cc |
+++ b/chrome/browser/chromeos/cros/brightness_library.cc |
@@ -16,10 +16,7 @@ namespace chromeos { |
class BrightnessLibraryImpl : public BrightnessLibrary { |
public: |
- BrightnessLibraryImpl() : brightness_connection_(NULL) { |
- if (CrosLibrary::Get()->EnsureLoaded()) |
- Init(); |
- } |
+ BrightnessLibraryImpl() : brightness_connection_(NULL) {} |
~BrightnessLibraryImpl() { |
if (brightness_connection_) { |
@@ -28,14 +25,12 @@ class BrightnessLibraryImpl : public BrightnessLibrary { |
} |
} |
- void DecreaseScreenBrightness(bool allow_off) { |
- if (chromeos::DecreaseScreenBrightness) |
- chromeos::DecreaseScreenBrightness(allow_off); |
- } |
- |
- void IncreaseScreenBrightness() { |
- if (chromeos::IncreaseScreenBrightness) |
- chromeos::IncreaseScreenBrightness(); |
+ void Init() { |
+ if (CrosLibrary::Get()->EnsureLoaded()) { |
+ CHECK(!brightness_connection_) << "Already intialized"; |
+ brightness_connection_ = |
+ chromeos::MonitorBrightnessV2(&BrightnessChangedHandler, this); |
+ } |
} |
void AddObserver(Observer* observer) { |
@@ -46,6 +41,16 @@ class BrightnessLibraryImpl : public BrightnessLibrary { |
observers_.RemoveObserver(observer); |
} |
+ void DecreaseScreenBrightness(bool allow_off) { |
+ if (chromeos::DecreaseScreenBrightness) |
+ chromeos::DecreaseScreenBrightness(allow_off); |
+ } |
+ |
+ void IncreaseScreenBrightness() { |
+ if (chromeos::IncreaseScreenBrightness) |
+ chromeos::IncreaseScreenBrightness(); |
+ } |
+ |
private: |
static void BrightnessChangedHandler(void* object, |
int brightness_level, |
@@ -54,12 +59,6 @@ class BrightnessLibraryImpl : public BrightnessLibrary { |
self->OnBrightnessChanged(brightness_level, user_initiated); |
} |
- void Init() { |
- DCHECK(!brightness_connection_) << "Already intialized"; |
- brightness_connection_ = |
- chromeos::MonitorBrightnessV2(&BrightnessChangedHandler, this); |
- } |
- |
void OnBrightnessChanged(int brightness_level, bool user_initiated) { |
// Make sure we run on the UI thread. |
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
@@ -88,18 +87,22 @@ class BrightnessLibraryStubImpl : public BrightnessLibrary { |
public: |
BrightnessLibraryStubImpl() {} |
~BrightnessLibraryStubImpl() {} |
- void DecreaseScreenBrightness(bool allow_off) {} |
- void IncreaseScreenBrightness() {} |
+ void Init() {} |
void AddObserver(Observer* observer) {} |
void RemoveObserver(Observer* observer) {} |
+ void DecreaseScreenBrightness(bool allow_off) {} |
+ void IncreaseScreenBrightness() {} |
}; |
// static |
BrightnessLibrary* BrightnessLibrary::GetImpl(bool stub) { |
+ BrightnessLibrary* impl; |
if (stub) |
- return new BrightnessLibraryStubImpl(); |
+ impl = new BrightnessLibraryStubImpl(); |
else |
- return new BrightnessLibraryImpl(); |
+ impl = new BrightnessLibraryImpl(); |
+ impl->Init(); |
+ return impl; |
} |
} // namespace chromeos |