OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "chromeos/dbus/nfc_device_client.h" | 5 #include "chromeos/dbus/nfc_device_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // NfcDeviceClient override. | 62 // NfcDeviceClient override. |
63 virtual Properties* GetProperties( | 63 virtual Properties* GetProperties( |
64 const dbus::ObjectPath& object_path) OVERRIDE { | 64 const dbus::ObjectPath& object_path) OVERRIDE { |
65 return static_cast<Properties*>( | 65 return static_cast<Properties*>( |
66 adapters_to_object_maps_.FindObjectProperties(object_path)); | 66 adapters_to_object_maps_.FindObjectProperties(object_path)); |
67 } | 67 } |
68 | 68 |
69 // NfcDeviceClient override. | 69 // NfcDeviceClient override. |
70 virtual void Push( | 70 virtual void Push( |
71 const dbus::ObjectPath& object_path, | 71 const dbus::ObjectPath& object_path, |
72 const NfcRecordClient::Attributes& attributes, | 72 const base::DictionaryValue& attributes, |
73 const base::Closure& callback, | 73 const base::Closure& callback, |
74 const nfc_client_helpers::ErrorCallback& error_callback) OVERRIDE { | 74 const nfc_client_helpers::ErrorCallback& error_callback) OVERRIDE { |
75 dbus::ObjectProxy* object_proxy = | 75 dbus::ObjectProxy* object_proxy = |
76 adapters_to_object_maps_.FindObjectProxy(object_path); | 76 adapters_to_object_maps_.FindObjectProxy(object_path); |
77 if (!object_proxy) { | 77 if (!object_proxy) { |
78 std::string error_message = | 78 std::string error_message = |
79 base::StringPrintf( | 79 base::StringPrintf( |
80 "NFC device with object path \"%s\" does not exist.", | 80 "NFC device with object path \"%s\" does not exist.", |
81 object_path.value().c_str()); | 81 object_path.value().c_str()); |
82 LOG(ERROR) << error_message; | 82 LOG(ERROR) << error_message; |
(...skipping 11 matching lines...) Expand all Loading... |
94 return; | 94 return; |
95 } | 95 } |
96 | 96 |
97 // Create the arguments. | 97 // Create the arguments. |
98 dbus::MethodCall method_call(nfc_device::kNfcDeviceInterface, | 98 dbus::MethodCall method_call(nfc_device::kNfcDeviceInterface, |
99 nfc_device::kPush); | 99 nfc_device::kPush); |
100 dbus::MessageWriter writer(&method_call); | 100 dbus::MessageWriter writer(&method_call); |
101 dbus::MessageWriter array_writer(NULL); | 101 dbus::MessageWriter array_writer(NULL); |
102 dbus::MessageWriter dict_entry_writer(NULL); | 102 dbus::MessageWriter dict_entry_writer(NULL); |
103 writer.OpenArray("{sv}", &array_writer); | 103 writer.OpenArray("{sv}", &array_writer); |
104 for (NfcRecordClient::Attributes::const_iterator iter = attributes.begin(); | 104 for (DictionaryValue::Iterator iter(attributes); |
105 iter != attributes.end(); ++iter) { | 105 !iter.IsAtEnd(); iter.Advance()) { |
106 array_writer.OpenDictEntry(&dict_entry_writer); | 106 array_writer.OpenDictEntry(&dict_entry_writer); |
107 dict_entry_writer.AppendString(iter->first); | 107 dict_entry_writer.AppendString(iter.key()); |
108 dict_entry_writer.AppendVariantOfString(iter->second); | 108 nfc_client_helpers::AppendValueDataAsVariant(&dict_entry_writer, |
| 109 iter.value()); |
109 array_writer.CloseContainer(&dict_entry_writer); | 110 array_writer.CloseContainer(&dict_entry_writer); |
110 } | 111 } |
111 writer.CloseContainer(&array_writer); | 112 writer.CloseContainer(&array_writer); |
112 | 113 |
113 object_proxy->CallMethodWithErrorCallback( | 114 object_proxy->CallMethodWithErrorCallback( |
114 &method_call, | 115 &method_call, |
115 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 116 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
116 base::Bind(&nfc_client_helpers::OnSuccess, callback), | 117 base::Bind(&nfc_client_helpers::OnSuccess, callback), |
117 base::Bind(&nfc_client_helpers::OnError, error_callback)); | 118 base::Bind(&nfc_client_helpers::OnError, error_callback)); |
118 } | 119 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 } | 231 } |
231 | 232 |
232 NfcDeviceClient::~NfcDeviceClient() { | 233 NfcDeviceClient::~NfcDeviceClient() { |
233 } | 234 } |
234 | 235 |
235 NfcDeviceClient* NfcDeviceClient::Create(NfcAdapterClient* adapter_client) { | 236 NfcDeviceClient* NfcDeviceClient::Create(NfcAdapterClient* adapter_client) { |
236 return new NfcDeviceClientImpl(adapter_client); | 237 return new NfcDeviceClientImpl(adapter_client); |
237 } | 238 } |
238 | 239 |
239 } // namespace chromeos | 240 } // namespace chromeos |
OLD | NEW |