| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/local_discovery/privetv3_setup_flow.h" | 5 #include "chrome/browser/local_discovery/privetv3_setup_flow.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/local_discovery/gcd_registration_ticket_request.h" | 8 #include "chrome/browser/local_discovery/gcd_registration_ticket_request.h" |
| 9 | 9 |
| 10 namespace local_discovery { | 10 namespace local_discovery { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 ticket_request_->Start(ticket_request.Pass()); | 102 ticket_request_->Start(ticket_request.Pass()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 #if defined(ENABLE_WIFI_BOOTSTRAPPING) | 105 #if defined(ENABLE_WIFI_BOOTSTRAPPING) |
| 106 void PrivetV3SetupFlow::SetupWifiAndRegister(const std::string& device_ssid) { | 106 void PrivetV3SetupFlow::SetupWifiAndRegister(const std::string& device_ssid) { |
| 107 NOTIMPLEMENTED(); | 107 NOTIMPLEMENTED(); |
| 108 } | 108 } |
| 109 #endif // ENABLE_WIFI_BOOTSTRAPPING | 109 #endif // ENABLE_WIFI_BOOTSTRAPPING |
| 110 | 110 |
| 111 void PrivetV3SetupFlow::OnSetupConfirmationNeeded( | 111 void PrivetV3SetupFlow::OnSetupConfirmationNeeded( |
| 112 const std::string& confirmation_code) { | 112 const std::string& confirmation_code, |
| 113 extensions::api::gcd_private::ConfirmationType confirmation_type) { |
| 113 delegate_->ConfirmSecurityCode(confirmation_code, | 114 delegate_->ConfirmSecurityCode(confirmation_code, |
| 114 base::Bind(&PrivetV3SetupFlow::OnCodeConfirmed, | 115 base::Bind(&PrivetV3SetupFlow::OnCodeConfirmed, |
| 115 weak_ptr_factory_.GetWeakPtr())); | 116 weak_ptr_factory_.GetWeakPtr(), |
| 117 confirmation_code)); |
| 116 } | 118 } |
| 117 | 119 |
| 118 void PrivetV3SetupFlow::OnSessionEstablished() { | 120 void PrivetV3SetupFlow::OnSessionStatus( |
| 119 DCHECK(setup_request_); | 121 extensions::api::gcd_private::Status status) { |
| 120 session_->StartRequest(setup_request_.get()); | 122 if (status == extensions::api::gcd_private::STATUS_SUCCESS) { |
| 121 } | 123 DCHECK(setup_request_); |
| 122 | 124 session_->StartRequest(setup_request_.get()); |
| 123 void PrivetV3SetupFlow::OnCannotEstablishSession() { | 125 } else { |
| 124 OnSetupError(); | 126 OnSetupError(); |
| 127 } |
| 125 } | 128 } |
| 126 | 129 |
| 127 void PrivetV3SetupFlow::OnSetupError() { | 130 void PrivetV3SetupFlow::OnSetupError() { |
| 128 delegate_->OnSetupError(); | 131 delegate_->OnSetupError(); |
| 129 } | 132 } |
| 130 | 133 |
| 131 void PrivetV3SetupFlow::OnDeviceRegistered() { | 134 void PrivetV3SetupFlow::OnDeviceRegistered() { |
| 132 delegate_->OnSetupDone(); | 135 delegate_->OnSetupDone(); |
| 133 } | 136 } |
| 134 | 137 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 152 void PrivetV3SetupFlow::OnPrivetClientCreated( | 155 void PrivetV3SetupFlow::OnPrivetClientCreated( |
| 153 scoped_ptr<PrivetHTTPClient> privet_http_client) { | 156 scoped_ptr<PrivetHTTPClient> privet_http_client) { |
| 154 if (!privet_http_client) { | 157 if (!privet_http_client) { |
| 155 OnSetupError(); | 158 OnSetupError(); |
| 156 return; | 159 return; |
| 157 } | 160 } |
| 158 session_.reset(new PrivetV3Session(privet_http_client.Pass(), this)); | 161 session_.reset(new PrivetV3Session(privet_http_client.Pass(), this)); |
| 159 session_->Start(); | 162 session_->Start(); |
| 160 } | 163 } |
| 161 | 164 |
| 162 void PrivetV3SetupFlow::OnCodeConfirmed(bool success) { | 165 void PrivetV3SetupFlow::OnCodeConfirmed(const std::string& code, bool success) { |
| 163 if (!success) | 166 if (!success) |
| 164 return OnSetupError(); | 167 return OnSetupError(); |
| 165 session_->ConfirmCode(); | 168 session_->ConfirmCode(code); |
| 166 } | 169 } |
| 167 | 170 |
| 168 } // namespace local_discovery | 171 } // namespace local_discovery |
| OLD | NEW |