| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_LINUX_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_LINUX_H_ |
| 6 #define EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_LINUX_H_ | 6 #define EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_LINUX_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 // Linux NetworkingPrivateDelegate implementation. | 33 // Linux NetworkingPrivateDelegate implementation. |
| 34 class NetworkingPrivateLinux : public NetworkingPrivateDelegate { | 34 class NetworkingPrivateLinux : public NetworkingPrivateDelegate { |
| 35 public: | 35 public: |
| 36 typedef std::map<base::string16, linked_ptr<base::DictionaryValue>> | 36 typedef std::map<base::string16, linked_ptr<base::DictionaryValue>> |
| 37 NetworkMap; | 37 NetworkMap; |
| 38 | 38 |
| 39 typedef std::vector<std::string> GuidList; | 39 typedef std::vector<std::string> GuidList; |
| 40 | 40 |
| 41 NetworkingPrivateLinux(content::BrowserContext* browser_context, | 41 NetworkingPrivateLinux(content::BrowserContext* browser_context, |
| 42 scoped_ptr<VerifyDelegate> verify_delegate); | 42 std::unique_ptr<VerifyDelegate> verify_delegate); |
| 43 | 43 |
| 44 // NetworkingPrivateDelegate | 44 // NetworkingPrivateDelegate |
| 45 void GetProperties(const std::string& guid, | 45 void GetProperties(const std::string& guid, |
| 46 const DictionaryCallback& success_callback, | 46 const DictionaryCallback& success_callback, |
| 47 const FailureCallback& failure_callback) override; | 47 const FailureCallback& failure_callback) override; |
| 48 void GetManagedProperties(const std::string& guid, | 48 void GetManagedProperties(const std::string& guid, |
| 49 const DictionaryCallback& success_callback, | 49 const DictionaryCallback& success_callback, |
| 50 const FailureCallback& failure_callback) override; | 50 const FailureCallback& failure_callback) override; |
| 51 void GetState(const std::string& guid, | 51 void GetState(const std::string& guid, |
| 52 const DictionaryCallback& success_callback, | 52 const DictionaryCallback& success_callback, |
| 53 const FailureCallback& failure_callback) override; | 53 const FailureCallback& failure_callback) override; |
| 54 void SetProperties(const std::string& guid, | 54 void SetProperties(const std::string& guid, |
| 55 scoped_ptr<base::DictionaryValue> properties, | 55 std::unique_ptr<base::DictionaryValue> properties, |
| 56 const VoidCallback& success_callback, | 56 const VoidCallback& success_callback, |
| 57 const FailureCallback& failure_callback) override; | 57 const FailureCallback& failure_callback) override; |
| 58 void CreateNetwork(bool shared, | 58 void CreateNetwork(bool shared, |
| 59 scoped_ptr<base::DictionaryValue> properties, | 59 std::unique_ptr<base::DictionaryValue> properties, |
| 60 const StringCallback& success_callback, | 60 const StringCallback& success_callback, |
| 61 const FailureCallback& failure_callback) override; | 61 const FailureCallback& failure_callback) override; |
| 62 void ForgetNetwork(const std::string& guid, | 62 void ForgetNetwork(const std::string& guid, |
| 63 const VoidCallback& success_callback, | 63 const VoidCallback& success_callback, |
| 64 const FailureCallback& failure_callback) override; | 64 const FailureCallback& failure_callback) override; |
| 65 void GetNetworks(const std::string& network_type, | 65 void GetNetworks(const std::string& network_type, |
| 66 bool configured_only, | 66 bool configured_only, |
| 67 bool visible_only, | 67 bool visible_only, |
| 68 int limit, | 68 int limit, |
| 69 const NetworkListCallback& success_callback, | 69 const NetworkListCallback& success_callback, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 90 const std::string& puk, | 90 const std::string& puk, |
| 91 const VoidCallback& success_callback, | 91 const VoidCallback& success_callback, |
| 92 const FailureCallback& failure_callback) override; | 92 const FailureCallback& failure_callback) override; |
| 93 void SetCellularSimState(const std::string& guid, | 93 void SetCellularSimState(const std::string& guid, |
| 94 bool require_pin, | 94 bool require_pin, |
| 95 const std::string& current_pin, | 95 const std::string& current_pin, |
| 96 const std::string& new_pin, | 96 const std::string& new_pin, |
| 97 const VoidCallback& success_callback, | 97 const VoidCallback& success_callback, |
| 98 const FailureCallback& failure_callback) override; | 98 const FailureCallback& failure_callback) override; |
| 99 | 99 |
| 100 scoped_ptr<base::ListValue> GetEnabledNetworkTypes() override; | 100 std::unique_ptr<base::ListValue> GetEnabledNetworkTypes() override; |
| 101 scoped_ptr<DeviceStateList> GetDeviceStateList() override; | 101 std::unique_ptr<DeviceStateList> GetDeviceStateList() override; |
| 102 bool EnableNetworkType(const std::string& type) override; | 102 bool EnableNetworkType(const std::string& type) override; |
| 103 bool DisableNetworkType(const std::string& type) override; | 103 bool DisableNetworkType(const std::string& type) override; |
| 104 bool RequestScan() override; | 104 bool RequestScan() override; |
| 105 void AddObserver(NetworkingPrivateDelegateObserver* observer) override; | 105 void AddObserver(NetworkingPrivateDelegateObserver* observer) override; |
| 106 void RemoveObserver(NetworkingPrivateDelegateObserver* observer) override; | 106 void RemoveObserver(NetworkingPrivateDelegateObserver* observer) override; |
| 107 | 107 |
| 108 private: | 108 private: |
| 109 ~NetworkingPrivateLinux() override; | 109 ~NetworkingPrivateLinux() override; |
| 110 | 110 |
| 111 // https://developer.gnome.org/NetworkManager/unstable/spec.html#type-NM_DEVIC
E_TYPE | 111 // https://developer.gnome.org/NetworkManager/unstable/spec.html#type-NM_DEVIC
E_TYPE |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 174 |
| 175 // Helper function to enumerate WiFi networks. Takes a path to a Wireless | 175 // Helper function to enumerate WiFi networks. Takes a path to a Wireless |
| 176 // device, scans that device and appends networks to network_list. | 176 // device, scans that device and appends networks to network_list. |
| 177 // Returns false if there is an error getting the access points visible | 177 // Returns false if there is an error getting the access points visible |
| 178 // to the |device_path|. | 178 // to the |device_path|. |
| 179 bool AddAccessPointsFromDevice(const dbus::ObjectPath& device_path, | 179 bool AddAccessPointsFromDevice(const dbus::ObjectPath& device_path, |
| 180 NetworkMap* network_map); | 180 NetworkMap* network_map); |
| 181 | 181 |
| 182 // Reply callback accepts the map of networks and fires the | 182 // Reply callback accepts the map of networks and fires the |
| 183 // OnNetworkListChanged event and user callbacks. | 183 // OnNetworkListChanged event and user callbacks. |
| 184 void OnAccessPointsFound(scoped_ptr<NetworkMap> network_map, | 184 void OnAccessPointsFound(std::unique_ptr<NetworkMap> network_map, |
| 185 const NetworkListCallback& success_callback, | 185 const NetworkListCallback& success_callback, |
| 186 const FailureCallback& failure_callback); | 186 const FailureCallback& failure_callback); |
| 187 | 187 |
| 188 // Reply callback accepts the map of networks and fires the | 188 // Reply callback accepts the map of networks and fires the |
| 189 // OnNetworkListChanged event. | 189 // OnNetworkListChanged event. |
| 190 void OnAccessPointsFoundViaScan(scoped_ptr<NetworkMap> network_map); | 190 void OnAccessPointsFoundViaScan(std::unique_ptr<NetworkMap> network_map); |
| 191 | 191 |
| 192 // Helper function for OnAccessPointsFound and OnAccessPointsFoundViaScan to | 192 // Helper function for OnAccessPointsFound and OnAccessPointsFoundViaScan to |
| 193 // fire the OnNetworkListChangedEvent. | 193 // fire the OnNetworkListChangedEvent. |
| 194 void SendNetworkListChangedEvent(const base::ListValue& network_list); | 194 void SendNetworkListChangedEvent(const base::ListValue& network_list); |
| 195 | 195 |
| 196 // Gets a dictionary of information about the access point. | 196 // Gets a dictionary of information about the access point. |
| 197 // Returns false if there is an error getting information about the | 197 // Returns false if there is an error getting information about the |
| 198 // supplied |access_point_path|. | 198 // supplied |access_point_path|. |
| 199 bool GetAccessPointInfo( | 199 bool GetAccessPointInfo( |
| 200 const dbus::ObjectPath& access_point_path, | 200 const dbus::ObjectPath& access_point_path, |
| 201 const scoped_ptr<base::DictionaryValue>& access_point_info); | 201 const std::unique_ptr<base::DictionaryValue>& access_point_info); |
| 202 | 202 |
| 203 // Helper function to extract a property from a device. | 203 // Helper function to extract a property from a device. |
| 204 // Returns the dbus::Response object from calling Get on the supplied | 204 // Returns the dbus::Response object from calling Get on the supplied |
| 205 // |property_name|. | 205 // |property_name|. |
| 206 scoped_ptr<dbus::Response> GetAccessPointProperty( | 206 std::unique_ptr<dbus::Response> GetAccessPointProperty( |
| 207 dbus::ObjectProxy* access_point_proxy, | 207 dbus::ObjectProxy* access_point_proxy, |
| 208 const std::string& property_name); | 208 const std::string& property_name); |
| 209 | 209 |
| 210 // If the access_point is not already in the map it is added. Otherwise | 210 // If the access_point is not already in the map it is added. Otherwise |
| 211 // the access point is updated (eg. with the max of the signal | 211 // the access point is updated (eg. with the max of the signal |
| 212 // strength). | 212 // strength). |
| 213 void AddOrUpdateAccessPoint(NetworkMap* network_map, | 213 void AddOrUpdateAccessPoint( |
| 214 const std::string& network_guid, | 214 NetworkMap* network_map, |
| 215 scoped_ptr<base::DictionaryValue>& access_point); | 215 const std::string& network_guid, |
| 216 std::unique_ptr<base::DictionaryValue>& access_point); |
| 216 | 217 |
| 217 // Maps the WPA security flags to a human readable string. | 218 // Maps the WPA security flags to a human readable string. |
| 218 void MapSecurityFlagsToString(uint32_t securityFlags, std::string* security); | 219 void MapSecurityFlagsToString(uint32_t securityFlags, std::string* security); |
| 219 | 220 |
| 220 // Gets the connected access point path on the given device. Internally gets | 221 // Gets the connected access point path on the given device. Internally gets |
| 221 // all active connections then checks if the device matches the requested | 222 // all active connections then checks if the device matches the requested |
| 222 // device, then gets the access point associated with the connection. | 223 // device, then gets the access point associated with the connection. |
| 223 // Returns false if there is an error getting the connected access point. | 224 // Returns false if there is an error getting the connected access point. |
| 224 bool GetConnectedAccessPoint(dbus::ObjectPath device_path, | 225 bool GetConnectedAccessPoint(dbus::ObjectPath device_path, |
| 225 dbus::ObjectPath* access_point_path); | 226 dbus::ObjectPath* access_point_path); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 238 dbus::ObjectPath* access_point_path); | 239 dbus::ObjectPath* access_point_path); |
| 239 | 240 |
| 240 // Helper method to set the connection state in the |network_map_| and post | 241 // Helper method to set the connection state in the |network_map_| and post |
| 241 // a change event. | 242 // a change event. |
| 242 bool SetConnectionStateAndPostEvent(const std::string& guid, | 243 bool SetConnectionStateAndPostEvent(const std::string& guid, |
| 243 const std::string& ssid, | 244 const std::string& ssid, |
| 244 const std::string& connection_state); | 245 const std::string& connection_state); |
| 245 | 246 |
| 246 // Helper method to post an OnNetworkChanged event to the UI thread from the | 247 // Helper method to post an OnNetworkChanged event to the UI thread from the |
| 247 // dbus thread. Used for connection status progress during |StartConnect|. | 248 // dbus thread. Used for connection status progress during |StartConnect|. |
| 248 void PostOnNetworksChangedToUIThread(scoped_ptr<GuidList> guid_list); | 249 void PostOnNetworksChangedToUIThread(std::unique_ptr<GuidList> guid_list); |
| 249 | 250 |
| 250 // Helper method to be called from the UI thread and manage ownership of the | 251 // Helper method to be called from the UI thread and manage ownership of the |
| 251 // passed vector from the |dbus_thread_|. | 252 // passed vector from the |dbus_thread_|. |
| 252 void OnNetworksChangedEventTask(scoped_ptr<GuidList> guid_list); | 253 void OnNetworksChangedEventTask(std::unique_ptr<GuidList> guid_list); |
| 253 | 254 |
| 254 void GetCachedNetworkProperties(const std::string& guid, | 255 void GetCachedNetworkProperties(const std::string& guid, |
| 255 base::DictionaryValue* properties, | 256 base::DictionaryValue* properties, |
| 256 std::string* error); | 257 std::string* error); |
| 257 | 258 |
| 258 void OnNetworksChangedEventOnUIThread(const GuidList& network_guids); | 259 void OnNetworksChangedEventOnUIThread(const GuidList& network_guids); |
| 259 | 260 |
| 260 void OnNetworkListChangedEventOnUIThread(const GuidList& network_guids); | 261 void OnNetworkListChangedEventOnUIThread(const GuidList& network_guids); |
| 261 | 262 |
| 262 // Browser context. | 263 // Browser context. |
| 263 content::BrowserContext* browser_context_; | 264 content::BrowserContext* browser_context_; |
| 264 // Thread used for DBus actions. | 265 // Thread used for DBus actions. |
| 265 base::Thread dbus_thread_; | 266 base::Thread dbus_thread_; |
| 266 // DBus instance. Only access on |dbus_thread_|. | 267 // DBus instance. Only access on |dbus_thread_|. |
| 267 scoped_refptr<dbus::Bus> dbus_; | 268 scoped_refptr<dbus::Bus> dbus_; |
| 268 // Task runner used by the |dbus_| object. | 269 // Task runner used by the |dbus_| object. |
| 269 scoped_refptr<base::SequencedTaskRunner> dbus_task_runner_; | 270 scoped_refptr<base::SequencedTaskRunner> dbus_task_runner_; |
| 270 // This is owned by |dbus_| object. Only access on |dbus_thread_|. | 271 // This is owned by |dbus_| object. Only access on |dbus_thread_|. |
| 271 dbus::ObjectProxy* network_manager_proxy_; | 272 dbus::ObjectProxy* network_manager_proxy_; |
| 272 // Holds the current mapping of known networks. Only access on |dbus_thread_|. | 273 // Holds the current mapping of known networks. Only access on |dbus_thread_|. |
| 273 scoped_ptr<NetworkMap> network_map_; | 274 std::unique_ptr<NetworkMap> network_map_; |
| 274 // Observers to Network Events. | 275 // Observers to Network Events. |
| 275 base::ObserverList<NetworkingPrivateDelegateObserver> | 276 base::ObserverList<NetworkingPrivateDelegateObserver> |
| 276 network_events_observers_; | 277 network_events_observers_; |
| 277 | 278 |
| 278 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateLinux); | 279 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateLinux); |
| 279 }; | 280 }; |
| 280 | 281 |
| 281 } // namespace extensions | 282 } // namespace extensions |
| 282 | 283 |
| 283 #endif // EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_LINUX_H_ | 284 #endif // EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_LINUX_H_ |
| OLD | NEW |