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..d80a65521caaabcddc7b05a02ec87c32065669a2 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. |
virtual void RegisterMessages() OVERRIDE; |
+ // PrivetRegisterOperation::Delegate implementation. |
+ virtual void OnPrivetRegisterClaimToken(const std::string& token, |
+ const GURL& url) OVERRIDE; |
+ |
Dan Beam
2013/08/06 21:21:38
nit: remove \n
Noam Samuel
2013/08/06 23:54:05
Done.
|
+ virtual void OnPrivetRegisterError( |
+ const std::string& action, |
+ PrivetRegisterOperation::FailureReason reason, |
+ int printer_http_code, |
+ const DictionaryValue* json) OVERRIDE; |
Dan Beam
2013/08/06 21:21:38
nit: remove \n
Noam Samuel
2013/08/06 23:54:05
Done.
|
+ |
+ 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); |
Dan Beam
2013/08/06 21:21:38
nit: HandleRegister
Noam Samuel
2013/08/06 23:54:05
Done.
|
+ // For when the page is ready to recieve device notifications. |
+ void OnStart(const base::ListValue* value); |
Dan Beam
2013/08/06 21:21:38
nit: HandleStart
Noam Samuel
2013/08/06 23:54:05
Done.
|
+ |
+ // 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); |
+ |
Dan Beam
2013/08/06 21:21:38
doc comments for all these members
Noam Samuel
2013/08/06 23:54:05
Done.
|
+ 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_; |
Dan Beam
2013/08/06 21:21:38
nit: looks like this would fit in 80 cols
Noam Samuel
2013/08/06 23:54:05
Done.
|
- content::ActionCallback action_callback_; |
+ scoped_ptr<LocalDomainResolver> domain_resolver_; |
DISALLOW_COPY_AND_ASSIGN(LocalDiscoveryUIHandler); |
}; |
+} // namespace local_discovery |
Dan Beam
2013/08/06 21:21:38
nit: 2 spaces, e.g.
} // namespace local_discove
Noam Samuel
2013/08/06 23:54:05
Done.
|
#endif // CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_ |