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/printing/cloud_print/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/printing/cloud_print/gcd_api_flow.h" |
10 #include "chrome/browser/local_discovery/gcd_constants.h" | 10 #include "chrome/browser/printing/cloud_print/gcd_constants.h" |
11 #include "chrome/browser/local_discovery/privet_constants.h" | 11 #include "chrome/browser/printing/cloud_print/privet_constants.h" |
12 #include "chrome/common/cloud_print/cloud_print_constants.h" | 12 #include "chrome/common/cloud_print/cloud_print_constants.h" |
13 #include "components/cloud_devices/common/cloud_devices_urls.h" | 13 #include "components/cloud_devices/common/cloud_devices_urls.h" |
14 #include "net/base/url_util.h" | 14 #include "net/base/url_util.h" |
15 | 15 |
16 namespace local_discovery { | 16 namespace cloud_print { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 GURL GetConfirmFlowUrl(const std::string& token) { | 20 GURL GetConfirmFlowUrl(const std::string& token) { |
21 return net::AppendQueryParameter( | 21 return net::AppendQueryParameter( |
22 cloud_devices::GetCloudPrintRelativeURL("confirm"), "token", token); | 22 cloud_devices::GetCloudPrintRelativeURL("confirm"), "token", token); |
23 } | 23 } |
24 | 24 |
25 } // namespace | 25 } // namespace |
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(GCDApiFlow::Status status) { |
37 callback_.Run(status); | 37 callback_.Run(status); |
38 } | 38 } |
39 | 39 |
40 void PrivetConfirmApiCallFlow::OnGCDAPIFlowComplete( | 40 void PrivetConfirmApiCallFlow::OnGCDApiFlowComplete( |
41 const base::DictionaryValue& value) { | 41 const base::DictionaryValue& value) { |
42 bool success = false; | 42 bool success = false; |
43 | 43 |
44 if (!value.GetBoolean(cloud_print::kSuccessValue, &success)) { | 44 if (!value.GetBoolean(cloud_print::kSuccessValue, &success)) { |
45 callback_.Run(GCDApiFlow::ERROR_MALFORMED_RESPONSE); | 45 callback_.Run(GCDApiFlow::ERROR_MALFORMED_RESPONSE); |
46 return; | 46 return; |
47 } | 47 } |
48 | 48 |
49 if (success) { | 49 if (success) { |
50 callback_.Run(GCDApiFlow::SUCCESS); | 50 callback_.Run(GCDApiFlow::SUCCESS); |
51 } else { | 51 } else { |
52 callback_.Run(GCDApiFlow::ERROR_FROM_SERVER); | 52 callback_.Run(GCDApiFlow::ERROR_FROM_SERVER); |
53 } | 53 } |
54 } | 54 } |
55 | 55 |
56 net::URLFetcher::RequestType PrivetConfirmApiCallFlow::GetRequestType() { | 56 net::URLFetcher::RequestType PrivetConfirmApiCallFlow::GetRequestType() { |
57 return net::URLFetcher::GET; | 57 return net::URLFetcher::GET; |
58 } | 58 } |
59 | 59 |
60 GURL PrivetConfirmApiCallFlow::GetURL() { | 60 GURL PrivetConfirmApiCallFlow::GetURL() { |
61 return GetConfirmFlowUrl(token_); | 61 return GetConfirmFlowUrl(token_); |
62 } | 62 } |
63 | 63 |
64 } // namespace local_discovery | 64 } // namespace cloud_print |
OLD | NEW |