diff options
author | jamescook <jamescook@chromium.org> | 2015-02-17 15:19:52 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-17 23:20:41 +0000 |
commit | 4dec2928f6227fa8ec9b3381deeb15c15d6ab320 (patch) | |
tree | 996e53942cd68c5c8371157806a33c5389bfd472 | |
parent | a8a9e2cd46440abd315cc876a8f6740ded878a0b (diff) | |
download | chromium_src-4dec2928f6227fa8ec9b3381deeb15c15d6ab320.zip chromium_src-4dec2928f6227fa8ec9b3381deeb15c15d6ab320.tar.gz chromium_src-4dec2928f6227fa8ec9b3381deeb15c15d6ab320.tar.bz2 |
cros: Remove shell.gcd app_shell API and D-Bus wrapper for privetd
Nothing uses this API and the API is the only user of the privetd bindings.
BUG=458724
TEST=compiles, chromeos_unittests, app_shell_unittests
Review URL: https://codereview.chromium.org/925893003
Cr-Commit-Position: refs/heads/master@{#316698}
-rw-r--r-- | chromeos/chromeos.gyp | 4 | ||||
-rw-r--r-- | chromeos/dbus/dbus_client_bundle.cc | 8 | ||||
-rw-r--r-- | chromeos/dbus/dbus_client_bundle.h | 19 | ||||
-rw-r--r-- | chromeos/dbus/dbus_thread_manager.cc | 12 | ||||
-rw-r--r-- | chromeos/dbus/dbus_thread_manager.h | 3 | ||||
-rw-r--r-- | chromeos/dbus/fake_privet_daemon_client.cc | 37 | ||||
-rw-r--r-- | chromeos/dbus/fake_privet_daemon_client.h | 34 | ||||
-rw-r--r-- | chromeos/dbus/privet_daemon_client.cc | 255 | ||||
-rw-r--r-- | chromeos/dbus/privet_daemon_client.h | 81 | ||||
-rw-r--r-- | extensions/shell/app_shell.gypi | 3 | ||||
-rw-r--r-- | extensions/shell/browser/api/shell_gcd/shell_gcd_api.cc | 51 | ||||
-rw-r--r-- | extensions/shell/browser/api/shell_gcd/shell_gcd_api.h | 53 | ||||
-rw-r--r-- | extensions/shell/browser/api/shell_gcd/shell_gcd_api_unittest.cc | 57 | ||||
-rw-r--r-- | extensions/shell/common/api/schemas.gypi | 1 | ||||
-rw-r--r-- | extensions/shell/common/api/shell_gcd.idl | 24 |
15 files changed, 6 insertions, 636 deletions
diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp index 86db888..095c64e 100644 --- a/chromeos/chromeos.gyp +++ b/chromeos/chromeos.gyp @@ -174,8 +174,6 @@ 'dbus/fake_peer_daemon_manager_client.h', 'dbus/fake_permission_broker_client.cc', 'dbus/fake_permission_broker_client.h', - 'dbus/fake_privet_daemon_client.cc', - 'dbus/fake_privet_daemon_client.h', 'dbus/fake_shill_device_client.cc', 'dbus/fake_shill_device_client.h', 'dbus/fake_shill_ipconfig_client.cc', @@ -228,8 +226,6 @@ 'dbus/power_manager_client.h', 'dbus/power_policy_controller.cc', 'dbus/power_policy_controller.h', - 'dbus/privet_daemon_client.cc', - 'dbus/privet_daemon_client.h', 'dbus/services/console_service_provider.cc', 'dbus/services/console_service_provider.h', 'dbus/services/cros_dbus_service.cc', diff --git a/chromeos/dbus/dbus_client_bundle.cc b/chromeos/dbus/dbus_client_bundle.cc index 97b2112..77a7010 100644 --- a/chromeos/dbus/dbus_client_bundle.cc +++ b/chromeos/dbus/dbus_client_bundle.cc @@ -54,7 +54,6 @@ #include "chromeos/dbus/fake_nfc_tag_client.h" #include "chromeos/dbus/fake_peer_daemon_manager_client.h" #include "chromeos/dbus/fake_permission_broker_client.h" -#include "chromeos/dbus/fake_privet_daemon_client.h" #include "chromeos/dbus/fake_shill_device_client.h" #include "chromeos/dbus/fake_shill_ipconfig_client.h" #include "chromeos/dbus/fake_shill_manager_client.h" @@ -78,7 +77,6 @@ #include "chromeos/dbus/permission_broker_client.h" #include "chromeos/dbus/power_manager_client.h" #include "chromeos/dbus/power_policy_controller.h" -#include "chromeos/dbus/privet_daemon_client.h" #include "chromeos/dbus/session_manager_client.h" #include "chromeos/dbus/shill_device_client.h" #include "chromeos/dbus/shill_ipconfig_client.h" @@ -116,7 +114,6 @@ const struct { { "peer_daemon", DBusClientBundle::PEER_DAEMON }, { "permission_broker", DBusClientBundle::PERMISSION_BROKER }, { "power_manager", DBusClientBundle::POWER_MANAGER }, - { "privet_daemon", DBusClientBundle::PRIVET_DAEMON }, { "session_manager", DBusClientBundle::SESSION_MANAGER }, { "sms", DBusClientBundle::SMS }, { "system_clock", DBusClientBundle::SYSTEM_CLOCK }, @@ -275,11 +272,6 @@ DBusClientBundle::DBusClientBundle(DBusClientTypeMask unstub_client_mask) else permission_broker_client_.reset(new FakePermissionBrokerClient); - if (!IsUsingStub(PRIVET_DAEMON)) - privet_daemon_client_.reset(PrivetDaemonClient::Create()); - else - privet_daemon_client_.reset(new FakePrivetDaemonClient); - if (!IsUsingStub(LEADERSHIP_DAEMON)) { leadership_daemon_manager_client_.reset( LeadershipDaemonManagerClient::Create()); diff --git a/chromeos/dbus/dbus_client_bundle.h b/chromeos/dbus/dbus_client_bundle.h index ec18fb7a..7397ada 100644 --- a/chromeos/dbus/dbus_client_bundle.h +++ b/chromeos/dbus/dbus_client_bundle.h @@ -47,7 +47,6 @@ class NfcTagClient; class NfcRecordClient; class PeerDaemonManagerClient; class PermissionBrokerClient; -class PrivetDaemonClient; class SystemClockClient; class PowerManagerClient; class SessionManagerClient; @@ -80,13 +79,12 @@ class CHROMEOS_EXPORT DBusClientBundle { NFC = 1 << 12, PERMISSION_BROKER = 1 << 13, POWER_MANAGER = 1 << 14, - PRIVET_DAEMON = 1 << 15, - SESSION_MANAGER = 1 << 16, - SMS = 1 << 17, - SYSTEM_CLOCK = 1 << 18, - UPDATE_ENGINE = 1 << 19, - PEER_DAEMON = 1 << 20, - LEADERSHIP_DAEMON = 1 << 21, + SESSION_MANAGER = 1 << 15, + SMS = 1 << 16, + SYSTEM_CLOCK = 1 << 17, + UPDATE_ENGINE = 1 << 18, + PEER_DAEMON = 1 << 19, + LEADERSHIP_DAEMON = 1 << 20, }; explicit DBusClientBundle(DBusClientTypeMask unstub_client_mask); @@ -245,10 +243,6 @@ class CHROMEOS_EXPORT DBusClientBundle { return permission_broker_client_.get(); } - PrivetDaemonClient* privet_daemon_client() { - return privet_daemon_client_.get(); - } - SystemClockClient* system_clock_client() { return system_clock_client_.get(); } @@ -296,7 +290,6 @@ class CHROMEOS_EXPORT DBusClientBundle { scoped_ptr<LeadershipDaemonManagerClient> leadership_daemon_manager_client_; scoped_ptr<LorgnetteManagerClient> lorgnette_manager_client_; scoped_ptr<PeerDaemonManagerClient> peer_daemon_manager_client_; - scoped_ptr<PrivetDaemonClient> privet_daemon_client_; scoped_ptr<ShillDeviceClient> shill_device_client_; scoped_ptr<ShillIPConfigClient> shill_ipconfig_client_; scoped_ptr<ShillManagerClient> shill_manager_client_; diff --git a/chromeos/dbus/dbus_thread_manager.cc b/chromeos/dbus/dbus_thread_manager.cc index b75b3b0..f74886b 100644 --- a/chromeos/dbus/dbus_thread_manager.cc +++ b/chromeos/dbus/dbus_thread_manager.cc @@ -40,7 +40,6 @@ #include "chromeos/dbus/peer_daemon_manager_client.h" #include "chromeos/dbus/permission_broker_client.h" #include "chromeos/dbus/power_manager_client.h" -#include "chromeos/dbus/privet_daemon_client.h" #include "chromeos/dbus/session_manager_client.h" #include "chromeos/dbus/shill_device_client.h" #include "chromeos/dbus/shill_ipconfig_client.h" @@ -275,10 +274,6 @@ PowerManagerClient* DBusThreadManager::GetPowerManagerClient() { return client_bundle_->power_manager_client(); } -PrivetDaemonClient* DBusThreadManager::GetPrivetDaemonClient() { - return client_bundle_->privet_daemon_client(); -} - SessionManagerClient* DBusThreadManager::GetSessionManagerClient() { return client_bundle_->session_manager_client(); } @@ -321,7 +316,6 @@ void DBusThreadManager::InitializeClients() { GetPermissionBrokerClient()->Init(GetSystemBus()); GetPeerDaemonManagerClient()->Init(GetSystemBus()); GetPowerManagerClient()->Init(GetSystemBus()); - GetPrivetDaemonClient()->Init(GetSystemBus()); GetSessionManagerClient()->Init(GetSystemBus()); GetShillDeviceClient()->Init(GetSystemBus()); GetShillIPConfigClient()->Init(GetSystemBus()); @@ -652,12 +646,6 @@ void DBusThreadManagerSetter::SetPowerManagerClient( client.Pass(); } -void DBusThreadManagerSetter::SetPrivetDaemonClient( - scoped_ptr<PrivetDaemonClient> client) { - DBusThreadManager::Get()->client_bundle_->privet_daemon_client_ = - client.Pass(); -} - void DBusThreadManagerSetter::SetSessionManagerClient( scoped_ptr<SessionManagerClient> client) { DBusThreadManager::Get()->client_bundle_->session_manager_client_ = diff --git a/chromeos/dbus/dbus_thread_manager.h b/chromeos/dbus/dbus_thread_manager.h index 0d69f14..fd26384 100644 --- a/chromeos/dbus/dbus_thread_manager.h +++ b/chromeos/dbus/dbus_thread_manager.h @@ -56,7 +56,6 @@ class NfcTagClient; class PeerDaemonManagerClient; class PermissionBrokerClient; class PowerManagerClient; -class PrivetDaemonClient; class SessionManagerClient; class ShillDeviceClient; class ShillIPConfigClient; @@ -148,7 +147,6 @@ class CHROMEOS_EXPORT DBusThreadManager { PeerDaemonManagerClient* GetPeerDaemonManagerClient(); PermissionBrokerClient* GetPermissionBrokerClient(); PowerManagerClient* GetPowerManagerClient(); - PrivetDaemonClient* GetPrivetDaemonClient(); SessionManagerClient* GetSessionManagerClient(); ShillDeviceClient* GetShillDeviceClient(); ShillIPConfigClient* GetShillIPConfigClient(); @@ -245,7 +243,6 @@ class CHROMEOS_EXPORT DBusThreadManagerSetter { void SetPeerDaemonManagerClient(scoped_ptr<PeerDaemonManagerClient> client); void SetPermissionBrokerClient(scoped_ptr<PermissionBrokerClient> client); void SetPowerManagerClient(scoped_ptr<PowerManagerClient> client); - void SetPrivetDaemonClient(scoped_ptr<PrivetDaemonClient> client); void SetSessionManagerClient(scoped_ptr<SessionManagerClient> client); void SetSMSClient(scoped_ptr<SMSClient> client); void SetSystemClockClient(scoped_ptr<SystemClockClient> client); diff --git a/chromeos/dbus/fake_privet_daemon_client.cc b/chromeos/dbus/fake_privet_daemon_client.cc deleted file mode 100644 index bc252f0..0000000 --- a/chromeos/dbus/fake_privet_daemon_client.cc +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chromeos/dbus/fake_privet_daemon_client.h" - -#include <string> - -#include "base/callback.h" - -namespace chromeos { - -FakePrivetDaemonClient::FakePrivetDaemonClient() { -} - -FakePrivetDaemonClient::~FakePrivetDaemonClient() { -} - -void FakePrivetDaemonClient::Init(dbus::Bus* bus) { -} - -void FakePrivetDaemonClient::AddObserver(Observer* observer) { -} - -void FakePrivetDaemonClient::RemoveObserver(Observer* observer) { -} - -std::string FakePrivetDaemonClient::GetWifiBootstrapState() { - // Simulate Wi-Fi being configured already. - return privetd::kWiFiBootstrapStateMonitoring; -} - -void FakePrivetDaemonClient::Ping(const PingCallback& callback) { - callback.Run(true /* success */); -} - -} // namespace chromeos diff --git a/chromeos/dbus/fake_privet_daemon_client.h b/chromeos/dbus/fake_privet_daemon_client.h deleted file mode 100644 index 1b86e41..0000000 --- a/chromeos/dbus/fake_privet_daemon_client.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROMEOS_DBUS_FAKE_PRIVET_DAEMON_CLIENT_H_ -#define CHROMEOS_DBUS_FAKE_PRIVET_DAEMON_CLIENT_H_ - -#include "base/macros.h" -#include "chromeos/dbus/privet_daemon_client.h" - -namespace chromeos { - -// A fake implementation of PrivetDaemonClient. Invokes callbacks immediately. -class FakePrivetDaemonClient : public PrivetDaemonClient { - public: - FakePrivetDaemonClient(); - ~FakePrivetDaemonClient() override; - - // DBusClient overrides: - void Init(dbus::Bus* bus) override; - - // PrivetClient overrides: - void AddObserver(Observer* observer) override; - void RemoveObserver(Observer* observer) override; - std::string GetWifiBootstrapState() override; - void Ping(const PingCallback& callback) override; - - private: - DISALLOW_COPY_AND_ASSIGN(FakePrivetDaemonClient); -}; - -} // namespace chromeos - -#endif // CHROMEOS_DBUS_FAKE_PRIVET_DAEMON_CLIENT_H_ diff --git a/chromeos/dbus/privet_daemon_client.cc b/chromeos/dbus/privet_daemon_client.cc deleted file mode 100644 index cd75d67..0000000 --- a/chromeos/dbus/privet_daemon_client.cc +++ /dev/null @@ -1,255 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chromeos/dbus/privet_daemon_client.h" - -#include "base/bind.h" -#include "base/callback.h" -#include "base/logging.h" -#include "base/macros.h" -#include "base/memory/weak_ptr.h" -#include "base/observer_list.h" -#include "dbus/bus.h" -#include "dbus/message.h" -#include "dbus/object_manager.h" -#include "dbus/object_proxy.h" -#include "dbus/property.h" - -namespace chromeos { -namespace { - -// The expected response to the Ping D-Bus method. -const char kPingResponse[] = "Hello world!"; - -// The PrivetDaemonClient implementation used in production. Note that privetd -// is not available on all devices. If privetd is not running this object -// returns empty property values and logs errors for attempted method calls but -// will not crash. -class PrivetDaemonClientImpl : public PrivetDaemonClient, - public dbus::ObjectManager::Interface { - public: - // Setup state properties. The object manager reads the initial values. - struct Properties : public dbus::PropertySet { - // Network bootstrap state. Read-only. - dbus::Property<std::string> wifi_bootstrap_state; - - Properties(dbus::ObjectProxy* object_proxy, - const std::string& interface_name, - const PropertyChangedCallback& callback); - ~Properties() override; - }; - - PrivetDaemonClientImpl(); - ~PrivetDaemonClientImpl() override; - - // DBusClient overrides: - void Init(dbus::Bus* bus) override; - - // PrivetDaemonClient overrides: - void AddObserver(Observer* observer) override; - void RemoveObserver(Observer* observer) override; - std::string GetWifiBootstrapState() override; - void Ping(const PingCallback& callback) override; - - private: - // dbus::ObjectManager::Interface overrides: - dbus::PropertySet* CreateProperties( - dbus::ObjectProxy* object_proxy, - const dbus::ObjectPath& object_path, - const std::string& interface_name) override; - - // Called with the owner of the privetd service at startup and again if the - // owner changes. - void OnServiceOwnerChanged(const std::string& service_owner); - - // Cleans up |object_manager_|. - void CleanUpObjectManager(); - - // Returns the instance of the property set or null if privetd is not running. - Properties* GetProperties(); - - // Called by dbus::PropertySet when a property value is changed, either by - // result of a signal or response to a GetAll() or Get() call. Informs - // observers. - void OnPropertyChanged(const std::string& property_name); - - // Callback for the Ping D-Bus method. - void OnPing(const PingCallback& callback, dbus::Response* response); - - // The current bus, usually the system bus. Not owned. - dbus::Bus* bus_; - - // Object manager used to read D-Bus properties. Null if privetd is not - // running. Not owned. - dbus::ObjectManager* object_manager_; - - // Callback that monitors for service owner changes. - dbus::Bus::GetServiceOwnerCallback service_owner_callback_; - - // The current service owner or the empty string is privetd is not running. - std::string service_owner_; - - ObserverList<Observer> observers_; - base::WeakPtrFactory<PrivetDaemonClientImpl> weak_ptr_factory_; - - DISALLOW_COPY_AND_ASSIGN(PrivetDaemonClientImpl); -}; - -/////////////////////////////////////////////////////////////////////////////// - -PrivetDaemonClientImpl::Properties::Properties( - dbus::ObjectProxy* object_proxy, - const std::string& interface_name, - const PropertyChangedCallback& callback) - : dbus::PropertySet(object_proxy, interface_name, callback) { - RegisterProperty(privetd::kWiFiBootstrapStateProperty, &wifi_bootstrap_state); -} - -PrivetDaemonClientImpl::Properties::~Properties() { -} - -/////////////////////////////////////////////////////////////////////////////// - -PrivetDaemonClientImpl::PrivetDaemonClientImpl() - : bus_(nullptr), object_manager_(nullptr), weak_ptr_factory_(this) { -} - -PrivetDaemonClientImpl::~PrivetDaemonClientImpl() { - CleanUpObjectManager(); - if (bus_) { - bus_->UnlistenForServiceOwnerChange(privetd::kPrivetdServiceName, - service_owner_callback_); - } -} - -void PrivetDaemonClientImpl::Init(dbus::Bus* bus) { - bus_ = bus; - // privetd may not be running. Watch for it starting up later. - service_owner_callback_ = - base::Bind(&PrivetDaemonClientImpl::OnServiceOwnerChanged, - weak_ptr_factory_.GetWeakPtr()); - bus_->ListenForServiceOwnerChange(privetd::kPrivetdServiceName, - service_owner_callback_); - // Also explicitly check for its existence on startup. - bus_->GetServiceOwner(privetd::kPrivetdServiceName, service_owner_callback_); -} - -void PrivetDaemonClientImpl::AddObserver(Observer* observer) { - observers_.AddObserver(observer); -} - -void PrivetDaemonClientImpl::RemoveObserver(Observer* observer) { - observers_.RemoveObserver(observer); -} - -std::string PrivetDaemonClientImpl::GetWifiBootstrapState() { - Properties* properties = GetProperties(); - if (!properties) - return ""; - return properties->wifi_bootstrap_state.value(); -} - -dbus::PropertySet* PrivetDaemonClientImpl::CreateProperties( - dbus::ObjectProxy* object_proxy, - const dbus::ObjectPath& object_path, - const std::string& interface_name) { - return new Properties(object_proxy, interface_name, - base::Bind(&PrivetDaemonClientImpl::OnPropertyChanged, - weak_ptr_factory_.GetWeakPtr())); -} - -void PrivetDaemonClientImpl::Ping(const PingCallback& callback) { - if (!object_manager_) { - LOG(ERROR) << "privetd not available."; - return; - } - dbus::ObjectProxy* proxy = object_manager_->GetObjectProxy( - dbus::ObjectPath(privetd::kPrivetdManagerServicePath)); - if (!proxy) { - LOG(ERROR) << "Object not available."; - return; - } - dbus::MethodCall method_call(privetd::kPrivetdManagerInterface, - privetd::kPingMethod); - proxy->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, - base::Bind(&PrivetDaemonClientImpl::OnPing, - weak_ptr_factory_.GetWeakPtr(), callback)); -} - -void PrivetDaemonClientImpl::OnServiceOwnerChanged( - const std::string& service_owner) { - // If |service_owner| and |service_owner_| are both empty then the service - // hasn't started yet. If they match the owner hasn't changed. - if (service_owner == service_owner_) - return; - - service_owner_ = service_owner; - if (service_owner_.empty()) { - LOG(ERROR) << "Lost privetd service."; - CleanUpObjectManager(); - return; - } - - // Finish initialization (or re-initialize if privetd restarted). - object_manager_ = - bus_->GetObjectManager(privetd::kPrivetdServiceName, - dbus::ObjectPath(privetd::kPrivetdServicePath)); - object_manager_->RegisterInterface(privetd::kPrivetdManagerInterface, this); -} - -void PrivetDaemonClientImpl::CleanUpObjectManager() { - if (object_manager_) { - object_manager_->UnregisterInterface(privetd::kPrivetdManagerInterface); - object_manager_ = nullptr; - } -} - -PrivetDaemonClientImpl::Properties* PrivetDaemonClientImpl::GetProperties() { - if (!object_manager_) - return nullptr; - - return static_cast<Properties*>(object_manager_->GetProperties( - dbus::ObjectPath(privetd::kPrivetdManagerServicePath), - privetd::kPrivetdManagerInterface)); -} - -void PrivetDaemonClientImpl::OnPropertyChanged( - const std::string& property_name) { - FOR_EACH_OBSERVER(PrivetDaemonClient::Observer, observers_, - OnPrivetDaemonPropertyChanged(property_name)); -} - -void PrivetDaemonClientImpl::OnPing(const PingCallback& callback, - dbus::Response* response) { - if (!response) { - LOG(ERROR) << "Error calling " << privetd::kPingMethod; - callback.Run(false); - return; - } - dbus::MessageReader reader(response); - std::string value; - if (!reader.PopString(&value)) { - LOG(ERROR) << "Error reading response from privetd: " - << response->ToString(); - } - // Returns success if the expected value is received. - callback.Run(value == kPingResponse); -} - -} // namespace - -////////////////////////////////////////////////////////////////////////////// - -PrivetDaemonClient::PrivetDaemonClient() { -} - -PrivetDaemonClient::~PrivetDaemonClient() { -} - -// static -PrivetDaemonClient* PrivetDaemonClient::Create() { - return new PrivetDaemonClientImpl(); -} - -} // namespace chromeos diff --git a/chromeos/dbus/privet_daemon_client.h b/chromeos/dbus/privet_daemon_client.h deleted file mode 100644 index 04e9df7..0000000 --- a/chromeos/dbus/privet_daemon_client.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROMEOS_DBUS_PRIVET_DAEMON_CLIENT_H_ -#define CHROMEOS_DBUS_PRIVET_DAEMON_CLIENT_H_ - -#include <string> - -#include "base/callback_forward.h" -#include "base/macros.h" -#include "chromeos/chromeos_export.h" -#include "chromeos/dbus/dbus_client.h" - -// TODO(jamescook): The DBus interface is still being defined by the privetd -// team. Move to third_party/cros_system_api/dbus/service_constants.h when the -// interface is finalized. -namespace privetd { -const char kPrivetdServiceName[] = "org.chromium.privetd"; -const char kPrivetdServicePath[] = "/org/chromium/privetd"; -const char kPrivetdManagerInterface[] = "org.chromium.privetd.Manager"; -const char kPrivetdManagerServicePath[] = "/org/chromium/privetd/Manager"; - -// Properties. -const char kWiFiBootstrapStateProperty[] = "WiFiBootstrapState"; - -// Property values. -const char kWiFiBootstrapStateDisabled[] = "disabled"; -const char kWiFiBootstrapStateWaiting[] = "waiting"; -const char kWiFiBootstrapStateConnecting[] = "connecting"; -const char kWiFiBootstrapStateMonitoring[] = "monitoring"; - -// Methods. -const char kPingMethod[] = "Ping"; -} // namespace privetd - -namespace chromeos { - -// PrivetDaemonClient is used to communicate with privetd for Wi-Fi -// bootstrapping and setup. The most common user for this code would be an -// embedded Chrome OS Core device. -class CHROMEOS_EXPORT PrivetDaemonClient : public DBusClient { - public: - // Returns true if privetd correctly responded to Ping(). - using PingCallback = base::Callback<void(bool success)>; - - // Interface for observing changes in setup state. - class Observer { - public: - virtual ~Observer() {} - - // Notifies the observer when a named |property| changes. - virtual void OnPrivetDaemonPropertyChanged(const std::string& property) = 0; - }; - - ~PrivetDaemonClient() override; - - // The usual observer interface. - virtual void AddObserver(Observer* observer) = 0; - virtual void RemoveObserver(Observer* observer) = 0; - - // Returns the current properties. - virtual std::string GetWifiBootstrapState() = 0; - - // Asynchronously pings the daemon. - virtual void Ping(const PingCallback& callback) = 0; - - // Creates a new instance and returns ownership. - static PrivetDaemonClient* Create(); - - protected: - // Create() should be used instead. - PrivetDaemonClient(); - - private: - DISALLOW_COPY_AND_ASSIGN(PrivetDaemonClient); -}; - -} // namespace chromeos - -#endif // CHROMEOS_DBUS_PRIVET_DAEMON_CLIENT_H_ diff --git a/extensions/shell/app_shell.gypi b/extensions/shell/app_shell.gypi index 8763e64..4c6bc8d 100644 --- a/extensions/shell/app_shell.gypi +++ b/extensions/shell/app_shell.gypi @@ -101,8 +101,6 @@ 'browser/shell_screen.h', ], 'app_shell_lib_sources_chromeos': [ - 'browser/api/shell_gcd/shell_gcd_api.cc', - 'browser/api/shell_gcd/shell_gcd_api.h', 'browser/api/vpn_provider/vpn_service_factory.cc', ], 'app_shell_lib_sources_nacl': [ @@ -129,7 +127,6 @@ 'browser/shell_screen_unittest.cc', ], 'app_shell_unittests_sources_chromeos': [ - 'browser/api/shell_gcd/shell_gcd_api_unittest.cc', 'browser/shell_audio_controller_chromeos_unittest.cc', ], 'app_shell_unittests_sources_nacl': [ diff --git a/extensions/shell/browser/api/shell_gcd/shell_gcd_api.cc b/extensions/shell/browser/api/shell_gcd/shell_gcd_api.cc deleted file mode 100644 index ea3d35c..0000000 --- a/extensions/shell/browser/api/shell_gcd/shell_gcd_api.cc +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "extensions/shell/browser/api/shell_gcd/shell_gcd_api.h" - -#include <string> - -#include "base/values.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/privet_daemon_client.h" -#include "extensions/shell/common/api/shell_gcd.h" - -namespace gcd = extensions::shell::api::shell_gcd; - -namespace extensions { - -ShellGcdPingFunction::ShellGcdPingFunction() { -} - -ShellGcdPingFunction::~ShellGcdPingFunction() { -} - -ExtensionFunction::ResponseAction ShellGcdPingFunction::Run() { - // |this| is refcounted so we don't need the usual DBus callback WeakPtr. - chromeos::DBusThreadManager::Get()->GetPrivetDaemonClient()->Ping( - base::Bind(&ShellGcdPingFunction::OnPing, this)); - return RespondLater(); -} - -void ShellGcdPingFunction::OnPing(bool success) { - Respond(OneArgument(new base::FundamentalValue(success))); -} - -/////////////////////////////////////////////////////////////////////////////// - -ShellGcdGetWiFiBootstrapStateFunction::ShellGcdGetWiFiBootstrapStateFunction() { -} - -ShellGcdGetWiFiBootstrapStateFunction:: - ~ShellGcdGetWiFiBootstrapStateFunction() { -} - -ExtensionFunction::ResponseAction ShellGcdGetWiFiBootstrapStateFunction::Run() { - std::string state = chromeos::DBusThreadManager::Get() - ->GetPrivetDaemonClient() - ->GetWifiBootstrapState(); - return RespondNow(OneArgument(new base::StringValue(state))); -} - -} // namespace extensions diff --git a/extensions/shell/browser/api/shell_gcd/shell_gcd_api.h b/extensions/shell/browser/api/shell_gcd/shell_gcd_api.h deleted file mode 100644 index 327f3aa..0000000 --- a/extensions/shell/browser/api/shell_gcd/shell_gcd_api.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef EXTENSIONS_SHELL_BROWSER_API_SHELL_GCD_SHELL_GCD_API_H_ -#define EXTENSIONS_SHELL_BROWSER_API_SHELL_GCD_SHELL_GCD_API_H_ - -#include "base/macros.h" -#include "extensions/browser/extension_function.h" - -namespace extensions { - -// Used for manual testing in app_shell. See shell_gcd.idl for documentation. -class ShellGcdPingFunction : public UIThreadExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("shell.gcd.ping", UNKNOWN); - - ShellGcdPingFunction(); - - protected: - ~ShellGcdPingFunction() override; - - // ExtensionFunction: - ResponseAction Run() override; - - private: - // Callback for status from DBus call to GCD privet daemon. - void OnPing(bool success); - - DISALLOW_COPY_AND_ASSIGN(ShellGcdPingFunction); -}; - -/////////////////////////////////////////////////////////////////////////////// - -// Used for manual testing in app_shell. See shell_gcd.idl for documentation. -class ShellGcdGetWiFiBootstrapStateFunction : public UIThreadExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("shell.gcd.getWiFiBootstrapState", UNKNOWN); - - ShellGcdGetWiFiBootstrapStateFunction(); - - // ExtensionFunction: - ResponseAction Run() override; - - private: - ~ShellGcdGetWiFiBootstrapStateFunction() override; - - DISALLOW_COPY_AND_ASSIGN(ShellGcdGetWiFiBootstrapStateFunction); -}; - -} // namespace extensions - -#endif // EXTENSIONS_SHELL_BROWSER_API_SHELL_GCD_SHELL_GCD_API_H_ diff --git a/extensions/shell/browser/api/shell_gcd/shell_gcd_api_unittest.cc b/extensions/shell/browser/api/shell_gcd/shell_gcd_api_unittest.cc deleted file mode 100644 index 66e4401..0000000 --- a/extensions/shell/browser/api/shell_gcd/shell_gcd_api_unittest.cc +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "extensions/shell/browser/api/shell_gcd/shell_gcd_api.h" - -#include <string> - -#include "base/memory/scoped_ptr.h" -#include "base/values.h" -#include "chromeos/dbus/dbus_thread_manager.h" -#include "chromeos/dbus/privet_daemon_client.h" -#include "extensions/browser/api_unittest.h" - -namespace extensions { - -class ShellGcdApiTest : public ApiUnitTest { - public: - ShellGcdApiTest() {} - ~ShellGcdApiTest() override {} - - // testing::Test overrides: - void SetUp() override { - ApiUnitTest::SetUp(); - chromeos::DBusThreadManager::Initialize(); - } - - void TearDown() override { - chromeos::DBusThreadManager::Shutdown(); - ApiUnitTest::TearDown(); - } - - private: - DISALLOW_COPY_AND_ASSIGN(ShellGcdApiTest); -}; - -TEST_F(ShellGcdApiTest, Ping) { - // Function succeeds and returns a result (for its callback). - scoped_ptr<base::Value> result = - RunFunctionAndReturnValue(new ShellGcdPingFunction, "[{}]"); - ASSERT_TRUE(result.get()); - bool success = false; - result->GetAsBoolean(&success); - EXPECT_TRUE(success); -} - -TEST_F(ShellGcdApiTest, GetWiFiBootstrapState) { - // Function succeeds and returns a result (for its callback). - scoped_ptr<base::Value> result = RunFunctionAndReturnValue( - new ShellGcdGetWiFiBootstrapStateFunction, "[{}]"); - ASSERT_TRUE(result.get()); - std::string state; - result->GetAsString(&state); - EXPECT_EQ(privetd::kWiFiBootstrapStateMonitoring, state); -} - -} // namespace extensions diff --git a/extensions/shell/common/api/schemas.gypi b/extensions/shell/common/api/schemas.gypi index 201628b..f257f9b 100644 --- a/extensions/shell/common/api/schemas.gypi +++ b/extensions/shell/common/api/schemas.gypi @@ -14,7 +14,6 @@ ], # Chrome OS specific APIs. 'chromeos_schema_files': [ - 'shell_gcd.idl', ], 'chromium_code': 1, diff --git a/extensions/shell/common/api/shell_gcd.idl b/extensions/shell/common/api/shell_gcd.idl deleted file mode 100644 index 65c80300..0000000 --- a/extensions/shell/common/api/shell_gcd.idl +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Setup related functions for a Google Cloud Devices (GCD) target device -// running on Chrome OS Core. The actual bootstrapping and GCD registration is -// handled by the privetd and buffet system daemons. -// -// TODO(jamescook): This API exists only for manual testing of GCD in app_shell. -// Delete it when GCD setup is integrated into OOBE. -namespace shell.gcd { - - callback PingCallback = void(boolean success); - callback StateCallback = void(DOMString state); - - interface Functions { - // Attempts to ping the daemon via D-Bus. - static void ping(PingCallback callback); - - // Returns the Wi-Fi bootstrap state. Return values are found in - // platform2/privetd/dbus_bindings/org.chromium.privetd.Manager.xml. - static void getWiFiBootstrapState(StateCallback callback); - }; -}; |