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 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h" | 5 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/local_discovery/privet_device_lister_impl.h" | 10 #include "chrome/browser/local_discovery/privet_device_lister_impl.h" |
11 #include "chrome/browser/local_discovery/privet_http_impl.h" | 11 #include "chrome/browser/local_discovery/privet_http_impl.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/signin/profile_oauth2_token_service.h" | 13 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
15 #include "chrome/browser/signin/signin_manager.h" | 15 #include "chrome/browser/signin/signin_manager.h" |
16 #include "chrome/browser/signin/signin_manager_base.h" | 16 #include "chrome/browser/signin/signin_manager_base.h" |
17 #include "chrome/browser/signin/signin_manager_factory.h" | 17 #include "chrome/browser/signin/signin_manager_factory.h" |
18 #include "content/public/browser/web_ui.h" | 18 #include "content/public/browser/web_ui.h" |
19 #include "net/base/host_port_pair.h" | 19 #include "net/base/host_port_pair.h" |
20 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
21 #include "net/http/http_status_code.h" | 21 #include "net/http/http_status_code.h" |
22 | 22 |
23 namespace local_discovery { | 23 namespace local_discovery { |
24 | 24 |
25 namespace { | 25 namespace { |
26 // TODO(noamsml): This is a temporary shim until automated_url is in the | 26 // TODO(noamsml): This is a temporary shim until automated_url is in the |
27 // response. | 27 // response. |
28 const char kPrivetAutomatedClaimURLFormat[] = "%s/confirm?token=%s"; | 28 const char kPrivetAutomatedClaimURLFormat[] = "%s/confirm?token=%s"; |
29 const int kAccountIndexUseOAuth2 = -1; | |
30 | 29 |
31 LocalDiscoveryUIHandler::Factory* g_factory = NULL; | 30 LocalDiscoveryUIHandler::Factory* g_factory = NULL; |
32 int g_num_visible = 0; | 31 int g_num_visible = 0; |
33 } // namespace | 32 } // namespace |
34 | 33 |
35 LocalDiscoveryUIHandler::LocalDiscoveryUIHandler() : is_visible_(false) { | 34 LocalDiscoveryUIHandler::LocalDiscoveryUIHandler() : is_visible_(false) { |
36 } | 35 } |
37 | 36 |
38 LocalDiscoveryUIHandler::LocalDiscoveryUIHandler( | 37 LocalDiscoveryUIHandler::LocalDiscoveryUIHandler( |
39 scoped_ptr<PrivetDeviceLister> privet_lister) { | 38 scoped_ptr<PrivetDeviceLister> privet_lister) { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 void LocalDiscoveryUIHandler::OnPrivetRegisterDone( | 227 void LocalDiscoveryUIHandler::OnPrivetRegisterDone( |
229 PrivetRegisterOperation* operation, | 228 PrivetRegisterOperation* operation, |
230 const std::string& device_id) { | 229 const std::string& device_id) { |
231 current_register_operation_.reset(); | 230 current_register_operation_.reset(); |
232 current_http_client_.reset(); | 231 current_http_client_.reset(); |
233 | 232 |
234 SendRegisterDone(); | 233 SendRegisterDone(); |
235 } | 234 } |
236 | 235 |
237 void LocalDiscoveryUIHandler::OnConfirmDone( | 236 void LocalDiscoveryUIHandler::OnConfirmDone( |
238 PrivetConfirmApiCallFlow::Status status) { | 237 CloudPrintBaseApiFlow::Status status) { |
239 if (status == PrivetConfirmApiCallFlow::SUCCESS) { | 238 if (status == CloudPrintBaseApiFlow::SUCCESS) { |
240 DLOG(INFO) << "Confirm success."; | |
241 confirm_api_call_flow_.reset(); | 239 confirm_api_call_flow_.reset(); |
242 current_register_operation_->CompleteRegistration(); | 240 current_register_operation_->CompleteRegistration(); |
243 } else { | 241 } else { |
244 // TODO(noamsml): Add detailed error message. | 242 // TODO(noamsml): Add detailed error message. |
245 SendRegisterError(); | 243 SendRegisterError(); |
246 } | 244 } |
247 } | 245 } |
248 | 246 |
249 void LocalDiscoveryUIHandler::DeviceChanged( | 247 void LocalDiscoveryUIHandler::DeviceChanged( |
250 bool added, | 248 bool added, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 | 370 |
373 confirm_api_call_flow_.reset(); | 371 confirm_api_call_flow_.reset(); |
374 privet_resolution_.reset(); | 372 privet_resolution_.reset(); |
375 cloud_print_account_manager_.reset(); | 373 cloud_print_account_manager_.reset(); |
376 xsrf_token_for_primary_user_.clear(); | 374 xsrf_token_for_primary_user_.clear(); |
377 current_register_user_index_ = 0; | 375 current_register_user_index_ = 0; |
378 current_http_client_.reset(); | 376 current_http_client_.reset(); |
379 } | 377 } |
380 | 378 |
381 } // namespace local_discovery | 379 } // namespace local_discovery |
OLD | NEW |