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> | |
9 #include <string> | |
10 | |
11 #include "chrome/browser/local_discovery/privet_confirm_api_flow.h" | |
12 #include "chrome/browser/local_discovery/privet_device_lister.h" | |
13 #include "chrome/browser/local_discovery/privet_http.h" | |
14 #include "chrome/browser/local_discovery/service_discovery_host_client.h" | |
15 #include "chrome/common/local_discovery/service_discovery_client.h" | |
8 #include "content/public/browser/user_metrics.h" | 16 #include "content/public/browser/user_metrics.h" |
9 #include "content/public/browser/web_ui_message_handler.h" | 17 #include "content/public/browser/web_ui_message_handler.h" |
10 | 18 |
11 // UI Handler for chrome://devices/ | 19 // UI Handler for chrome://devices/ |
Vitaly Buka (NO REVIEWS)
2013/07/24 01:27:54
you can put this class in local_discovery namespac
Noam Samuel
2013/07/24 17:57:32
Done.
| |
12 // It listens to local discovery notifications and passes those notifications | 20 // It listens to local discovery notifications and passes those notifications |
13 // into the Javascript to update the page. | 21 // into the Javascript to update the page. |
14 class LocalDiscoveryUIHandler : public content::WebUIMessageHandler { | 22 class LocalDiscoveryUIHandler |
23 : public content::WebUIMessageHandler, | |
24 public local_discovery::PrivetRegisterOperation::Delegate, | |
25 public local_discovery::PrivetDeviceLister::Delegate { | |
15 public: | 26 public: |
16 LocalDiscoveryUIHandler(); | 27 LocalDiscoveryUIHandler(); |
17 virtual ~LocalDiscoveryUIHandler(); | 28 virtual ~LocalDiscoveryUIHandler(); |
18 | 29 |
19 // WebUIMessageHandler implementation. | 30 // WebUIMessageHandler implementation: |
20 // Does nothing for now. | |
21 virtual void RegisterMessages() OVERRIDE; | 31 virtual void RegisterMessages() OVERRIDE; |
22 | 32 |
33 // PrivetRegisterOperation::Delegate implementation: | |
34 virtual void OnPrivetRegisterClaimToken(const std::string& token, | |
35 const GURL& url) OVERRIDE; | |
36 | |
37 virtual void OnPrivetRegisterError( | |
38 const std::string& action, | |
39 local_discovery::PrivetRegisterOperation::FailureReason reason, | |
40 int printer_http_code, | |
41 const DictionaryValue* json) OVERRIDE; | |
42 | |
43 virtual void OnPrivetRegisterDone(const std::string& device_id) OVERRIDE; | |
44 | |
45 // PrivetDeviceLister::Delegate implementation: | |
46 virtual void DeviceChanged( | |
47 bool added, | |
48 const std::string& name, | |
49 const local_discovery::DeviceDescription& description) OVERRIDE; | |
50 virtual void DeviceRemoved(const std::string& name) OVERRIDE; | |
51 | |
23 private: | 52 private: |
24 // Callback for adding new device to the devices page. | 53 // Message handlers: |
25 // |name| contains a user friendly name of the device. | 54 // For registering a device. |
26 void OnNewDevice(const std::string& name); | 55 void OnRegisterDevice(const base::ListValue* data); |
56 // For when the page is ready to recieve device notifications. | |
57 void OnStart(const base::ListValue* value); | |
27 | 58 |
28 content::ActionCallback action_callback_; | 59 // For when the IP address of the printer has been resolved. |
60 void OnDomainResolved(bool success, const net::IPAddressNumber& address); | |
61 | |
62 // For when the confirm operation on the cloudprint server has finished | |
63 // executing. | |
64 void OnConfirmDone(local_discovery::PrivetConfirmApiCallFlow::Status status); | |
65 | |
66 // Log an error to the web interface. | |
67 void LogRegisterErrorToWeb(const std::string& error); | |
68 | |
69 // Log a successful registration to the web inteface. | |
70 void LogRegisterDoneToWeb(const std::string& id); | |
71 | |
72 scoped_ptr<local_discovery::PrivetHTTPClient> current_http_client_; | |
Vitaly Buka (NO REVIEWS)
2013/07/24 01:27:54
and remove local_discovery::
Noam Samuel
2013/07/24 17:57:32
Done.
| |
73 scoped_ptr<local_discovery::PrivetRegisterOperation> | |
74 current_register_operation_; | |
75 scoped_ptr<local_discovery::PrivetConfirmApiCallFlow> confirm_api_call_flow_; | |
76 std::string currently_registering_device_; | |
77 | |
78 scoped_ptr<local_discovery::PrivetDeviceLister> privet_lister_; | |
79 scoped_refptr<local_discovery::ServiceDiscoveryHostClient> | |
80 service_discovery_client_; | |
81 | |
82 std::map<std::string, local_discovery::DeviceDescription> | |
83 device_descriptions_; | |
84 | |
85 scoped_ptr<local_discovery::LocalDomainResolver> domain_resolver_; | |
29 | 86 |
30 DISALLOW_COPY_AND_ASSIGN(LocalDiscoveryUIHandler); | 87 DISALLOW_COPY_AND_ASSIGN(LocalDiscoveryUIHandler); |
31 }; | 88 }; |
32 | 89 |
33 #endif // CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_ | 90 #endif // CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_ |
OLD | NEW |