OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/dbus/sensors_client.h" | 5 #include "chrome/browser/chromeos/dbus/sensors_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "chrome/browser/chromeos/system/runtime_environment.h" | 9 #include "chrome/browser/chromeos/system/runtime_environment.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
11 #include "content/public/browser/sensors_provider.h" | 11 #include "content/public/browser/sensors_provider.h" |
12 #include "dbus/bus.h" | 12 #include "dbus/bus.h" |
13 #include "dbus/message.h" | 13 #include "dbus/message.h" |
| 14 #include "dbus/object_path.h" |
14 #include "dbus/object_proxy.h" | 15 #include "dbus/object_proxy.h" |
15 | 16 |
16 using content::BrowserThread; | 17 using content::BrowserThread; |
17 | 18 |
18 // TODO(cwolfe): Fix the DEPs so that these can be pulled in from | 19 // TODO(cwolfe): Fix the DEPs so that these can be pulled in from |
19 // "chromeos/dbus/service_constants.h". | 20 // "chromeos/dbus/service_constants.h". |
20 namespace chromeos { | 21 namespace chromeos { |
21 // Sensors service identifiers. | 22 // Sensors service identifiers. |
22 const char kSensorsServiceName[] = "org.chromium.Sensors"; | 23 const char kSensorsServiceName[] = "org.chromium.Sensors"; |
23 const char kSensorsServicePath[] = "/org/chromium/Sensors"; | 24 const char kSensorsServicePath[] = "/org/chromium/Sensors"; |
24 const char kSensorsServiceInterface[] = "org.chromium.Sensors"; | 25 const char kSensorsServiceInterface[] = "org.chromium.Sensors"; |
25 // Sensors signal names. | 26 // Sensors signal names. |
26 const char kScreenOrientationChanged[] = "ScreenOrientationChanged"; | 27 const char kScreenOrientationChanged[] = "ScreenOrientationChanged"; |
27 | 28 |
28 // The SensorsClient implementation used in production. | 29 // The SensorsClient implementation used in production. |
29 class SensorsClientImpl : public SensorsClient { | 30 class SensorsClientImpl : public SensorsClient { |
30 public: | 31 public: |
31 explicit SensorsClientImpl(dbus::Bus* bus) | 32 explicit SensorsClientImpl(dbus::Bus* bus) |
32 : sensors_proxy_(NULL), | 33 : sensors_proxy_(NULL), |
33 weak_ptr_factory_(this) { | 34 weak_ptr_factory_(this) { |
34 sensors_proxy_ = bus->GetObjectProxy(chromeos::kSensorsServiceName, | 35 sensors_proxy_ = bus->GetObjectProxy( |
35 chromeos::kSensorsServicePath); | 36 chromeos::kSensorsServiceName, |
| 37 dbus::ObjectPath(chromeos::kSensorsServicePath)); |
36 sensors_proxy_->ConnectToSignal( | 38 sensors_proxy_->ConnectToSignal( |
37 chromeos::kSensorsServiceInterface, | 39 chromeos::kSensorsServiceInterface, |
38 chromeos::kScreenOrientationChanged, | 40 chromeos::kScreenOrientationChanged, |
39 base::Bind(&SensorsClientImpl::OrientationChangedReceived, | 41 base::Bind(&SensorsClientImpl::OrientationChangedReceived, |
40 weak_ptr_factory_.GetWeakPtr()), | 42 weak_ptr_factory_.GetWeakPtr()), |
41 base::Bind(&SensorsClientImpl::OrientationChangedConnected, | 43 base::Bind(&SensorsClientImpl::OrientationChangedConnected, |
42 weak_ptr_factory_.GetWeakPtr())); | 44 weak_ptr_factory_.GetWeakPtr())); |
43 } | 45 } |
44 | 46 |
45 virtual ~SensorsClientImpl() { | 47 virtual ~SensorsClientImpl() { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 95 |
94 SensorsClient* SensorsClient::Create(dbus::Bus* bus) { | 96 SensorsClient* SensorsClient::Create(dbus::Bus* bus) { |
95 if (system::runtime_environment::IsRunningOnChromeOS()) { | 97 if (system::runtime_environment::IsRunningOnChromeOS()) { |
96 return new SensorsClientImpl(bus); | 98 return new SensorsClientImpl(bus); |
97 } else { | 99 } else { |
98 return new SensorsClientStubImpl(); | 100 return new SensorsClientStubImpl(); |
99 } | 101 } |
100 } | 102 } |
101 | 103 |
102 } // namespace chromeos | 104 } // namespace chromeos |
OLD | NEW |