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

Side by Side Diff: chrome/browser/local_discovery/privetv3_setup_flow.h

Issue 323563006: Updated PrivetV3SetupFlow API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fri 06/06/2014 16:20:01.01 Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/local_discovery/privetv3_setup_flow.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 // If |ssid| is empty, call failed to get credentials.
25 // If |key| is empty, network is open.
26 typedef base::Callback<void(const std::string& ssid,
27 const std::string& key)> CredentialsCallback;
29 28
30 virtual ~Delegate() {} 29 virtual ~Delegate();
31 30
32 #if defined(ENABLE_WIFI_BOOTSTRAPPING) 31 // Creates |GCDApiFlow| for making requests to GCD server.
33 virtual void OnSetupCredentialsNeeded(const std::string& ssid, 32 virtual scoped_ptr<GCDApiFlow> CreateApiFlow(
34 const CredentialsCallback& callback); 33 scoped_ptr<GCDApiFlow::Request> request) = 0;
35 #endif
36 34
37 virtual void OnSetupConfirmationNeeded( 35 // Requests WiFi credentials.
38 const std::string& confirmation_code, 36 virtual void GetWiFiCredentials(const CredentialsCallback& callback) = 0;
39 const ConfirmationCallback& callback) = 0;
40 37
38 // Switches to setup WiFi network.
39 // If switch was successfully |RestoreWifi| should be called later.
40 virtual void SwitchToSetupWiFi(const ResultCallback& callback) = 0;
41
42 // Starts device resolution that should callback with ready
43 // |PrivetHTTPClient|.
44 virtual scoped_ptr<PrivetHTTPResolution> CreatePrivetHTTP(
45 const std::string& service_name,
46 const PrivetHTTPAsynchronousFactory::ResultCallback& callback) = 0;
47
48 // Requests client to prompt user to check |confirmation_code|.
49 virtual void ConfirmSecurityCode(const std::string& confirmation_code,
50 const ResultCallback& callback) = 0;
51
52 // Restores WiFi network.
53 virtual void RestoreWifi(const ResultCallback& callback) = 0;
54
55 // Notifies client that device is set up.
41 virtual void OnSetupDone() = 0; 56 virtual void OnSetupDone() = 0;
42 57
58 // Notifies client setup failed.
43 virtual void OnSetupError() = 0; 59 virtual void OnSetupError() = 0;
44 }; 60 };
45 61
46 virtual ~PrivetV3SetupFlow() {} 62 explicit PrivetV3SetupFlow(Delegate* delegate);
63 ~PrivetV3SetupFlow();
47 64
48 static scoped_ptr<PrivetV3SetupFlow> CreateMDnsOnlyFlow( 65 // Starts registration.
49 ServiceDiscoveryClient* service_discovery_client, 66 void Register(const std::string& service_name);
50 const std::string& service_name);
51 67
52 #if defined(ENABLE_WIFI_BOOTSTRAPPING) 68 #if defined(ENABLE_WIFI_BOOTSTRAPPING)
53 static scoped_ptr<PrivetV3SetupFlow> CreateWifiFlow( 69 void SetupWifiAndRegister(const std::string& device_ssid);
54 ServiceDiscoveryClient* service_discovery_client, 70 #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 71
62 virtual void Start() = 0; 72 private:
73 Delegate* delegate_;
74 std::string service_name_;
75 base::WeakPtrFactory<PrivetV3SetupFlow> weak_ptr_factory_;
76
77 DISALLOW_COPY_AND_ASSIGN(PrivetV3SetupFlow);
63 }; 78 };
64 79
65 } // namespace local_discovery 80 } // namespace local_discovery
66 81
67 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_ 82 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SETUP_FLOW_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/local_discovery/privetv3_setup_flow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698