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
3 // found in the LICENSE file.
5 #include "base/values.h"
6 #include "chrome/browser/local_discovery/cloud_print_base_api_flow.h"
7 #include "chrome/browser/local_discovery/privet_confirm_api_flow.h"
8 #include "chrome/common/cloud_print/cloud_print_constants.h"
10 namespace local_discovery
{
12 PrivetConfirmApiCallFlow::PrivetConfirmApiCallFlow(
13 net::URLRequestContextGetter
* request_context
,
14 OAuth2TokenService
* token_service
,
15 const std::string
& account_id
,
16 const GURL
& automated_claim_url
,
17 const ResponseCallback
& callback
)
18 : flow_(request_context
,
26 PrivetConfirmApiCallFlow::PrivetConfirmApiCallFlow(
27 net::URLRequestContextGetter
* request_context
,
29 const std::string
& xsrf_token
,
30 const GURL
& automated_claim_url
,
31 const ResponseCallback
& callback
)
32 : flow_(request_context
,
40 PrivetConfirmApiCallFlow::~PrivetConfirmApiCallFlow() {
43 void PrivetConfirmApiCallFlow::Start() {
47 void PrivetConfirmApiCallFlow::OnCloudPrintAPIFlowError(
48 CloudPrintBaseApiFlow
* flow
,
49 CloudPrintBaseApiFlow::Status status
) {
50 callback_
.Run(status
);
53 void PrivetConfirmApiCallFlow::OnCloudPrintAPIFlowComplete(
54 CloudPrintBaseApiFlow
* flow
,
55 const base::DictionaryValue
* value
) {
58 if (!value
->GetBoolean(cloud_print::kSuccessValue
, &success
)) {
59 callback_
.Run(CloudPrintBaseApiFlow::ERROR_MALFORMED_RESPONSE
);
64 callback_
.Run(CloudPrintBaseApiFlow::SUCCESS
);
66 callback_
.Run(CloudPrintBaseApiFlow::ERROR_FROM_SERVER
);
70 } // namespace local_discovery