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

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

Issue 20070002: Demo UI for device discovery and registration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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>
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
19 namespace local_discovery {
20
11 // UI Handler for chrome://devices/ 21 // UI Handler for chrome://devices/
12 // It listens to local discovery notifications and passes those notifications 22 // It listens to local discovery notifications and passes those notifications
13 // into the Javascript to update the page. 23 // into the Javascript to update the page.
14 class LocalDiscoveryUIHandler : public content::WebUIMessageHandler { 24 class LocalDiscoveryUIHandler
25 : public content::WebUIMessageHandler,
26 public PrivetRegisterOperation::Delegate,
27 public PrivetDeviceLister::Delegate {
Dan Beam 2013/08/07 00:51:28 nit: class LocalDiscoveryUIHandler : public conten
Noam Samuel 2013/08/07 17:52:44 Done.
15 public: 28 public:
16 LocalDiscoveryUIHandler(); 29 LocalDiscoveryUIHandler();
17 virtual ~LocalDiscoveryUIHandler(); 30 virtual ~LocalDiscoveryUIHandler();
18 31
19 // WebUIMessageHandler implementation. 32 // WebUIMessageHandler implementation.
20 // Does nothing for now.
21 virtual void RegisterMessages() OVERRIDE; 33 virtual void RegisterMessages() OVERRIDE;
22 34
35 // PrivetRegisterOperation::Delegate implementation.
36 virtual void OnPrivetRegisterClaimToken(const std::string& token,
37 const GURL& url) OVERRIDE;
38 virtual void OnPrivetRegisterError(
39 const std::string& action,
40 PrivetRegisterOperation::FailureReason reason,
41 int printer_http_code,
42 const DictionaryValue* json) OVERRIDE;
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 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 HandleRegisterDevice(const base::ListValue* data);
Dan Beam 2013/08/07 00:51:28 nit: s/data/args/
Noam Samuel 2013/08/07 17:52:44 Done.
56 // For when the page is ready to recieve device notifications.
57 void HandleStart(const base::ListValue* value);
Dan Beam 2013/08/07 00:51:28 nit: s/value/args/
Noam Samuel 2013/08/07 17:52:44 Done.
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(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 // The current HTTP client (used for the current operation).
73 scoped_ptr<PrivetHTTPClient> current_http_client_;
Dan Beam 2013/08/07 00:51:28 nit: \n between each
Noam Samuel 2013/08/07 17:52:44 Done.
74 // The current register operation. Only one allowed at any time.
75 scoped_ptr<PrivetRegisterOperation>
76 current_register_operation_;
Dan Beam 2013/08/07 00:51:28 nit: can fit in 80 cols
Noam Samuel 2013/08/07 17:52:44 Done.
77 // The current confirm call used during the registration flow.
78 scoped_ptr<PrivetConfirmApiCallFlow> confirm_api_call_flow_;
79 // The name of the currently registering device.
80 std::string currently_registering_device_;
81 // The device lister used to list devices on the local network.
82 scoped_ptr<PrivetDeviceLister> privet_lister_;
83 // The service discovery client used listen for devices on the local network.
84 scoped_refptr<ServiceDiscoveryHostClient>
85 service_discovery_client_;
Dan Beam 2013/08/07 00:51:28 nit: can fit in 80 cols
Noam Samuel 2013/08/07 17:52:44 Done.
86 // A map of current device descriptions provided by the PrivetDeviceLister.
87 std::map<std::string, DeviceDescription> device_descriptions_;
88 // The local domain resolver used to resolve the domains for local devices.
89 scoped_ptr<LocalDomainResolver> domain_resolver_;
29 90
30 DISALLOW_COPY_AND_ASSIGN(LocalDiscoveryUIHandler); 91 DISALLOW_COPY_AND_ASSIGN(LocalDiscoveryUIHandler);
31 }; 92 };
32 93
94 } // namespace local_discovery
33 #endif // CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_ 95 #endif // CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698