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

Side by Side Diff: chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h

Issue 873103002: Removed unused native code related to wifi bootstrapping. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sun 01/25/2015 21:44:58.31 Created 5 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/cancelable_callback.h"
13 #include "base/prefs/pref_member.h"
14 #include "chrome/browser/local_discovery/cloud_device_list.h"
15 #include "chrome/browser/local_discovery/cloud_print_printer_list.h" 12 #include "chrome/browser/local_discovery/cloud_print_printer_list.h"
16 #include "chrome/browser/local_discovery/privet_device_lister.h" 13 #include "chrome/browser/local_discovery/privet_device_lister.h"
17 #include "chrome/browser/local_discovery/privet_http.h" 14 #include "chrome/browser/local_discovery/privet_http.h"
18 #include "chrome/browser/local_discovery/privetv3_setup_flow.h"
19 #include "components/signin/core/browser/signin_manager.h" 15 #include "components/signin/core/browser/signin_manager.h"
20 #include "content/public/browser/web_ui_message_handler.h" 16 #include "content/public/browser/web_ui_message_handler.h"
21 17
22 #if defined(ENABLE_PRINT_PREVIEW) && !defined(OS_CHROMEOS) 18 #if defined(ENABLE_PRINT_PREVIEW) && !defined(OS_CHROMEOS)
23 #define CLOUD_PRINT_CONNECTOR_UI_AVAILABLE 19 #define CLOUD_PRINT_CONNECTOR_UI_AVAILABLE
24 #endif 20 #endif
25 21
26 #if defined(ENABLE_WIFI_BOOTSTRAPPING)
27 #include "chrome/browser/local_discovery/wifi/bootstrapping_device_lister.h"
28 #include "chrome/browser/local_discovery/wifi/wifi_manager.h"
29 #endif
30
31 // TODO(noamsml): Factor out full registration flow into single class 22 // TODO(noamsml): Factor out full registration flow into single class
32 namespace local_discovery { 23 namespace local_discovery {
33 24
34 class PrivetConfirmApiCallFlow; 25 class PrivetConfirmApiCallFlow;
35 class PrivetHTTPAsynchronousFactory; 26 class PrivetHTTPAsynchronousFactory;
36 class PrivetHTTPResolution; 27 class PrivetHTTPResolution;
37 class PrivetV1HTTPClient; 28 class PrivetV1HTTPClient;
38 class ServiceDiscoverySharedClient; 29 class ServiceDiscoverySharedClient;
39 30
40 // UI Handler for chrome://devices/ 31 // UI Handler for chrome://devices/
41 // It listens to local discovery notifications and passes those notifications 32 // It listens to local discovery notifications and passes those notifications
42 // into the Javascript to update the page. 33 // into the Javascript to update the page.
43 class LocalDiscoveryUIHandler : public content::WebUIMessageHandler, 34 class LocalDiscoveryUIHandler : public content::WebUIMessageHandler,
44 public PrivetRegisterOperation::Delegate, 35 public PrivetRegisterOperation::Delegate,
45 public PrivetV3SetupFlow::Delegate,
46 public PrivetDeviceLister::Delegate, 36 public PrivetDeviceLister::Delegate,
47 public CloudDeviceListDelegate, 37 public CloudDeviceListDelegate,
48 public SigninManagerBase::Observer { 38 public SigninManagerBase::Observer {
49 public: 39 public:
50 LocalDiscoveryUIHandler(); 40 LocalDiscoveryUIHandler();
51 ~LocalDiscoveryUIHandler() override; 41 ~LocalDiscoveryUIHandler() override;
52 42
53 static bool GetHasVisible(); 43 static bool GetHasVisible();
54 44
55 // WebUIMessageHandler implementation. 45 // WebUIMessageHandler implementation.
56 void RegisterMessages() override; 46 void RegisterMessages() override;
57 // PrivetRegisterOperation::Delegate implementation. 47 // PrivetRegisterOperation::Delegate implementation.
58 void OnPrivetRegisterClaimToken(PrivetRegisterOperation* operation, 48 void OnPrivetRegisterClaimToken(PrivetRegisterOperation* operation,
59 const std::string& token, 49 const std::string& token,
60 const GURL& url) override; 50 const GURL& url) override;
61 void OnPrivetRegisterError(PrivetRegisterOperation* operation, 51 void OnPrivetRegisterError(PrivetRegisterOperation* operation,
62 const std::string& action, 52 const std::string& action,
63 PrivetRegisterOperation::FailureReason reason, 53 PrivetRegisterOperation::FailureReason reason,
64 int printer_http_code, 54 int printer_http_code,
65 const base::DictionaryValue* json) override; 55 const base::DictionaryValue* json) override;
66 void OnPrivetRegisterDone(PrivetRegisterOperation* operation, 56 void OnPrivetRegisterDone(PrivetRegisterOperation* operation,
67 const std::string& device_id) override; 57 const std::string& device_id) override;
68 58
69 // PrivetV3SetupFlow::Delegate implementation.
70 scoped_ptr<GCDApiFlow> CreateApiFlow() override;
71 void GetWiFiCredentials(const CredentialsCallback& callback) override;
72 void SwitchToSetupWiFi(const ResultCallback& callback) override;
73 void CreatePrivetV3Client(const std::string& service_name,
74 const PrivetClientCallback& callback) override;
75 void ConfirmSecurityCode(const ResultCallback& callback) override;
76 void RestoreWifi(const ResultCallback& callback) override;
77 void OnSetupDone() override;
78 void OnSetupError() override;
79
80 // PrivetDeviceLister::Delegate implementation. 59 // PrivetDeviceLister::Delegate implementation.
81 void DeviceChanged(bool added, 60 void DeviceChanged(bool added,
82 const std::string& name, 61 const std::string& name,
83 const DeviceDescription& description) override; 62 const DeviceDescription& description) override;
84 void DeviceRemoved(const std::string& name) override; 63 void DeviceRemoved(const std::string& name) override;
85 void DeviceCacheFlushed() override; 64 void DeviceCacheFlushed() override;
86 65
87 // CloudDeviceListDelegate implementation. 66 // CloudDeviceListDelegate implementation.
88 void OnDeviceListReady(const std::vector<Device>& devices) override; 67 void OnDeviceListReady(const std::vector<Device>& devices) override;
89 void OnDeviceListUnavailable() override; 68 void OnDeviceListUnavailable() override;
90 69
91 // SigninManagerBase::Observer implementation. 70 // SigninManagerBase::Observer implementation.
92 void GoogleSigninSucceeded(const std::string& account_id, 71 void GoogleSigninSucceeded(const std::string& account_id,
93 const std::string& username, 72 const std::string& username,
94 const std::string& password) override; 73 const std::string& password) override;
95 void GoogleSignedOut(const std::string& account_id, 74 void GoogleSignedOut(const std::string& account_id,
96 const std::string& username) override; 75 const std::string& username) override;
97 76
98 private: 77 private:
99 typedef std::map<std::string, DeviceDescription> DeviceDescriptionMap; 78 typedef std::map<std::string, DeviceDescription> DeviceDescriptionMap;
79 typedef base::Callback<void(bool result)> ResultCallback;
100 80
101 // Message handlers: 81 // Message handlers:
102 // For when the page is ready to receive device notifications. 82 // For when the page is ready to receive device notifications.
103 void HandleStart(const base::ListValue* args); 83 void HandleStart(const base::ListValue* args);
104 84
105 // For when a visibility change occurs. 85 // For when a visibility change occurs.
106 void HandleIsVisible(const base::ListValue* args); 86 void HandleIsVisible(const base::ListValue* args);
107 87
108 // For when a user choice is made. 88 // For when a user choice is made.
109 void HandleRegisterDevice(const base::ListValue* args); 89 void HandleRegisterDevice(const base::ListValue* args);
110 90
111 // For when a code is confirmed.
112 void HandleConfirmCode(const base::ListValue* args);
113
114 // For when a cancellation is made. 91 // For when a cancellation is made.
115 void HandleCancelRegistration(const base::ListValue* args); 92 void HandleCancelRegistration(const base::ListValue* args);
116 93
117 // For requesting the device list. 94 // For requesting the device list.
118 void HandleRequestDeviceList(const base::ListValue* args); 95 void HandleRequestDeviceList(const base::ListValue* args);
119 96
120 // For opening URLs (relative to the Google Cloud Print base URL) in a new 97 // For opening URLs (relative to the Google Cloud Print base URL) in a new
121 // tab. 98 // tab.
122 void HandleOpenCloudPrintURL(const base::ListValue* args); 99 void HandleOpenCloudPrintURL(const base::ListValue* args);
123 100
(...skipping 15 matching lines...) Expand all
139 116
140 // Set the visibility of the page. 117 // Set the visibility of the page.
141 void SetIsVisible(bool visible); 118 void SetIsVisible(bool visible);
142 119
143 // Get the sync account email. 120 // Get the sync account email.
144 std::string GetSyncAccount(); 121 std::string GetSyncAccount();
145 122
146 // Reset and cancel the current registration. 123 // Reset and cancel the current registration.
147 void ResetCurrentRegistration(); 124 void ResetCurrentRegistration();
148 125
149 // Creates |PrivetV3HTTPClient| privet from |PrivetHTTPClient| and calls 126 scoped_ptr<GCDApiFlow> CreateApiFlow();
150 // callback. 127 void OnSetupError();
151 void PrivetClientToV3(const PrivetClientCallback& callback,
152 scoped_ptr<PrivetHTTPClient> client);
153 128
154 // Announcement hasn't been sent for a certain time after registration 129 // Announcement hasn't been sent for a certain time after registration
155 // finished. Consider it failed. 130 // finished. Consider it failed.
156 // TODO(noamsml): Re-resolve service first. 131 // TODO(noamsml): Re-resolve service first.
157 void OnAnnouncementTimeoutReached(); 132 void OnAnnouncementTimeoutReached();
158 133
159 void CheckUserLoggedIn(); 134 void CheckUserLoggedIn();
160 135
161 void CheckListingDone(); 136 void CheckListingDone();
162 137
163 bool IsUserSupervisedOrOffTheRecord(); 138 bool IsUserSupervisedOrOffTheRecord();
164 139
165 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) 140 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE)
166 void StartCloudPrintConnector(); 141 void StartCloudPrintConnector();
167 void OnCloudPrintPrefsChanged(); 142 void OnCloudPrintPrefsChanged();
168 void ShowCloudPrintSetupDialog(const base::ListValue* args); 143 void ShowCloudPrintSetupDialog(const base::ListValue* args);
169 void HandleDisableCloudPrintConnector(const base::ListValue* args); 144 void HandleDisableCloudPrintConnector(const base::ListValue* args);
170 void SetupCloudPrintConnectorSection(); 145 void SetupCloudPrintConnectorSection();
171 void RemoveCloudPrintConnectorSection(); 146 void RemoveCloudPrintConnectorSection();
172 void RefreshCloudPrintStatusFromService(); 147 void RefreshCloudPrintStatusFromService();
173 #endif 148 #endif
174 149
175 #if defined(ENABLE_WIFI_BOOTSTRAPPING)
176 void StartWifiBootstrapping();
177 void OnBootstrappingDeviceChanged(
178 bool available,
179 const wifi::BootstrappingDeviceDescription& description);
180 #endif
181
182 // A map of current device descriptions provided by the PrivetDeviceLister. 150 // A map of current device descriptions provided by the PrivetDeviceLister.
183 DeviceDescriptionMap device_descriptions_; 151 DeviceDescriptionMap device_descriptions_;
184 152
185 // The service discovery client used listen for devices on the local network. 153 // The service discovery client used listen for devices on the local network.
186 scoped_refptr<ServiceDiscoverySharedClient> service_discovery_client_; 154 scoped_refptr<ServiceDiscoverySharedClient> service_discovery_client_;
187 155
188 // A factory for creating the privet HTTP Client. 156 // A factory for creating the privet HTTP Client.
189 scoped_ptr<PrivetHTTPAsynchronousFactory> privet_http_factory_; 157 scoped_ptr<PrivetHTTPAsynchronousFactory> privet_http_factory_;
190 158
191 // An object representing the resolution process for the privet_http_factory. 159 // An object representing the resolution process for the privet_http_factory.
192 scoped_ptr<PrivetHTTPResolution> privet_resolution_; 160 scoped_ptr<PrivetHTTPResolution> privet_resolution_;
193 161
194 // The current HTTP client (used for the current operation). 162 // The current HTTP client (used for the current operation).
195 scoped_ptr<PrivetV1HTTPClient> current_http_client_; 163 scoped_ptr<PrivetV1HTTPClient> current_http_client_;
196 164
197 // The current register operation. Only one allowed at any time. 165 // The current register operation. Only one allowed at any time.
198 scoped_ptr<PrivetRegisterOperation> current_register_operation_; 166 scoped_ptr<PrivetRegisterOperation> current_register_operation_;
199 167
200 // The current Privet v3 setup operation. Only one allowed at any time.
201 scoped_ptr<PrivetV3SetupFlow> current_setup_operation_;
202
203 // The current confirm call used during the registration flow. 168 // The current confirm call used during the registration flow.
204 scoped_ptr<GCDApiFlow> confirm_api_call_flow_; 169 scoped_ptr<GCDApiFlow> confirm_api_call_flow_;
205 170
206 // The device lister used to list devices on the local network. 171 // The device lister used to list devices on the local network.
207 scoped_ptr<PrivetDeviceLister> privet_lister_; 172 scoped_ptr<PrivetDeviceLister> privet_lister_;
208 173
209 // Whether or not the page is marked as visible. 174 // Whether or not the page is marked as visible.
210 bool is_visible_; 175 bool is_visible_;
211 176
212 // List of printers from cloud print. 177 // List of printers from cloud print.
213 scoped_ptr<GCDApiFlow> cloud_print_printer_list_; 178 scoped_ptr<GCDApiFlow> cloud_print_printer_list_;
214 scoped_ptr<GCDApiFlow> cloud_device_list_;
215 std::vector<Device> cloud_devices_; 179 std::vector<Device> cloud_devices_;
216 int failed_list_count_; 180 int failed_list_count_;
217 int succeded_list_count_; 181 int succeded_list_count_;
218 ResultCallback device_code_callback_;
219 182
220 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) 183 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE)
221 StringPrefMember cloud_print_connector_email_; 184 StringPrefMember cloud_print_connector_email_;
222 BooleanPrefMember cloud_print_connector_enabled_; 185 BooleanPrefMember cloud_print_connector_enabled_;
223 bool cloud_print_connector_ui_enabled_; 186 bool cloud_print_connector_ui_enabled_;
224 #endif 187 #endif
225 188
226 #if defined(ENABLE_WIFI_BOOTSTRAPPING)
227 scoped_ptr<wifi::WifiManager> wifi_manager_;
228 scoped_ptr<wifi::BootstrappingDeviceLister> bootstrapping_device_lister_;
229 #endif
230
231 DISALLOW_COPY_AND_ASSIGN(LocalDiscoveryUIHandler); 189 DISALLOW_COPY_AND_ASSIGN(LocalDiscoveryUIHandler);
232 }; 190 };
233 191
234 #undef CLOUD_PRINT_CONNECTOR_UI_AVAILABLE 192 #undef CLOUD_PRINT_CONNECTOR_UI_AVAILABLE
235 193
236 } // namespace local_discovery 194 } // namespace local_discovery
237 #endif // CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_ 195 #endif // CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698