OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/cros/brightness_library.h" | 5 #include "chrome/browser/chromeos/cros/brightness_library.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 | 21 |
22 virtual ~BrightnessLibraryImpl() { | 22 virtual ~BrightnessLibraryImpl() { |
23 if (brightness_connection_) { | 23 if (brightness_connection_) { |
24 chromeos::DisconnectBrightness(brightness_connection_); | 24 chromeos::DisconnectBrightness(brightness_connection_); |
25 brightness_connection_ = NULL; | 25 brightness_connection_ = NULL; |
26 } | 26 } |
27 } | 27 } |
28 | 28 |
29 // Begin BrightnessLibrary implementation. | 29 // Begin BrightnessLibrary implementation. |
30 virtual void Init() OVERRIDE { | 30 virtual void Init() OVERRIDE { |
31 if (CrosLibrary::Get()->EnsureLoaded()) { | 31 DCHECK(CrosLibrary::Get()->libcros_loaded()); |
32 CHECK(!brightness_connection_) << "Already intialized"; | 32 CHECK(!brightness_connection_) << "Already intialized"; |
33 brightness_connection_ = | 33 brightness_connection_ = |
34 chromeos::MonitorBrightnessV2(&BrightnessChangedHandler, this); | 34 chromeos::MonitorBrightnessV2(&BrightnessChangedHandler, this); |
35 } | |
36 } | 35 } |
37 | 36 |
38 virtual void AddObserver(Observer* observer) OVERRIDE { | 37 virtual void AddObserver(Observer* observer) OVERRIDE { |
39 observers_.AddObserver(observer); | 38 observers_.AddObserver(observer); |
40 } | 39 } |
41 | 40 |
42 virtual void RemoveObserver(Observer* observer) OVERRIDE { | 41 virtual void RemoveObserver(Observer* observer) OVERRIDE { |
43 observers_.RemoveObserver(observer); | 42 observers_.RemoveObserver(observer); |
44 } | 43 } |
45 | 44 |
46 virtual void DecreaseScreenBrightness(bool allow_off) OVERRIDE { | 45 virtual void DecreaseScreenBrightness(bool allow_off) OVERRIDE { |
47 if (chromeos::DecreaseScreenBrightness) | 46 chromeos::DecreaseScreenBrightness(allow_off); |
48 chromeos::DecreaseScreenBrightness(allow_off); | |
49 } | 47 } |
50 | 48 |
51 virtual void IncreaseScreenBrightness() OVERRIDE { | 49 virtual void IncreaseScreenBrightness() OVERRIDE { |
52 if (chromeos::IncreaseScreenBrightness) | |
53 chromeos::IncreaseScreenBrightness(); | 50 chromeos::IncreaseScreenBrightness(); |
satorux1
2011/09/16 20:05:55
Indentation is off?
stevenjb
2011/09/16 21:44:24
Done.
| |
54 } | 51 } |
55 // End BrightnessLibrary implementation. | 52 // End BrightnessLibrary implementation. |
56 | 53 |
57 private: | 54 private: |
58 static void BrightnessChangedHandler(void* object, | 55 static void BrightnessChangedHandler(void* object, |
59 int brightness_level, | 56 int brightness_level, |
60 bool user_initiated) { | 57 bool user_initiated) { |
61 BrightnessLibraryImpl* self = static_cast<BrightnessLibraryImpl*>(object); | 58 BrightnessLibraryImpl* self = static_cast<BrightnessLibraryImpl*>(object); |
62 self->OnBrightnessChanged(brightness_level, user_initiated); | 59 self->OnBrightnessChanged(brightness_level, user_initiated); |
63 } | 60 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 else | 101 else |
105 impl = new BrightnessLibraryImpl(); | 102 impl = new BrightnessLibraryImpl(); |
106 impl->Init(); | 103 impl->Init(); |
107 return impl; | 104 return impl; |
108 } | 105 } |
109 | 106 |
110 } // namespace chromeos | 107 } // namespace chromeos |
111 | 108 |
112 // Needed for NewRunnableMethod() call above. | 109 // Needed for NewRunnableMethod() call above. |
113 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::BrightnessLibraryImpl); | 110 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::BrightnessLibraryImpl); |
OLD | NEW |