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" | 12 #include "chrome/browser/local_discovery/gcd_api_flow.h" |
13 #include "chrome/browser/local_discovery/privet_http.h" | 13 #include "chrome/browser/local_discovery/privet_http.h" |
14 #include "chrome/browser/local_discovery/privetv3_session.h" | |
14 | 15 |
15 namespace local_discovery { | 16 namespace local_discovery { |
16 | 17 |
17 // Provides complete flow for Privet v3 device setup. | 18 // Provides complete flow for Privet v3 device setup. |
18 class PrivetV3SetupFlow { | 19 class PrivetV3SetupFlow : public PrivetV3Session::Delegate { |
Noam Samuel
2014/07/16 20:48:23
Is this class still needed?
Vitaly Buka (NO REVIEWS)
2014/07/16 20:53:23
I guess we could finish this for chrome://devices
| |
19 public: | 20 public: |
20 // Delegate to be implemented by client code. | 21 // Delegate to be implemented by client code. |
21 class Delegate { | 22 class Delegate { |
22 public: | 23 public: |
23 typedef base::Callback<void(bool success)> ResultCallback; | 24 typedef base::Callback<void(bool success)> ResultCallback; |
24 // If |ssid| is empty, call failed to get credentials. | 25 // If |ssid| is empty, call failed to get credentials. |
25 // If |key| is empty, network is open. | 26 // If |key| is empty, network is open. |
26 typedef base::Callback<void(const std::string& ssid, | 27 typedef base::Callback<void(const std::string& ssid, |
27 const std::string& key)> CredentialsCallback; | 28 const std::string& key)> CredentialsCallback; |
28 | 29 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 explicit PrivetV3SetupFlow(Delegate* delegate); | 64 explicit PrivetV3SetupFlow(Delegate* delegate); |
64 ~PrivetV3SetupFlow(); | 65 ~PrivetV3SetupFlow(); |
65 | 66 |
66 // Starts registration. | 67 // Starts registration. |
67 void Register(const std::string& service_name); | 68 void Register(const std::string& service_name); |
68 | 69 |
69 #if defined(ENABLE_WIFI_BOOTSTRAPPING) | 70 #if defined(ENABLE_WIFI_BOOTSTRAPPING) |
70 void SetupWifiAndRegister(const std::string& device_ssid); | 71 void SetupWifiAndRegister(const std::string& device_ssid); |
71 #endif // ENABLE_WIFI_BOOTSTRAPPING | 72 #endif // ENABLE_WIFI_BOOTSTRAPPING |
72 | 73 |
74 // PrivetV3Session::Delegate implementation. | |
75 virtual void OnSetupConfirmationNeeded( | |
76 const std::string& confirmation_code) OVERRIDE; | |
77 virtual void OnSessionEstablished() OVERRIDE; | |
78 virtual void OnCannotEstablishSession() OVERRIDE; | |
79 | |
80 void OnSetupError(); | |
81 void OnDeviceRegistered(); | |
82 | |
73 private: | 83 private: |
84 void OnTicketCreated(const std::string& ticket_id); | |
85 void OnPrivetClientCreated(scoped_ptr<PrivetHTTPClient> privet_http_client); | |
86 void OnCodeConfirmed(bool success); | |
87 | |
74 Delegate* delegate_; | 88 Delegate* delegate_; |
75 std::string service_name_; | 89 std::string service_name_; |
90 scoped_ptr<GCDApiFlow> ticket_request_; | |
91 scoped_ptr<PrivetV3Session> session_; | |
92 scoped_ptr<PrivetV3Session::Request> setup_request_; | |
76 base::WeakPtrFactory<PrivetV3SetupFlow> weak_ptr_factory_; | 93 base::WeakPtrFactory<PrivetV3SetupFlow> weak_ptr_factory_; |
77 | 94 |
78 DISALLOW_COPY_AND_ASSIGN(PrivetV3SetupFlow); | 95 DISALLOW_COPY_AND_ASSIGN(PrivetV3SetupFlow); |
79 }; | 96 }; |
80 | 97 |
81 } // namespace local_discovery | 98 } // namespace local_discovery |
82 | 99 |
83 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_ | 100 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_ |
OLD | NEW |