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

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

Issue 1898503002: Cleanup LocalDiscoveryUIHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/printing/cloud_print/cloud_print_printer_list.h" 14 #include "chrome/browser/printing/cloud_print/cloud_print_printer_list.h"
15 #include "chrome/browser/printing/cloud_print/privet_device_lister.h" 15 #include "chrome/browser/printing/cloud_print/privet_device_lister.h"
16 #include "chrome/browser/printing/cloud_print/privet_http.h" 16 #include "chrome/browser/printing/cloud_print/privet_http.h"
17 #include "components/signin/core/browser/signin_manager.h" 17 #include "components/signin/core/browser/signin_manager.h"
18 #include "content/public/browser/web_ui_message_handler.h" 18 #include "content/public/browser/web_ui_message_handler.h"
19 19
20 #if defined(ENABLE_PRINT_PREVIEW) && !defined(OS_CHROMEOS) 20 #if defined(ENABLE_PRINT_PREVIEW) && !defined(OS_CHROMEOS)
21 #define CLOUD_PRINT_CONNECTOR_UI_AVAILABLE 21 #define CLOUD_PRINT_CONNECTOR_UI_AVAILABLE
22 #endif 22 #endif
23 23
24 class CloudPrintProxyService;
25
24 namespace cloud_print { 26 namespace cloud_print {
25 class PrivetConfirmApiCallFlow;
26 class PrivetHTTPAsynchronousFactory; 27 class PrivetHTTPAsynchronousFactory;
27 class PrivetHTTPResolution; 28 class PrivetHTTPResolution;
28 class PrivetV1HTTPClient; 29 class PrivetV1HTTPClient;
29 } 30 }
30 31
31 // TODO(noamsml): Factor out full registration flow into single class 32 // TODO(noamsml): Factor out full registration flow into single class
32 namespace local_discovery { 33 namespace local_discovery {
33 34
34 class ServiceDiscoverySharedClient; 35 class ServiceDiscoverySharedClient;
35 36
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 void OnDeviceListUnavailable() override; 79 void OnDeviceListUnavailable() override;
79 80
80 // SigninManagerBase::Observer implementation. 81 // SigninManagerBase::Observer implementation.
81 void GoogleSigninSucceeded(const std::string& account_id, 82 void GoogleSigninSucceeded(const std::string& account_id,
82 const std::string& username, 83 const std::string& username,
83 const std::string& password) override; 84 const std::string& password) override;
84 void GoogleSignedOut(const std::string& account_id, 85 void GoogleSignedOut(const std::string& account_id,
85 const std::string& username) override; 86 const std::string& username) override;
86 87
87 private: 88 private:
88 typedef std::map<std::string, 89 using DeviceDescriptionMap =
89 cloud_print::DeviceDescription> DeviceDescriptionMap; 90 std::map<std::string, cloud_print::DeviceDescription>;
90 typedef base::Callback<void(bool result)> ResultCallback; 91 using ResultCallback = base::Callback<void(bool result)>;
91 92
92 // Message handlers: 93 // Message handlers:
93 // For when the page is ready to receive device notifications. 94 // For when the page is ready to receive device notifications.
94 void HandleStart(const base::ListValue* args); 95 void HandleStart(const base::ListValue* args);
95 96
96 // For when a visibility change occurs. 97 // For when a visibility change occurs.
97 void HandleIsVisible(const base::ListValue* args); 98 void HandleIsVisible(const base::ListValue* args);
98 99
99 // For when a user choice is made. 100 // For when a user choice is made.
100 void HandleRegisterDevice(const base::ListValue* args); 101 void HandleRegisterDevice(const base::ListValue* args);
(...skipping 22 matching lines...) Expand all
123 // Signal to the web interface an error has ocurred while registering. 124 // Signal to the web interface an error has ocurred while registering.
124 void SendRegisterError(); 125 void SendRegisterError();
125 126
126 // Singal to the web interface that registration has finished. 127 // Singal to the web interface that registration has finished.
127 void SendRegisterDone(const std::string& service_name); 128 void SendRegisterDone(const std::string& service_name);
128 129
129 // Set the visibility of the page. 130 // Set the visibility of the page.
130 void SetIsVisible(bool visible); 131 void SetIsVisible(bool visible);
131 132
132 // Get the sync account email. 133 // Get the sync account email.
133 std::string GetSyncAccount(); 134 std::string GetSyncAccount() const;
134 135
135 // Reset and cancel the current registration. 136 // Reset and cancel the current registration.
136 void ResetCurrentRegistration(); 137 void ResetCurrentRegistration();
137 138
138 std::unique_ptr<cloud_print::GCDApiFlow> CreateApiFlow(); 139 std::unique_ptr<cloud_print::GCDApiFlow> CreateApiFlow();
139 void OnSetupError(); 140 void OnSetupError();
140 141
141 // Announcement hasn't been sent for a certain time after registration 142 // Announcement hasn't been sent for a certain time after registration
142 // finished. Consider it failed. 143 // finished. Consider it failed.
143 // TODO(noamsml): Re-resolve service first. 144 // TODO(noamsml): Re-resolve service first.
144 void OnAnnouncementTimeoutReached(); 145 void OnAnnouncementTimeoutReached();
145 146
146 void CheckUserLoggedIn(); 147 void CheckUserLoggedIn();
147 148
148 void CheckListingDone(); 149 void CheckListingDone();
149 150
150 bool IsUserSupervisedOrOffTheRecord(); 151 bool IsUserSupervisedOrOffTheRecord();
151 152
152 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) 153 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE)
153 void StartCloudPrintConnector(); 154 void StartCloudPrintConnector();
154 void OnCloudPrintPrefsChanged(); 155 void OnCloudPrintPrefsChanged();
155 void ShowCloudPrintSetupDialog(const base::ListValue* args); 156 void ShowCloudPrintSetupDialog(const base::ListValue* args);
156 void HandleDisableCloudPrintConnector(const base::ListValue* args); 157 void HandleDisableCloudPrintConnector(const base::ListValue* args);
157 void SetupCloudPrintConnectorSection(); 158 void SetupCloudPrintConnectorSection();
158 void RemoveCloudPrintConnectorSection();
159 void RefreshCloudPrintStatusFromService(); 159 void RefreshCloudPrintStatusFromService();
160 CloudPrintProxyService* GetCloudPrintProxyService();
160 #endif 161 #endif
161 162
162 // A map of current device descriptions provided by the PrivetDeviceLister. 163 // A map of current device descriptions provided by the PrivetDeviceLister.
163 DeviceDescriptionMap device_descriptions_; 164 DeviceDescriptionMap device_descriptions_;
164 165
165 // 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.
166 scoped_refptr<ServiceDiscoverySharedClient> service_discovery_client_; 167 scoped_refptr<ServiceDiscoverySharedClient> service_discovery_client_;
167 168
168 // A factory for creating the privet HTTP Client. 169 // A factory for creating the privet HTTP Client.
169 std::unique_ptr<cloud_print::PrivetHTTPAsynchronousFactory> 170 std::unique_ptr<cloud_print::PrivetHTTPAsynchronousFactory>
(...skipping 20 matching lines...) Expand all
190 191
191 // List of printers from cloud print. 192 // List of printers from cloud print.
192 std::unique_ptr<cloud_print::GCDApiFlow> cloud_print_printer_list_; 193 std::unique_ptr<cloud_print::GCDApiFlow> cloud_print_printer_list_;
193 std::vector<cloud_print::CloudPrintPrinterList::Device> cloud_devices_; 194 std::vector<cloud_print::CloudPrintPrinterList::Device> cloud_devices_;
194 int failed_list_count_; 195 int failed_list_count_;
195 int succeded_list_count_; 196 int succeded_list_count_;
196 197
197 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) 198 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE)
198 StringPrefMember cloud_print_connector_email_; 199 StringPrefMember cloud_print_connector_email_;
199 BooleanPrefMember cloud_print_connector_enabled_; 200 BooleanPrefMember cloud_print_connector_enabled_;
200 bool cloud_print_connector_ui_enabled_;
Vitaly Buka (NO REVIEWS) 2016/04/16 01:33:52 you are replacing this with def?
Lei Zhang 2016/04/16 01:53:19 I'm assuming this is always true now.
Vitaly Buka (NO REVIEWS) 2016/04/16 02:17:56 sgtm
201 #endif 201 #endif
202 202
203 DISALLOW_COPY_AND_ASSIGN(LocalDiscoveryUIHandler); 203 DISALLOW_COPY_AND_ASSIGN(LocalDiscoveryUIHandler);
204 }; 204 };
205 205
206 #undef CLOUD_PRINT_CONNECTOR_UI_AVAILABLE 206 #undef CLOUD_PRINT_CONNECTOR_UI_AVAILABLE
207 207
208 } // namespace local_discovery 208 } // namespace local_discovery
209
209 #endif // CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_ 210 #endif // CHROME_BROWSER_UI_WEBUI_LOCAL_DISCOVERY_LOCAL_DISCOVERY_UI_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698