Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: extensions/browser/api/networking_private/networking_private_delegate.h

Issue 2751423004: Move NetworkingPrivateDelegate::CryptoVerify to networking_cast_private (Closed)
Patch Set: blocking pool removed Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 16 matching lines...) Expand all
27 using DictionaryCallback = 27 using DictionaryCallback =
28 base::Callback<void(std::unique_ptr<base::DictionaryValue>)>; 28 base::Callback<void(std::unique_ptr<base::DictionaryValue>)>;
29 using VoidCallback = base::Callback<void()>; 29 using VoidCallback = base::Callback<void()>;
30 using BoolCallback = base::Callback<void(bool)>; 30 using BoolCallback = base::Callback<void(bool)>;
31 using StringCallback = base::Callback<void(const std::string&)>; 31 using StringCallback = base::Callback<void(const std::string&)>;
32 using NetworkListCallback = 32 using NetworkListCallback =
33 base::Callback<void(std::unique_ptr<base::ListValue>)>; 33 base::Callback<void(std::unique_ptr<base::ListValue>)>;
34 using FailureCallback = base::Callback<void(const std::string&)>; 34 using FailureCallback = base::Callback<void(const std::string&)>;
35 using DeviceStateList = std::vector< 35 using DeviceStateList = std::vector<
36 std::unique_ptr<api::networking_private::DeviceStateProperties>>; 36 std::unique_ptr<api::networking_private::DeviceStateProperties>>;
37 using VerificationProperties =
38 api::networking_private::VerificationProperties;
39
40 // The Verify* methods will be forwarded to a delegate implementation if
41 // provided, otherwise they will fail. A separate delegate it used so that the
42 // current Verify* implementations are not exposed outside of src/chrome.
43 class VerifyDelegate {
44 public:
45 typedef NetworkingPrivateDelegate::VerificationProperties
46 VerificationProperties;
47 typedef NetworkingPrivateDelegate::BoolCallback BoolCallback;
48 typedef NetworkingPrivateDelegate::StringCallback StringCallback;
49 typedef NetworkingPrivateDelegate::FailureCallback FailureCallback;
50
51 VerifyDelegate();
52 virtual ~VerifyDelegate();
53
54 virtual void VerifyDestination(
55 const VerificationProperties& verification_properties,
56 const BoolCallback& success_callback,
57 const FailureCallback& failure_callback) = 0;
58 virtual void VerifyAndEncryptCredentials(
59 const std::string& guid,
60 const VerificationProperties& verification_properties,
61 const StringCallback& success_callback,
62 const FailureCallback& failure_callback) = 0;
63 virtual void VerifyAndEncryptData(
64 const VerificationProperties& verification_properties,
65 const std::string& data,
66 const StringCallback& success_callback,
67 const FailureCallback& failure_callback) = 0;
68
69 private:
70 DISALLOW_COPY_AND_ASSIGN(VerifyDelegate);
71 };
72 37
73 // Delegate for forwarding UI requests, e.g. for showing the account UI. 38 // Delegate for forwarding UI requests, e.g. for showing the account UI.
74 class UIDelegate { 39 class UIDelegate {
75 public: 40 public:
76 UIDelegate(); 41 UIDelegate();
77 virtual ~UIDelegate(); 42 virtual ~UIDelegate();
78 43
79 // Navigate to the acoount details page for the cellular network associated 44 // Navigate to the acoount details page for the cellular network associated
80 // with |guid|. 45 // with |guid|.
81 virtual void ShowAccountDetails(const std::string& guid) const = 0; 46 virtual void ShowAccountDetails(const std::string& guid) const = 0;
82 47
83 // Possibly handle a connection failure, e.g. by showing the configuration 48 // Possibly handle a connection failure, e.g. by showing the configuration
84 // UI. Returns true if the error was handled, i.e. the UI was shown. 49 // UI. Returns true if the error was handled, i.e. the UI was shown.
85 virtual bool HandleConnectFailed(const std::string& guid, 50 virtual bool HandleConnectFailed(const std::string& guid,
86 const std::string error) const = 0; 51 const std::string error) const = 0;
87 52
88 private: 53 private:
89 DISALLOW_COPY_AND_ASSIGN(UIDelegate); 54 DISALLOW_COPY_AND_ASSIGN(UIDelegate);
90 }; 55 };
91 56
92 // If |verify_delegate| is not NULL, the Verify* methods will be forwarded 57 NetworkingPrivateDelegate();
93 // to the delegate. Otherwise they will fail with a NotSupported error.
94 explicit NetworkingPrivateDelegate(
95 std::unique_ptr<VerifyDelegate> verify_delegate);
96 ~NetworkingPrivateDelegate() override; 58 ~NetworkingPrivateDelegate() override;
97 59
98 void set_ui_delegate(std::unique_ptr<UIDelegate> ui_delegate) { 60 void set_ui_delegate(std::unique_ptr<UIDelegate> ui_delegate) {
99 ui_delegate_ = std::move(ui_delegate); 61 ui_delegate_ = std::move(ui_delegate);
100 } 62 }
101 63
102 const UIDelegate* ui_delegate() { return ui_delegate_.get(); } 64 const UIDelegate* ui_delegate() { return ui_delegate_.get(); }
103 65
104 // Asynchronous methods 66 // Asynchronous methods
105 virtual void GetProperties(const std::string& guid, 67 virtual void GetProperties(const std::string& guid,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 148
187 // Returns true if a scan was requested. It may take many seconds for a scan 149 // Returns true if a scan was requested. It may take many seconds for a scan
188 // to complete. The scan may or may not trigger API events when complete. 150 // to complete. The scan may or may not trigger API events when complete.
189 virtual bool RequestScan() = 0; 151 virtual bool RequestScan() = 0;
190 152
191 // Optional methods for adding a NetworkingPrivateDelegateObserver for 153 // Optional methods for adding a NetworkingPrivateDelegateObserver for
192 // implementations that require it (non-chromeos). 154 // implementations that require it (non-chromeos).
193 virtual void AddObserver(NetworkingPrivateDelegateObserver* observer); 155 virtual void AddObserver(NetworkingPrivateDelegateObserver* observer);
194 virtual void RemoveObserver(NetworkingPrivateDelegateObserver* observer); 156 virtual void RemoveObserver(NetworkingPrivateDelegateObserver* observer);
195 157
196 // Verify* methods are forwarded to |verify_delegate_| if not NULL.
197 void VerifyDestination(const VerificationProperties& verification_properties,
198 const BoolCallback& success_callback,
199 const FailureCallback& failure_callback);
200 void VerifyAndEncryptCredentials(
201 const std::string& guid,
202 const VerificationProperties& verification_properties,
203 const StringCallback& success_callback,
204 const FailureCallback& failure_callback);
205 void VerifyAndEncryptData(
206 const VerificationProperties& verification_properties,
207 const std::string& data,
208 const StringCallback& success_callback,
209 const FailureCallback& failure_callback);
210
211 private: 158 private:
212 // Interface for Verify* methods. May be null.
213 std::unique_ptr<VerifyDelegate> verify_delegate_;
214
215 // Interface for UI methods. May be null. 159 // Interface for UI methods. May be null.
216 std::unique_ptr<UIDelegate> ui_delegate_; 160 std::unique_ptr<UIDelegate> ui_delegate_;
217 161
218 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateDelegate); 162 DISALLOW_COPY_AND_ASSIGN(NetworkingPrivateDelegate);
219 }; 163 };
220 164
221 } // namespace extensions 165 } // namespace extensions
222 166
223 #endif // EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_DELEGATE _H_ 167 #endif // EXTENSIONS_BROWSER_API_NETWORKING_PRIVATE_NETWORKING_PRIVATE_DELEGATE _H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698