OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_DISPLAY_POWER_SERVICE_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_DISPLAY_POWER_SERVICE_PROVIDER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DBUS_DISPLAY_POWER_SERVICE_PROVIDER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DBUS_DISPLAY_POWER_SERVICE_PROVIDER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" | 14 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" |
15 #include "dbus/exported_object.h" | 15 #include "dbus/exported_object.h" |
16 | 16 |
17 namespace dbus { | 17 namespace dbus { |
18 class MethodCall; | 18 class MethodCall; |
19 class Response; | 19 class Response; |
20 } | 20 } |
21 | 21 |
22 namespace chromeos { | 22 namespace chromeos { |
23 | 23 |
24 // This class exports a "SetDisplayPower" D-Bus method that the power | 24 // This class exports "SetDisplayPower" and "SetDisplaySoftwareDimming" |
25 // manager calls to instruct Chrome to turn various displays on or off. | 25 // D-Bus methods that the power manager calls to instruct Chrome to turn |
| 26 // various displays on or off or dim them. |
26 class DisplayPowerServiceProvider | 27 class DisplayPowerServiceProvider |
27 : public CrosDBusService::ServiceProviderInterface { | 28 : public CrosDBusService::ServiceProviderInterface { |
28 public: | 29 public: |
29 DisplayPowerServiceProvider(); | 30 DisplayPowerServiceProvider(); |
30 virtual ~DisplayPowerServiceProvider(); | 31 virtual ~DisplayPowerServiceProvider(); |
31 | 32 |
32 // CrosDBusService::ServiceProviderInterface overrides: | 33 // CrosDBusService::ServiceProviderInterface overrides: |
33 virtual void Start( | 34 virtual void Start( |
34 scoped_refptr<dbus::ExportedObject> exported_object) OVERRIDE; | 35 scoped_refptr<dbus::ExportedObject> exported_object) OVERRIDE; |
35 | 36 |
36 private: | 37 private: |
37 // Called from ExportedObject when SetDisplayPower() is exported as a D-Bus | 38 // Called from ExportedObject when a handler is exported as a D-Bus |
38 // method or failed to be exported. | 39 // method or failed to be exported. |
39 void OnExported(const std::string& interface_name, | 40 void OnExported(const std::string& interface_name, |
40 const std::string& method_name, | 41 const std::string& method_name, |
41 bool success); | 42 bool success); |
42 | 43 |
43 // Called on UI thread in response to a D-Bus request. | 44 // Called on UI thread in response to D-Bus requests. |
44 void SetDisplayPower(dbus::MethodCall* method_call, | 45 void SetDisplayPower(dbus::MethodCall* method_call, |
45 dbus::ExportedObject::ResponseSender response_sender); | 46 dbus::ExportedObject::ResponseSender response_sender); |
| 47 void SetDisplaySoftwareDimming( |
| 48 dbus::MethodCall* method_call, |
| 49 dbus::ExportedObject::ResponseSender response_sender); |
46 | 50 |
47 // Keep this last so that all weak pointers will be invalidated at the | 51 // Keep this last so that all weak pointers will be invalidated at the |
48 // beginning of destruction. | 52 // beginning of destruction. |
49 base::WeakPtrFactory<DisplayPowerServiceProvider> weak_ptr_factory_; | 53 base::WeakPtrFactory<DisplayPowerServiceProvider> weak_ptr_factory_; |
50 | 54 |
51 DISALLOW_COPY_AND_ASSIGN(DisplayPowerServiceProvider); | 55 DISALLOW_COPY_AND_ASSIGN(DisplayPowerServiceProvider); |
52 }; | 56 }; |
53 | 57 |
54 } // namespace chromeos | 58 } // namespace chromeos |
55 | 59 |
56 #endif // CHROME_BROWSER_CHROMEOS_DBUS_DISPLAY_POWER_SERVICE_PROVIDER_H_ | 60 #endif // CHROME_BROWSER_CHROMEOS_DBUS_DISPLAY_POWER_SERVICE_PROVIDER_H_ |
OLD | NEW |