Chromium Code Reviews| 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 CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_ | 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_ |
| 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_ | 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/browser/local_discovery/gcd_api_flow.h" | |
| 13 #include "chrome/browser/local_discovery/privet_http_asynchronous_factory.h" | |
| 12 | 14 |
| 13 namespace local_discovery { | 15 namespace local_discovery { |
| 14 | 16 |
| 15 class ServiceDiscoveryClient; | 17 // Provides complete flow for Privet v3 device setup. |
| 16 | |
| 17 #if defined(ENABLE_WIFI_BOOTSTRAPPING) | |
| 18 namespace wifi { | |
| 19 class WifiManager; | |
| 20 }; | |
| 21 #endif | |
| 22 | |
| 23 class PrivetV3SetupFlow { | 18 class PrivetV3SetupFlow { |
| 24 public: | 19 public: |
| 20 // Delegate to be implemented by client code. | |
| 25 class Delegate { | 21 class Delegate { |
| 26 public: | 22 public: |
| 27 typedef base::Callback<void(bool confirm)> ConfirmationCallback; | 23 typedef base::Callback<void(bool success)> ResultCallback; |
| 28 typedef base::Callback<void(const std::string& key)> CredentialsCallback; | 24 typedef base::Callback<void(const std::string& ssid, |
|
Noam Samuel
2014/06/06 23:14:48
Add comment explaining empty ssid is sentinel valu
Vitaly Buka (NO REVIEWS)
2014/06/06 23:20:31
Done.
| |
| 25 const std::string& key)> CredentialsCallback; | |
| 29 | 26 |
| 30 virtual ~Delegate() {} | 27 virtual ~Delegate(); |
| 31 | 28 |
| 32 #if defined(ENABLE_WIFI_BOOTSTRAPPING) | 29 // Creates |GCDApiFlow| for making requests to GCD server. |
| 33 virtual void OnSetupCredentialsNeeded(const std::string& ssid, | 30 virtual scoped_ptr<GCDApiFlow> CreateApiFlow( |
| 34 const CredentialsCallback& callback); | 31 scoped_ptr<GCDApiFlow::Request> request) = 0; |
| 35 #endif | |
| 36 | 32 |
| 37 virtual void OnSetupConfirmationNeeded( | 33 // Requests WiFi credentials. |
| 38 const std::string& confirmation_code, | 34 virtual void GetWiFiCredentials(const CredentialsCallback& callback) = 0; |
| 39 const ConfirmationCallback& callback) = 0; | |
| 40 | 35 |
| 36 // Switches to setup WiFi network. | |
| 37 // If switch was successfully |RestoreWifi| should be called later. | |
| 38 virtual void SwitchToSetupWiFi(const ResultCallback& callback) = 0; | |
| 39 | |
| 40 // Starts device resolution that should callback with ready | |
| 41 // |PrivetHTTPClient|. | |
| 42 virtual scoped_ptr<PrivetHTTPResolution> CreatePrivetHTTP( | |
| 43 const std::string& device, | |
|
Noam Samuel
2014/06/06 23:14:48
service_name
Vitaly Buka (NO REVIEWS)
2014/06/06 23:20:31
Done.
| |
| 44 const PrivetHTTPAsynchronousFactory::ResultCallback& callback) = 0; | |
| 45 | |
| 46 // Requests client to prompt user to check |confirmation_code|. | |
| 47 virtual void ConfirmSecurityCode(const std::string& confirmation_code, | |
| 48 const ResultCallback& callback) = 0; | |
| 49 | |
| 50 // Restores WiFi network. | |
| 51 virtual void RestoreWifi(const ResultCallback& callback) = 0; | |
| 52 | |
| 53 // Notifies client that device is set up. | |
| 41 virtual void OnSetupDone() = 0; | 54 virtual void OnSetupDone() = 0; |
| 42 | 55 |
| 56 // Notifies client setup failed. | |
| 43 virtual void OnSetupError() = 0; | 57 virtual void OnSetupError() = 0; |
| 44 }; | 58 }; |
| 45 | 59 |
| 46 virtual ~PrivetV3SetupFlow() {} | 60 explicit PrivetV3SetupFlow(Delegate* delegate); |
| 61 ~PrivetV3SetupFlow(); | |
| 47 | 62 |
| 48 static scoped_ptr<PrivetV3SetupFlow> CreateMDnsOnlyFlow( | 63 // Starts registration. |
| 49 ServiceDiscoveryClient* service_discovery_client, | 64 void Register(const std::string& service_name); |
| 50 const std::string& service_name); | |
| 51 | 65 |
| 52 #if defined(ENABLE_WIFI_BOOTSTRAPPING) | 66 #if defined(ENABLE_WIFI_BOOTSTRAPPING) |
| 53 static scoped_ptr<PrivetV3SetupFlow> CreateWifiFlow( | 67 void SetupWifiAndRegister(const std::string& device_ssid); |
| 54 ServiceDiscoveryClient* service_discovery_client, | 68 #endif // ENABLE_WIFI_BOOTSTRAPPING |
| 55 wifi::WifiManager* wifi_manager, | |
| 56 // The SSID of the network whose credentials we will be provisioning. | |
| 57 const std::string& credentials_ssid, | |
| 58 // The SSID of the device we will be provisioning. | |
| 59 const std::string& device_ssid); | |
| 60 #endif | |
| 61 | 69 |
| 62 virtual void Start() = 0; | 70 private: |
| 71 Delegate* delegate_; | |
| 72 std::string service_name_; | |
| 73 base::WeakPtrFactory<PrivetV3SetupFlow> weak_ptr_factory_; | |
| 74 | |
| 75 DISALLOW_COPY_AND_ASSIGN(PrivetV3SetupFlow); | |
| 63 }; | 76 }; |
| 64 | 77 |
| 65 } // namespace local_discovery | 78 } // namespace local_discovery |
| 66 | 79 |
| 67 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_ | 80 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_ |
| OLD | NEW |