#include "base/memory/scoped_ptr.h"
#include "chrome/browser/local_discovery/gcd_api_flow.h"
#include "chrome/browser/local_discovery/privet_http.h"
+#include "chrome/browser/local_discovery/privetv3_session.h"
namespace local_discovery {
// Provides complete flow for Privet v3 device setup.
-class PrivetV3SetupFlow {
+class PrivetV3SetupFlow : public PrivetV3Session::Delegate {
public:
// Delegate to be implemented by client code.
class Delegate {
typedef base::Callback<void(const std::string& ssid,
const std::string& key)> CredentialsCallback;
- typedef base::Callback<void(scoped_ptr<PrivetV3HTTPClient>)>
+ typedef base::Callback<void(scoped_ptr<PrivetHTTPClient>)>
PrivetClientCallback;
virtual ~Delegate();
};
explicit PrivetV3SetupFlow(Delegate* delegate);
- ~PrivetV3SetupFlow();
+ virtual ~PrivetV3SetupFlow();
// Starts registration.
void Register(const std::string& service_name);
void SetupWifiAndRegister(const std::string& device_ssid);
#endif // ENABLE_WIFI_BOOTSTRAPPING
+ // PrivetV3Session::Delegate implementation.
+ virtual void OnSetupConfirmationNeeded(
+ const std::string& confirmation_code,
+ extensions::api::gcd_private::ConfirmationType confirmation_type)
+ OVERRIDE;
+ virtual void OnSessionStatus(
+ extensions::api::gcd_private::Status status) OVERRIDE;
+
+ void OnSetupError();
+ void OnDeviceRegistered();
+
+ const std::string& service_name() const { return service_name_; }
+
private:
+ void OnTicketCreated(const std::string& ticket_id,
+ const std::string& device_id);
+ void OnPrivetClientCreated(scoped_ptr<PrivetHTTPClient> privet_http_client);
+ void OnCodeConfirmed(const std::string& code, bool success);
+
Delegate* delegate_;
std::string service_name_;
+ std::string device_id_;
+ scoped_ptr<GCDApiFlow> ticket_request_;
+ scoped_ptr<PrivetV3Session> session_;
+ scoped_ptr<PrivetV3Session::Request> setup_request_;
base::WeakPtrFactory<PrivetV3SetupFlow> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PrivetV3SetupFlow);