Index: chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h |
diff --git a/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h b/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h |
index f2b7eec9a3495bb856c68662ba700ea5f7a4a512..51ff14e1a5de8d3ad7373057cdf0f90eea7ea2c0 100644 |
--- a/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h |
+++ b/chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h |
@@ -5,29 +5,89 @@ |
#ifndef CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_ |
#define CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_ |
+#include <map> |
+#include <string> |
+ |
+#include "chrome/browser/local_discovery/privet_confirm_api_flow.h" |
+#include "chrome/browser/local_discovery/privet_device_lister.h" |
+#include "chrome/browser/local_discovery/privet_http.h" |
+#include "chrome/browser/local_discovery/service_discovery_host_client.h" |
+#include "chrome/common/local_discovery/service_discovery_client.h" |
#include "content/public/browser/user_metrics.h" |
#include "content/public/browser/web_ui_message_handler.h" |
+namespace local_discovery { |
+ |
// UI Handler for chrome://devices/ |
// It listens to local discovery notifications and passes those notifications |
// into the Javascript to update the page. |
-class LocalDiscoveryUIHandler : public content::WebUIMessageHandler { |
+class LocalDiscoveryUIHandler |
+ : public content::WebUIMessageHandler, |
+ public PrivetRegisterOperation::Delegate, |
+ public PrivetDeviceLister::Delegate { |
public: |
LocalDiscoveryUIHandler(); |
virtual ~LocalDiscoveryUIHandler(); |
- // WebUIMessageHandler implementation. |
- // Does nothing for now. |
+ // WebUIMessageHandler implementation: |
James Hawkins
2013/07/29 16:27:03
Please revert this change. Comments must end with
Noam Samuel
2013/08/02 22:20:02
Done.
|
virtual void RegisterMessages() OVERRIDE; |
+ // PrivetRegisterOperation::Delegate implementation: |
+ virtual void OnPrivetRegisterClaimToken(const std::string& token, |
+ const GURL& url) OVERRIDE; |
+ |
+ virtual void OnPrivetRegisterError( |
+ const std::string& action, |
+ PrivetRegisterOperation::FailureReason reason, |
+ int printer_http_code, |
+ const DictionaryValue* json) OVERRIDE; |
+ |
+ virtual void OnPrivetRegisterDone(const std::string& device_id) OVERRIDE; |
+ |
+ // PrivetDeviceLister::Delegate implementation: |
+ virtual void DeviceChanged( |
+ bool added, |
+ const std::string& name, |
+ const DeviceDescription& description) OVERRIDE; |
+ virtual void DeviceRemoved(const std::string& name) OVERRIDE; |
+ |
private: |
- // Callback for adding new device to the devices page. |
- // |name| contains a user friendly name of the device. |
- void OnNewDevice(const std::string& name); |
+ // Message handlers: |
+ // For registering a device. |
+ void OnRegisterDevice(const base::ListValue* data); |
+ // For when the page is ready to recieve device notifications. |
+ void OnStart(const base::ListValue* value); |
+ |
+ // For when the IP address of the printer has been resolved. |
+ void OnDomainResolved(bool success, const net::IPAddressNumber& address); |
+ |
+ // For when the confirm operation on the cloudprint server has finished |
+ // executing. |
+ void OnConfirmDone(PrivetConfirmApiCallFlow::Status status); |
+ |
+ // Log an error to the web interface. |
+ void LogRegisterErrorToWeb(const std::string& error); |
+ |
+ // Log a successful registration to the web inteface. |
+ void LogRegisterDoneToWeb(const std::string& id); |
+ |
+ scoped_ptr<PrivetHTTPClient> current_http_client_; |
+ scoped_ptr<PrivetRegisterOperation> |
+ current_register_operation_; |
+ scoped_ptr<PrivetConfirmApiCallFlow> confirm_api_call_flow_; |
+ std::string currently_registering_device_; |
+ |
+ scoped_ptr<PrivetDeviceLister> privet_lister_; |
+ scoped_refptr<ServiceDiscoveryHostClient> |
+ service_discovery_client_; |
+ |
+ std::map<std::string, DeviceDescription> |
+ device_descriptions_; |
- content::ActionCallback action_callback_; |
+ scoped_ptr<LocalDomainResolver> domain_resolver_; |
DISALLOW_COPY_AND_ASSIGN(LocalDiscoveryUIHandler); |
}; |
+} // namespace local_discovery |
#endif // CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_ |