| 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_DELEGATE_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_DELEGATE_H_ |
| 6 #define EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_DELEGATE_H_ | 6 #define EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/callback.h" | 12 #include "base/callback.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "components/keyed_service/core/keyed_service.h" | 16 #include "components/keyed_service/core/keyed_service.h" |
| 17 #include "extensions/common/api/networking_private.h" | 17 #include "extensions/common/api/networking_private.h" |
| 18 | 18 |
| 19 namespace extensions { | 19 namespace extensions { |
| 20 | 20 |
| 21 class NetworkingPrivateDelegateObserver; | 21 class NetworkingPrivateDelegateObserver; |
| 22 | 22 |
| 23 namespace api { | 23 namespace api { |
| 24 namespace networking_private { | 24 namespace networking_private { |
| 25 struct DeviceStateProperties; | 25 struct DeviceStateProperties; |
| 26 struct VerificationProperties; | 26 struct VerificationProperties; |
| 27 } // networking_private | 27 } // networking_private |
| 28 } // api | 28 } // api |
| 29 | 29 |
| 30 // Base class for platform dependent networkingPrivate API implementations. | 30 // Base class for platform dependent networkingPrivate API implementations. |
| 31 // All inputs and results for this class use ONC values. See | 31 // All inputs and results for this class use ONC values. See |
| 32 // networking_private.idl for descriptions of the expected inputs and results. | 32 // networking_private.idl for descriptions of the expected inputs and results. |
| 33 class NetworkingPrivateDelegate : public KeyedService { | 33 class NetworkingPrivateDelegate : public KeyedService { |
| 34 public: | 34 public: |
| 35 using DictionaryCallback = | 35 using DictionaryCallback = |
| 36 base::Callback<void(scoped_ptr<base::DictionaryValue>)>; | 36 base::Callback<void(std::unique_ptr<base::DictionaryValue>)>; |
| 37 using VoidCallback = base::Callback<void()>; | 37 using VoidCallback = base::Callback<void()>; |
| 38 using BoolCallback = base::Callback<void(bool)>; | 38 using BoolCallback = base::Callback<void(bool)>; |
| 39 using StringCallback = base::Callback<void(const std::string&)>; | 39 using StringCallback = base::Callback<void(const std::string&)>; |
| 40 using NetworkListCallback = base::Callback<void(scoped_ptr<base::ListValue>)>; | 40 using NetworkListCallback = |
| 41 base::Callback<void(std::unique_ptr<base::ListValue>)>; |
| 41 using FailureCallback = base::Callback<void(const std::string&)>; | 42 using FailureCallback = base::Callback<void(const std::string&)>; |
| 42 using DeviceStateList = | 43 using DeviceStateList = std::vector< |
| 43 std::vector<scoped_ptr<api::networking_private::DeviceStateProperties>>; | 44 std::unique_ptr<api::networking_private::DeviceStateProperties>>; |
| 44 using VerificationProperties = | 45 using VerificationProperties = |
| 45 api::networking_private::VerificationProperties; | 46 api::networking_private::VerificationProperties; |
| 46 | 47 |
| 47 // The Verify* methods will be forwarded to a delegate implementation if | 48 // The Verify* methods will be forwarded to a delegate implementation if |
| 48 // provided, otherwise they will fail. A separate delegate it used so that the | 49 // provided, otherwise they will fail. A separate delegate it used so that the |
| 49 // current Verify* implementations are not exposed outside of src/chrome. | 50 // current Verify* implementations are not exposed outside of src/chrome. |
| 50 class VerifyDelegate { | 51 class VerifyDelegate { |
| 51 public: | 52 public: |
| 52 typedef NetworkingPrivateDelegate::VerificationProperties | 53 typedef NetworkingPrivateDelegate::VerificationProperties |
| 53 VerificationProperties; | 54 VerificationProperties; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 virtual bool HandleConnectFailed(const std::string& guid, | 93 virtual bool HandleConnectFailed(const std::string& guid, |
| 93 const std::string error) const = 0; | 94 const std::string error) const = 0; |
| 94 | 95 |
| 95 private: | 96 private: |
| 96 DISALLOW_COPY_AND_ASSIGN(UIDelegate); | 97 DISALLOW_COPY_AND_ASSIGN(UIDelegate); |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 // If |verify_delegate| is not NULL, the Verify* methods will be forwarded | 100 // If |verify_delegate| is not NULL, the Verify* methods will be forwarded |
| 100 // to the delegate. Otherwise they will fail with a NotSupported error. | 101 // to the delegate. Otherwise they will fail with a NotSupported error. |
| 101 explicit NetworkingPrivateDelegate( | 102 explicit NetworkingPrivateDelegate( |
| 102 scoped_ptr<VerifyDelegate> verify_delegate); | 103 std::unique_ptr<VerifyDelegate> verify_delegate); |
| 103 ~NetworkingPrivateDelegate() override; | 104 ~NetworkingPrivateDelegate() override; |
| 104 | 105 |
| 105 void set_ui_delegate(scoped_ptr<UIDelegate> ui_delegate) { | 106 void set_ui_delegate(std::unique_ptr<UIDelegate> ui_delegate) { |
| 106 ui_delegate_.reset(ui_delegate.release()); | 107 ui_delegate_.reset(ui_delegate.release()); |
| 107 } | 108 } |
| 108 | 109 |
| 109 const UIDelegate* ui_delegate() { return ui_delegate_.get(); } | 110 const UIDelegate* ui_delegate() { return ui_delegate_.get(); } |
| 110 | 111 |
| 111 // Asynchronous methods | 112 // Asynchronous methods |
| 112 virtual void GetProperties(const std::string& guid, | 113 virtual void GetProperties(const std::string& guid, |
| 113 const DictionaryCallback& success_callback, | 114 const DictionaryCallback& success_callback, |
| 114 const FailureCallback& failure_callback) = 0; | 115 const FailureCallback& failure_callback) = 0; |
| 115 virtual void GetManagedProperties( | 116 virtual void GetManagedProperties( |
| 116 const std::string& guid, | 117 const std::string& guid, |
| 117 const DictionaryCallback& success_callback, | 118 const DictionaryCallback& success_callback, |
| 118 const FailureCallback& failure_callback) = 0; | 119 const FailureCallback& failure_callback) = 0; |
| 119 virtual void GetState(const std::string& guid, | 120 virtual void GetState(const std::string& guid, |
| 120 const DictionaryCallback& success_callback, | 121 const DictionaryCallback& success_callback, |
| 121 const FailureCallback& failure_callback) = 0; | 122 const FailureCallback& failure_callback) = 0; |
| 122 virtual void SetProperties(const std::string& guid, | 123 virtual void SetProperties(const std::string& guid, |
| 123 scoped_ptr<base::DictionaryValue> properties, | 124 std::unique_ptr<base::DictionaryValue> properties, |
| 124 const VoidCallback& success_callback, | 125 const VoidCallback& success_callback, |
| 125 const FailureCallback& failure_callback) = 0; | 126 const FailureCallback& failure_callback) = 0; |
| 126 virtual void CreateNetwork(bool shared, | 127 virtual void CreateNetwork(bool shared, |
| 127 scoped_ptr<base::DictionaryValue> properties, | 128 std::unique_ptr<base::DictionaryValue> properties, |
| 128 const StringCallback& success_callback, | 129 const StringCallback& success_callback, |
| 129 const FailureCallback& failure_callback) = 0; | 130 const FailureCallback& failure_callback) = 0; |
| 130 virtual void ForgetNetwork(const std::string& guid, | 131 virtual void ForgetNetwork(const std::string& guid, |
| 131 const VoidCallback& success_callback, | 132 const VoidCallback& success_callback, |
| 132 const FailureCallback& failure_callback) = 0; | 133 const FailureCallback& failure_callback) = 0; |
| 133 virtual void GetNetworks(const std::string& network_type, | 134 virtual void GetNetworks(const std::string& network_type, |
| 134 bool configured_only, | 135 bool configured_only, |
| 135 bool visible_only, | 136 bool visible_only, |
| 136 int limit, | 137 int limit, |
| 137 const NetworkListCallback& success_callback, | 138 const NetworkListCallback& success_callback, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 167 virtual void SetCellularSimState(const std::string& guid, | 168 virtual void SetCellularSimState(const std::string& guid, |
| 168 bool require_pin, | 169 bool require_pin, |
| 169 const std::string& current_pin, | 170 const std::string& current_pin, |
| 170 const std::string& new_pin, | 171 const std::string& new_pin, |
| 171 const VoidCallback& success_callback, | 172 const VoidCallback& success_callback, |
| 172 const FailureCallback& failure_callback) = 0; | 173 const FailureCallback& failure_callback) = 0; |
| 173 | 174 |
| 174 // Synchronous methods | 175 // Synchronous methods |
| 175 | 176 |
| 176 // Returns a list of ONC type strings. | 177 // Returns a list of ONC type strings. |
| 177 virtual scoped_ptr<base::ListValue> GetEnabledNetworkTypes() = 0; | 178 virtual std::unique_ptr<base::ListValue> GetEnabledNetworkTypes() = 0; |
| 178 | 179 |
| 179 // Returns a list of DeviceStateProperties. | 180 // Returns a list of DeviceStateProperties. |
| 180 virtual scoped_ptr<DeviceStateList> GetDeviceStateList() = 0; | 181 virtual std::unique_ptr<DeviceStateList> GetDeviceStateList() = 0; |
| 181 | 182 |
| 182 // Returns true if the ONC network type |type| is enabled. | 183 // Returns true if the ONC network type |type| is enabled. |
| 183 virtual bool EnableNetworkType(const std::string& type) = 0; | 184 virtual bool EnableNetworkType(const std::string& type) = 0; |
| 184 | 185 |
| 185 // Returns true if the ONC network type |type| is disabled. | 186 // Returns true if the ONC network type |type| is disabled. |
| 186 virtual bool DisableNetworkType(const std::string& type) = 0; | 187 virtual bool DisableNetworkType(const std::string& type) = 0; |
| 187 | 188 |
| 188 // Returns true if a scan was requested. It may take many seconds for a scan | 189 // Returns true if a scan was requested. It may take many seconds for a scan |
| 189 // to complete. The scan may or may not trigger API events when complete. | 190 // to complete. The scan may or may not trigger API events when complete. |
| 190 virtual bool RequestScan() = 0; | 191 virtual bool RequestScan() = 0; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 204 const StringCallback& success_callback, | 205 const StringCallback& success_callback, |
| 205 const FailureCallback& failure_callback); | 206 const FailureCallback& failure_callback); |
| 206 void VerifyAndEncryptData( | 207 void VerifyAndEncryptData( |
| 207 const VerificationProperties& verification_properties, | 208 const VerificationProperties& verification_properties, |
| 208 const std::string& data, | 209 const std::string& data, |
| 209 const StringCallback& success_callback, | 210 const StringCallback& success_callback, |
| 210 const FailureCallback& failure_callback); | 211 const FailureCallback& failure_callback); |
| 211 | 212 |
| 212 private: | 213 private: |
| 213 // Interface for Verify* methods. May be null. | 214 // Interface for Verify* methods. May be null. |
| 214 scoped_ptr<VerifyDelegate> verify_delegate_; | 215 std::unique_ptr<VerifyDelegate> verify_delegate_; |
| 215 | 216 |
| 216 // Interface for UI methods. May be null. | 217 // Interface for UI methods. May be null. |
| 217 scoped_ptr<UIDelegate> ui_delegate_; | 218 std::unique_ptr<UIDelegate> ui_delegate_; |
| 218 | 219 |
| 219 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateDelegate); | 220 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateDelegate); |
| 220 }; | 221 }; |
| 221 | 222 |
| 222 } // namespace extensions | 223 } // namespace extensions |
| 223 | 224 |
| 224 #endif // EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_DELEGATE
_H_ | 225 #endif // EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_DELEGATE
_H_ |
| OLD | NEW |