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

Side by Side Diff: chrome/browser/printing/cloud_print/privet_confirm_api_flow.cc

Issue 2742763002: Clean up Cloud Print API flow code. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « chrome/browser/printing/cloud_print/privet_confirm_api_flow.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/printing/cloud_print/privet_confirm_api_flow.h" 5 #include "chrome/browser/printing/cloud_print/privet_confirm_api_flow.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/printing/cloud_print/gcd_api_flow.h" 8 #include "chrome/browser/printing/cloud_print/gcd_api_flow.h"
9 #include "chrome/browser/printing/cloud_print/gcd_constants.h" 9 #include "chrome/browser/printing/cloud_print/gcd_constants.h"
10 #include "chrome/browser/printing/cloud_print/privet_constants.h" 10 #include "chrome/browser/printing/cloud_print/privet_constants.h"
11 #include "chrome/common/cloud_print/cloud_print_constants.h" 11 #include "chrome/common/cloud_print/cloud_print_constants.h"
12 #include "components/cloud_devices/common/cloud_devices_urls.h" 12 #include "components/cloud_devices/common/cloud_devices_urls.h"
13 #include "net/base/url_util.h" 13 #include "net/base/url_util.h"
14 14
15 namespace cloud_print { 15 namespace cloud_print {
16 16
17 namespace {
18
19 GURL GetConfirmFlowUrl(const std::string& token) {
20 return net::AppendQueryParameter(
21 cloud_devices::GetCloudPrintRelativeURL("confirm"), "token", token);
22 }
23
24 } // namespace
25
26 PrivetConfirmApiCallFlow::PrivetConfirmApiCallFlow( 17 PrivetConfirmApiCallFlow::PrivetConfirmApiCallFlow(
27 const std::string& token, 18 const std::string& token,
28 const ResponseCallback& callback) 19 const ResponseCallback& callback)
29 : callback_(callback), token_(token) { 20 : callback_(callback), token_(token) {
30 } 21 }
31 22
32 PrivetConfirmApiCallFlow::~PrivetConfirmApiCallFlow() { 23 PrivetConfirmApiCallFlow::~PrivetConfirmApiCallFlow() {
33 } 24 }
34 25
35 void PrivetConfirmApiCallFlow::OnGCDApiFlowError(GCDApiFlow::Status status) { 26 void PrivetConfirmApiCallFlow::OnGCDApiFlowError(GCDApiFlow::Status status) {
36 callback_.Run(status); 27 callback_.Run(status);
37 } 28 }
38 29
39 void PrivetConfirmApiCallFlow::OnGCDApiFlowComplete( 30 void PrivetConfirmApiCallFlow::OnGCDApiFlowComplete(
40 const base::DictionaryValue& value) { 31 const base::DictionaryValue& value) {
41 bool success = false; 32 bool success = false;
42
43 if (!value.GetBoolean(cloud_print::kSuccessValue, &success)) { 33 if (!value.GetBoolean(cloud_print::kSuccessValue, &success)) {
44 callback_.Run(GCDApiFlow::ERROR_MALFORMED_RESPONSE); 34 callback_.Run(GCDApiFlow::ERROR_MALFORMED_RESPONSE);
45 return; 35 return;
46 } 36 }
47 37
48 if (success) { 38 callback_.Run(success ? GCDApiFlow::SUCCESS : GCDApiFlow::ERROR_FROM_SERVER);
49 callback_.Run(GCDApiFlow::SUCCESS);
50 } else {
51 callback_.Run(GCDApiFlow::ERROR_FROM_SERVER);
52 }
53 } 39 }
54 40
55 net::URLFetcher::RequestType PrivetConfirmApiCallFlow::GetRequestType() { 41 net::URLFetcher::RequestType PrivetConfirmApiCallFlow::GetRequestType() {
56 return net::URLFetcher::GET; 42 return net::URLFetcher::GET;
57 } 43 }
58 44
59 GURL PrivetConfirmApiCallFlow::GetURL() { 45 GURL PrivetConfirmApiCallFlow::GetURL() {
60 return GetConfirmFlowUrl(token_); 46 return net::AppendQueryParameter(
47 cloud_devices::GetCloudPrintRelativeURL("confirm"), "token", token_);
61 } 48 }
62 49
63 } // namespace cloud_print 50 } // namespace cloud_print
OLDNEW
« no previous file with comments | « chrome/browser/printing/cloud_print/privet_confirm_api_flow.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698