OLD | NEW |
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> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 public CloudDeviceListDelegate, | 45 public CloudDeviceListDelegate, |
46 public SigninManagerBase::Observer { | 46 public SigninManagerBase::Observer { |
47 public: | 47 public: |
48 LocalDiscoveryUIHandler(); | 48 LocalDiscoveryUIHandler(); |
49 virtual ~LocalDiscoveryUIHandler(); | 49 virtual ~LocalDiscoveryUIHandler(); |
50 | 50 |
51 static bool GetHasVisible(); | 51 static bool GetHasVisible(); |
52 | 52 |
53 // WebUIMessageHandler implementation. | 53 // WebUIMessageHandler implementation. |
54 virtual void RegisterMessages() OVERRIDE; | 54 virtual void RegisterMessages() OVERRIDE; |
55 | |
56 // PrivetRegisterOperation::Delegate implementation. | 55 // PrivetRegisterOperation::Delegate implementation. |
57 virtual void OnPrivetRegisterClaimToken( | 56 virtual void OnPrivetRegisterClaimToken( |
58 PrivetRegisterOperation* operation, | 57 PrivetRegisterOperation* operation, |
59 const std::string& token, | 58 const std::string& token, |
60 const GURL& url) OVERRIDE; | 59 const GURL& url) OVERRIDE; |
61 | |
62 virtual void OnPrivetRegisterError( | 60 virtual void OnPrivetRegisterError( |
63 PrivetRegisterOperation* operation, | 61 PrivetRegisterOperation* operation, |
64 const std::string& action, | 62 const std::string& action, |
65 PrivetRegisterOperation::FailureReason reason, | 63 PrivetRegisterOperation::FailureReason reason, |
66 int printer_http_code, | 64 int printer_http_code, |
67 const base::DictionaryValue* json) OVERRIDE; | 65 const base::DictionaryValue* json) OVERRIDE; |
68 | |
69 virtual void OnPrivetRegisterDone( | 66 virtual void OnPrivetRegisterDone( |
70 PrivetRegisterOperation* operation, | 67 PrivetRegisterOperation* operation, |
71 const std::string& device_id) OVERRIDE; | 68 const std::string& device_id) OVERRIDE; |
72 | 69 |
73 // PrivetDeviceLister::Delegate implementation. | 70 // PrivetDeviceLister::Delegate implementation. |
74 virtual void DeviceChanged(bool added, | 71 virtual void DeviceChanged(bool added, |
75 const std::string& name, | 72 const std::string& name, |
76 const DeviceDescription& description) OVERRIDE; | 73 const DeviceDescription& description) OVERRIDE; |
77 | |
78 virtual void DeviceRemoved(const std::string& name) OVERRIDE; | 74 virtual void DeviceRemoved(const std::string& name) OVERRIDE; |
79 | |
80 virtual void DeviceCacheFlushed() OVERRIDE; | 75 virtual void DeviceCacheFlushed() OVERRIDE; |
81 | 76 |
82 // CloudDeviceListDelegate implementation. | 77 // CloudDeviceListDelegate implementation. |
83 virtual void OnDeviceListReady(const std::vector<Device>& devices) OVERRIDE; | 78 virtual void OnDeviceListReady(const std::vector<Device>& devices) OVERRIDE; |
84 virtual void OnDeviceListUnavailable() OVERRIDE; | 79 virtual void OnDeviceListUnavailable() OVERRIDE; |
85 | 80 |
86 // SigninManagerBase::Observer implementation. | 81 // SigninManagerBase::Observer implementation. |
87 virtual void GoogleSigninSucceeded(const std::string& username, | 82 virtual void GoogleSigninSucceeded(const std::string& username, |
88 const std::string& password) OVERRIDE; | 83 const std::string& password) OVERRIDE; |
89 | |
90 virtual void GoogleSignedOut(const std::string& username) OVERRIDE; | 84 virtual void GoogleSignedOut(const std::string& username) OVERRIDE; |
91 | 85 |
92 private: | 86 private: |
93 typedef std::map<std::string, DeviceDescription> DeviceDescriptionMap; | 87 typedef std::map<std::string, DeviceDescription> DeviceDescriptionMap; |
94 | 88 |
95 // Message handlers: | 89 // Message handlers: |
96 // For when the page is ready to receive device notifications. | 90 // For when the page is ready to receive device notifications. |
97 void HandleStart(const base::ListValue* args); | 91 void HandleStart(const base::ListValue* args); |
98 | 92 |
99 // For when a visibility change occurs. | 93 // For when a visibility change occurs. |
(...skipping 13 matching lines...) Expand all Loading... |
113 void HandleOpenCloudPrintURL(const base::ListValue* args); | 107 void HandleOpenCloudPrintURL(const base::ListValue* args); |
114 | 108 |
115 // For showing sync login UI. | 109 // For showing sync login UI. |
116 void HandleShowSyncUI(const base::ListValue* args); | 110 void HandleShowSyncUI(const base::ListValue* args); |
117 | 111 |
118 // For when the IP address of the printer has been resolved for registration. | 112 // For when the IP address of the printer has been resolved for registration. |
119 void StartRegisterHTTP(scoped_ptr<PrivetHTTPClient> http_client); | 113 void StartRegisterHTTP(scoped_ptr<PrivetHTTPClient> http_client); |
120 | 114 |
121 // For when the confirm operation on the cloudprint server has finished | 115 // For when the confirm operation on the cloudprint server has finished |
122 // executing. | 116 // executing. |
123 void OnConfirmDone(GCDApiFlow::Status status); | 117 void OnConfirmDone(GCDApiFlowInterface::Status status); |
124 | 118 |
125 // Signal to the web interface an error has ocurred while registering. | 119 // Signal to the web interface an error has ocurred while registering. |
126 void SendRegisterError(); | 120 void SendRegisterError(); |
127 | 121 |
128 // Singal to the web interface that registration has finished. | 122 // Singal to the web interface that registration has finished. |
129 void SendRegisterDone(const std::string& service_name, | 123 void SendRegisterDone(const std::string& service_name, |
130 const DeviceDescription& device); | 124 const DeviceDescription& device); |
131 | 125 |
132 // Set the visibility of the page. | 126 // Set the visibility of the page. |
133 void SetIsVisible(bool visible); | 127 void SetIsVisible(bool visible); |
134 | 128 |
135 // Get the sync account email. | 129 // Get the sync account email. |
136 std::string GetSyncAccount(); | 130 std::string GetSyncAccount(); |
137 | 131 |
138 // Reset and cancel the current registration. | 132 // Reset and cancel the current registration. |
139 void ResetCurrentRegistration(); | 133 void ResetCurrentRegistration(); |
140 | 134 |
141 // Announcement hasn't been sent for a certain time after registration | 135 // Announcement hasn't been sent for a certain time after registration |
142 // finished. Consider it failed. | 136 // finished. Consider it failed. |
143 // TODO(noamsml): Re-resolve service first. | 137 // TODO(noamsml): Re-resolve service first. |
144 void OnAnnouncementTimeoutReached(); | 138 void OnAnnouncementTimeoutReached(); |
145 | 139 |
146 void CheckUserLoggedIn(); | 140 void CheckUserLoggedIn(); |
147 | 141 |
148 void CheckListingDone(); | 142 void CheckListingDone(); |
149 | 143 |
150 scoped_ptr<GCDApiFlow> CreateApiFlow(scoped_ptr<GCDApiFlow::Request> request); | 144 scoped_ptr<GCDApiFlowInterface> CreateApiFlow(); |
151 | 145 |
152 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) | 146 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) |
153 void StartCloudPrintConnector(); | 147 void StartCloudPrintConnector(); |
154 void OnCloudPrintPrefsChanged(); | 148 void OnCloudPrintPrefsChanged(); |
155 void ShowCloudPrintSetupDialog(const base::ListValue* args); | 149 void ShowCloudPrintSetupDialog(const base::ListValue* args); |
156 void HandleDisableCloudPrintConnector(const base::ListValue* args); | 150 void HandleDisableCloudPrintConnector(const base::ListValue* args); |
157 void SetupCloudPrintConnectorSection(); | 151 void SetupCloudPrintConnectorSection(); |
158 void RemoveCloudPrintConnectorSection(); | 152 void RemoveCloudPrintConnectorSection(); |
159 void RefreshCloudPrintStatusFromService(); | 153 void RefreshCloudPrintStatusFromService(); |
160 #endif | 154 #endif |
161 | 155 |
162 #if defined(ENABLE_WIFI_BOOTSTRAPPING) | 156 #if defined(ENABLE_WIFI_BOOTSTRAPPING) |
163 void StartWifiBootstrapping(); | 157 void StartWifiBootstrapping(); |
164 void OnBootstrappingDeviceChanged( | 158 void OnBootstrappingDeviceChanged( |
165 bool available, | 159 bool available, |
166 const wifi::BootstrappingDeviceDescription& description); | 160 const wifi::BootstrappingDeviceDescription& description); |
167 #endif | 161 #endif |
168 | 162 |
169 // The current HTTP client (used for the current operation). | 163 // A map of current device descriptions provided by the PrivetDeviceLister. |
170 scoped_ptr<PrivetV1HTTPClient> current_http_client_; | 164 DeviceDescriptionMap device_descriptions_; |
171 | |
172 // The current register operation. Only one allowed at any time. | |
173 scoped_ptr<PrivetRegisterOperation> current_register_operation_; | |
174 | |
175 // The current confirm call used during the registration flow. | |
176 scoped_ptr<GCDApiFlow> confirm_api_call_flow_; | |
177 | |
178 // The device lister used to list devices on the local network. | |
179 scoped_ptr<PrivetDeviceLister> privet_lister_; | |
180 | 165 |
181 // The service discovery client used listen for devices on the local network. | 166 // The service discovery client used listen for devices on the local network. |
182 scoped_refptr<ServiceDiscoverySharedClient> service_discovery_client_; | 167 scoped_refptr<ServiceDiscoverySharedClient> service_discovery_client_; |
183 | 168 |
184 // A factory for creating the privet HTTP Client. | 169 // A factory for creating the privet HTTP Client. |
185 scoped_ptr<PrivetHTTPAsynchronousFactory> privet_http_factory_; | 170 scoped_ptr<PrivetHTTPAsynchronousFactory> privet_http_factory_; |
186 | 171 |
187 // An object representing the resolution process for the privet_http_factory. | 172 // An object representing the resolution process for the privet_http_factory. |
188 scoped_ptr<PrivetHTTPResolution> privet_resolution_; | 173 scoped_ptr<PrivetHTTPResolution> privet_resolution_; |
189 | 174 |
190 // A map of current device descriptions provided by the PrivetDeviceLister. | 175 // The current HTTP client (used for the current operation). |
191 DeviceDescriptionMap device_descriptions_; | 176 scoped_ptr<PrivetV1HTTPClient> current_http_client_; |
| 177 |
| 178 // The current register operation. Only one allowed at any time. |
| 179 scoped_ptr<PrivetRegisterOperation> current_register_operation_; |
| 180 |
| 181 // The current confirm call used during the registration flow. |
| 182 scoped_ptr<GCDApiFlowInterface> confirm_api_call_flow_; |
| 183 |
| 184 // The device lister used to list devices on the local network. |
| 185 scoped_ptr<PrivetDeviceLister> privet_lister_; |
192 | 186 |
193 // Whether or not the page is marked as visible. | 187 // Whether or not the page is marked as visible. |
194 bool is_visible_; | 188 bool is_visible_; |
195 | 189 |
196 // List of printers from cloud print. | 190 // List of printers from cloud print. |
197 scoped_ptr<GCDApiFlow> cloud_print_printer_list_; | 191 scoped_ptr<GCDApiFlowInterface> cloud_print_printer_list_; |
198 scoped_ptr<GCDApiFlow> cloud_device_list_; | 192 scoped_ptr<GCDApiFlowInterface> cloud_device_list_; |
199 std::vector<Device> cloud_devices_; | 193 std::vector<Device> cloud_devices_; |
200 int failed_list_count_; | 194 int failed_list_count_; |
201 int succeded_list_count_; | 195 int succeded_list_count_; |
202 | 196 |
203 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) | 197 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) |
204 StringPrefMember cloud_print_connector_email_; | 198 StringPrefMember cloud_print_connector_email_; |
205 BooleanPrefMember cloud_print_connector_enabled_; | 199 BooleanPrefMember cloud_print_connector_enabled_; |
206 bool cloud_print_connector_ui_enabled_; | 200 bool cloud_print_connector_ui_enabled_; |
207 #endif | 201 #endif |
208 | 202 |
209 #if defined(ENABLE_WIFI_BOOTSTRAPPING) | 203 #if defined(ENABLE_WIFI_BOOTSTRAPPING) |
210 scoped_ptr<wifi::WifiManager> wifi_manager_; | 204 scoped_ptr<wifi::WifiManager> wifi_manager_; |
211 scoped_ptr<wifi::BootstrappingDeviceLister> bootstrapping_device_lister_; | 205 scoped_ptr<wifi::BootstrappingDeviceLister> bootstrapping_device_lister_; |
212 #endif | 206 #endif |
213 | 207 |
214 DISALLOW_COPY_AND_ASSIGN(LocalDiscoveryUIHandler); | 208 DISALLOW_COPY_AND_ASSIGN(LocalDiscoveryUIHandler); |
215 }; | 209 }; |
216 | 210 |
217 #undef CLOUD_PRINT_CONNECTOR_UI_AVAILABLE | 211 #undef CLOUD_PRINT_CONNECTOR_UI_AVAILABLE |
218 | 212 |
219 } // namespace local_discovery | 213 } // namespace local_discovery |
220 #endif // CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_ | 214 #endif // CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_ |
OLD | NEW |