| 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/local_discovery/privet_confirm_api_flow.h" | 5 #include "chrome/browser/local_discovery/privet_confirm_api_flow.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/local_discovery/gcd_api_flow.h" | 9 #include "chrome/browser/local_discovery/gcd_api_flow.h" |
| 10 #include "chrome/browser/local_discovery/gcd_constants.h" | 10 #include "chrome/browser/local_discovery/gcd_constants.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 PrivetConfirmApiCallFlow::PrivetConfirmApiCallFlow( | 27 PrivetConfirmApiCallFlow::PrivetConfirmApiCallFlow( |
| 28 const std::string& token, | 28 const std::string& token, |
| 29 const ResponseCallback& callback) | 29 const ResponseCallback& callback) |
| 30 : callback_(callback), token_(token) { | 30 : callback_(callback), token_(token) { |
| 31 } | 31 } |
| 32 | 32 |
| 33 PrivetConfirmApiCallFlow::~PrivetConfirmApiCallFlow() { | 33 PrivetConfirmApiCallFlow::~PrivetConfirmApiCallFlow() { |
| 34 } | 34 } |
| 35 | 35 |
| 36 void PrivetConfirmApiCallFlow::OnGCDAPIFlowError(GCDApiFlow::Status status) { | 36 void PrivetConfirmApiCallFlow::OnGCDAPIFlowError( |
| 37 GCDApiFlowInterface::Status status) { |
| 37 callback_.Run(status); | 38 callback_.Run(status); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void PrivetConfirmApiCallFlow::OnGCDAPIFlowComplete( | 41 void PrivetConfirmApiCallFlow::OnGCDAPIFlowComplete( |
| 41 const base::DictionaryValue& value) { | 42 const base::DictionaryValue& value) { |
| 42 bool success = false; | 43 bool success = false; |
| 43 | 44 |
| 44 if (!value.GetBoolean(cloud_print::kSuccessValue, &success)) { | 45 if (!value.GetBoolean(cloud_print::kSuccessValue, &success)) { |
| 45 callback_.Run(GCDApiFlow::ERROR_MALFORMED_RESPONSE); | 46 callback_.Run(GCDApiFlowInterface::ERROR_MALFORMED_RESPONSE); |
| 46 return; | 47 return; |
| 47 } | 48 } |
| 48 | 49 |
| 49 if (success) { | 50 if (success) { |
| 50 callback_.Run(GCDApiFlow::SUCCESS); | 51 callback_.Run(GCDApiFlowInterface::SUCCESS); |
| 51 } else { | 52 } else { |
| 52 callback_.Run(GCDApiFlow::ERROR_FROM_SERVER); | 53 callback_.Run(GCDApiFlowInterface::ERROR_FROM_SERVER); |
| 53 } | 54 } |
| 54 } | 55 } |
| 55 | 56 |
| 56 net::URLFetcher::RequestType PrivetConfirmApiCallFlow::GetRequestType() { | 57 net::URLFetcher::RequestType PrivetConfirmApiCallFlow::GetRequestType() { |
| 57 return net::URLFetcher::GET; | 58 return net::URLFetcher::GET; |
| 58 } | 59 } |
| 59 | 60 |
| 60 GURL PrivetConfirmApiCallFlow::GetURL() { | 61 GURL PrivetConfirmApiCallFlow::GetURL() { |
| 61 return GetConfirmFlowUrl(token_); | 62 return GetConfirmFlowUrl(token_); |
| 62 } | 63 } |
| 63 | 64 |
| 64 } // namespace local_discovery | 65 } // namespace local_discovery |
| OLD | NEW |