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
3 // found in the LICENSE file.
8 #include "base/bind_helpers.h"
9 #include "base/callback.h"
10 #include "base/command_line.h"
11 #include "base/location.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/values.h"
14 #include "chromeos/chromeos_switches.h"
15 #include "chromeos/dbus/fake_sms_client.h"
16 #include "dbus/object_path.h"
20 FakeSMSClient::FakeSMSClient() : weak_ptr_factory_(this) {}
22 FakeSMSClient::~FakeSMSClient() {}
24 void FakeSMSClient::Init(dbus::Bus
* bus
) {}
26 void FakeSMSClient::GetAll(const std::string
& service_name
,
27 const dbus::ObjectPath
& object_path
,
28 const GetAllCallback
& callback
) {
29 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
30 chromeos::switches::kSmsTestMessages
))
33 // Ownership passed to callback
34 base::DictionaryValue
* sms
= new base::DictionaryValue();
35 sms
->SetString("Number", "000-000-0000");
36 sms
->SetString("Text", "FakeSMSClient: Test Message: " + object_path
.value());
37 sms
->SetString("Timestamp", "Fri Jun 8 13:26:04 EDT 2012");
39 // Run callback asynchronously.
40 if (callback
.is_null())
42 base::MessageLoop::current()->PostTask(
44 base::Bind(&FakeSMSClient::OnGetAll
,
45 weak_ptr_factory_
.GetWeakPtr(),
50 void FakeSMSClient::OnGetAll(base::DictionaryValue
* sms
,
51 const GetAllCallback
& callback
) {
55 } // namespace chromeos