Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_CONFIRM_API_FLOW_H_ | |
| 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_CONFIRM_API_FLOW_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "chrome/browser/local_discovery/privet_http.h" | |
| 11 #include "chrome/browser/signin/oauth2_token_service.h" | |
| 12 #include "net/url_request/url_fetcher.h" | |
| 13 #include "net/url_request/url_fetcher_delegate.h" | |
| 14 #include "net/url_request/url_request_context_getter.h" | |
| 15 | |
| 16 namespace local_discovery { | |
| 17 | |
| 18 // API call flow for server-side communication with cloudprint for registration. | |
| 19 class PrivetConfirmApiCallFlow : public net::URLFetcherDelegate, | |
| 20 public OAuth2TokenService::Consumer { | |
| 21 public: | |
| 22 // TODO(noamsml): Better error model for this class. | |
| 23 enum Status { | |
| 24 SUCCESS, | |
| 25 ERROR_TOKEN, | |
| 26 ERROR_NETWORK, | |
| 27 ERROR_HTTP_CODE, | |
| 28 ERROR_FROM_SERVER, | |
| 29 ERROR_MALFORMED_RESPONSE | |
| 30 }; | |
| 31 typedef base::Callback<void(Status /*success*/)> | |
| 32 ResponseCallback; | |
|
gene
2013/07/22 10:32:50
fit on one line
Noam Samuel
2013/07/22 19:22:05
Done.
| |
| 33 | |
| 34 PrivetConfirmApiCallFlow(net::URLRequestContextGetter* request_context, | |
| 35 OAuth2TokenService* token_service_, | |
| 36 const GURL& automated_claim_url, | |
| 37 const ResponseCallback& callback); | |
| 38 virtual ~PrivetConfirmApiCallFlow(); | |
| 39 | |
| 40 void Start(); | |
| 41 | |
| 42 // net::URLFetcherDelegate implementation: | |
| 43 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | |
| 44 | |
| 45 // OAuth2TokenService::Consumer implementation: | |
| 46 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | |
| 47 const std::string& access_token, | |
| 48 const base::Time& expiration_time) OVERRIDE; | |
| 49 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | |
| 50 const GoogleServiceAuthError& error) OVERRIDE; | |
| 51 | |
| 52 private: | |
| 53 scoped_ptr<net::URLFetcher> url_fetcher_; | |
| 54 scoped_ptr<OAuth2TokenService::Request> oauth_request_; | |
| 55 scoped_refptr<net::URLRequestContextGetter> request_context_; | |
| 56 OAuth2TokenService* token_service_; | |
| 57 GURL automated_claim_url_; | |
| 58 ResponseCallback callback_; | |
| 59 }; | |
| 60 | |
| 61 } // namespace local_discovery | |
| 62 | |
| 63 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_CONFIRM_API_FLOW_H_ | |
| OLD | NEW |