| Index: chrome/utility/wifi/wifi_service.h
|
| diff --git a/chrome/utility/wifi/wifi_service.h b/chrome/utility/wifi/wifi_service.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d5d7c79a2fcc6307e116106d30b42f19fb10e81f
|
| --- /dev/null
|
| +++ b/chrome/utility/wifi/wifi_service.h
|
| @@ -0,0 +1,157 @@
|
| +// Copyright 2013 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 CHROME_UTILITY_WIFI_WIFI_SERVICE_H_
|
| +#define CHROME_UTILITY_WIFI_WIFI_SERVICE_H_
|
| +
|
| +#include <list>
|
| +#include <string>
|
| +
|
| +#include "base/callback.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/values.h"
|
| +
|
| +namespace wifi {
|
| +
|
| +// WiFiService interface used by implementation of chrome.networkingPrivate
|
| +// JavaScript extension API.
|
| +class WiFiService {
|
| + public:
|
| + typedef int32 Frequency;
|
| + enum FrequencyEnum {
|
| + kFrequencyUnknown = 0,
|
| + kFrequency2400 = 2400,
|
| + kFrequency5000 = 5000
|
| + };
|
| +
|
| + typedef std::list<Frequency> FrequencyList;
|
| +
|
| + // Network Properties, used as result of |GetProperties| and
|
| + // |GetVisibleNetworks|.
|
| + // TODO(mef): Replace with |DictionaryValue| once onc_constants are moved into
|
| + // src/components.
|
| + struct NetworkProperties {
|
| + NetworkProperties();
|
| + ~NetworkProperties();
|
| +
|
| + std::string connection_state;
|
| + std::string guid;
|
| + std::string name;
|
| + std::string ssid;
|
| + std::string bssid;
|
| + std::string type;
|
| + std::string security;
|
| + // WiFi Signal Strength. 0..100
|
| + int32 signal_strength;
|
| + bool auto_connect;
|
| + Frequency frequency;
|
| + FrequencyList frequency_list;
|
| +
|
| + std::string json_extra; // Extra JSON properties for unit tests
|
| +
|
| + scoped_ptr<base::DictionaryValue> ToValue(bool network_list) const;
|
| + bool UpdateFromValue(const base::DictionaryValue& value);
|
| + static std::string MacAddressAsString(const uint8 mac_as_int[6]);
|
| + static bool OrderByType(const NetworkProperties& l,
|
| + const NetworkProperties& r);
|
| + };
|
| +
|
| + typedef std::list<NetworkProperties> NetworkList;
|
| + typedef std::list<std::string> NetworkGuidList;
|
| +
|
| + // An error callback used by both the configuration handler and the state
|
| + // handler to receive error results from the API.
|
| + typedef base::Callback<
|
| + void(const std::string& error_name,
|
| + scoped_ptr<base::DictionaryValue> error_data)> ErrorCallback;
|
| +
|
| + typedef base::Callback<
|
| + void(const std::string& network_guid,
|
| + const base::DictionaryValue& dictionary)> DictionaryResultCallback;
|
| +
|
| + typedef base::Callback<
|
| + void(const std::string& network_guid,
|
| + const NetworkProperties& properties)> NetworkPropertiesCallback;
|
| +
|
| + typedef base::Callback<
|
| + void(const NetworkList& network_list)> NetworkListCallback;
|
| +
|
| + typedef base::Callback<
|
| + void(const std::string& service_path)> StringResultCallback;
|
| +
|
| + typedef base::Callback<
|
| + void(const NetworkGuidList& network_guid_list)> NetworkGuidListCallback;
|
| +
|
| + virtual ~WiFiService() {}
|
| +
|
| + // Get Properties of network identified by |network_guid|. Run |callback| on
|
| + // success, |error_callback| on failure.
|
| + virtual void GetProperties(const std::string& network_guid,
|
| + const NetworkPropertiesCallback& callback,
|
| + const ErrorCallback& error_callback) = 0;
|
| +
|
| + // Get State of network identified by |network_guid|. Run |callback| on
|
| + // success, |error_callback| on failure. Not implemented except unit tests.
|
| + virtual void GetState(const std::string& network_guid,
|
| + const NetworkPropertiesCallback& callback,
|
| + const ErrorCallback& error_callback) = 0;
|
| +
|
| + // Get Managed Properties of network identified by |network_guid|.
|
| + // Run |callback| on success, |error_callback| on failure. Not implemented
|
| + // except unit tests.
|
| + virtual void GetManagedProperties(const std::string& network_guid,
|
| + const DictionaryResultCallback& callback,
|
| + const ErrorCallback& error_callback) = 0;
|
| +
|
| + // Set Properties of network identified by |network_guid|. Run |callback| on
|
| + // success, |error_callback| on failure. Not implemented except unit tests.
|
| + virtual void SetProperties(const std::string& network_guid,
|
| + const base::DictionaryValue& properties,
|
| + const StringResultCallback& callback,
|
| + const ErrorCallback& error_callback) = 0;
|
| +
|
| + // Get list of visible networks. Run |callback| on success, |error_callback|
|
| + // on failure.
|
| + virtual void GetVisibleNetworks(const NetworkListCallback& callback,
|
| + const ErrorCallback& error_callback) = 0;
|
| +
|
| + // Request network scan. Send |NetworkListChanged| event on completion.
|
| + virtual void RequestNetworkScan() = 0;
|
| +
|
| + // Start connect to network identified by |network_guid|. Run |callback| on
|
| + // success, |error_callback| on failure. Send |NetworksChanged| event
|
| + // on completion.
|
| + virtual void StartConnect(const std::string& network_guid,
|
| + const StringResultCallback& callback,
|
| + const ErrorCallback& error_callback) = 0;
|
| +
|
| + // Start disconnect from network identified by |network_guid|. Run |callback|
|
| + // on success, |error_callback| on failure. Send |NetworksChanged| event on
|
| + // completion.
|
| + virtual void StartDisconnect(const std::string& network_guid,
|
| + const StringResultCallback& callback,
|
| + const ErrorCallback& error_callback) = 0;
|
| +
|
| + // Set |observer| to run when |NetworksChanged| event needs to be sent.
|
| + virtual void SetNetworksChangedObserver(
|
| + const NetworkGuidListCallback& observer) = 0;
|
| +
|
| + // Set |observer| to run when |NetworkListChanged| event needs to be sent.
|
| + virtual void SetNetworkListChangedObserver(
|
| + const NetworkGuidListCallback& observer) = 0;
|
| +
|
| + // Create instance of |WiFiService| for normal use. Creates mock service on
|
| + // non-Windows system.
|
| + static WiFiService* CreateService();
|
| + // Create instance of |WiFiService| for unit test use.
|
| + static WiFiService* CreateServiceMock();
|
| +
|
| + protected:
|
| + WiFiService() {}
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(WiFiService);
|
| +};
|
| +} // namespace wifi
|
| +#endif // CHROME_UTILITY_WIFI_WIFI_SERVICE_H_
|
|
|