app_shell: Connect shell.gcd app API to Chrome OS privetd DBus API
[chromium-blink-merge.git] / extensions / shell / browser / api / shell_gcd / shell_gcd_api.cc
blob2cbb133a6b32a1006ba36a1652e00a00fce80236
1 // Copyright 2014 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.
5 #include "extensions/shell/browser/api/shell_gcd/shell_gcd_api.h"
7 #include "base/values.h"
8 #include "chromeos/dbus/dbus_thread_manager.h"
9 #include "chromeos/dbus/privet_daemon_client.h"
10 #include "extensions/shell/common/api/shell_gcd.h"
12 namespace gcd = extensions::shell::api::shell_gcd;
14 namespace extensions {
16 ShellGcdGetSetupStatusFunction::ShellGcdGetSetupStatusFunction() {
19 ShellGcdGetSetupStatusFunction::~ShellGcdGetSetupStatusFunction() {
22 ExtensionFunction::ResponseAction ShellGcdGetSetupStatusFunction::Run() {
23 // |this| is refcounted so we don't need the usual DBus callback WeakPtr.
24 chromeos::DBusThreadManager::Get()->GetPrivetDaemonClient()->GetSetupStatus(
25 base::Bind(&ShellGcdGetSetupStatusFunction::OnSetupStatus, this));
26 return RespondLater();
29 void ShellGcdGetSetupStatusFunction::OnSetupStatus(
30 const std::string& status_string) {
31 gcd::SetupStatus status = gcd::ParseSetupStatus(status_string);
32 Respond(ArgumentList(gcd::GetSetupStatus::Results::Create(status)));
35 } // namespace extensions