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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_GCD_API_FLOW_H_
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_GCD_API_FLOW_H_
10 #include "google_apis/gaia/oauth2_token_service.h"
11 #include "net/url_request/url_fetcher.h"
12 #include "net/url_request/url_request_context_getter.h"
14 namespace local_discovery
{
16 // API flow for communicating with cloud print and cloud devices.
19 // TODO(noamsml): Better error model for this class.
26 ERROR_MALFORMED_RESPONSE
29 // Provides GCDApiFlowImpl with parameters required to make request.
30 // Parses results of requests.
36 virtual void OnGCDAPIFlowError(Status status
) = 0;
38 virtual void OnGCDAPIFlowComplete(const base::DictionaryValue
& value
) = 0;
40 virtual GURL
GetURL() = 0;
42 virtual std::string
GetOAuthScope() = 0;
44 virtual net::URLFetcher::RequestType
GetRequestType();
46 virtual std::vector
<std::string
> GetExtraRequestHeaders() = 0;
48 // If there is no data, set upload_type and upload_data to ""
49 virtual void GetUploadData(std::string
* upload_type
,
50 std::string
* upload_data
);
53 DISALLOW_COPY_AND_ASSIGN(Request
);
57 virtual ~GCDApiFlow();
59 static scoped_ptr
<GCDApiFlow
> Create(
60 net::URLRequestContextGetter
* request_context
,
61 OAuth2TokenService
* token_service
,
62 const std::string
& account_id
);
64 virtual void Start(scoped_ptr
<Request
> request
) = 0;
67 DISALLOW_COPY_AND_ASSIGN(GCDApiFlow
);
70 class GCDApiFlowRequest
: public GCDApiFlow::Request
{
73 ~GCDApiFlowRequest() override
;
75 // GCDApiFlowRequest implementation
76 std::string
GetOAuthScope() override
;
77 std::vector
<std::string
> GetExtraRequestHeaders() override
;
80 DISALLOW_COPY_AND_ASSIGN(GCDApiFlowRequest
);
83 class CloudPrintApiFlowRequest
: public GCDApiFlow::Request
{
85 CloudPrintApiFlowRequest();
86 ~CloudPrintApiFlowRequest() override
;
88 // GCDApiFlowRequest implementation
89 std::string
GetOAuthScope() override
;
90 std::vector
<std::string
> GetExtraRequestHeaders() override
;
93 DISALLOW_COPY_AND_ASSIGN(CloudPrintApiFlowRequest
);
96 } // namespace local_discovery
98 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_GCD_API_FLOW_H_