| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_GCD_API_FLOW_IMPL_H_ | |
| 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_GCD_API_FLOW_IMPL_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "chrome/browser/local_discovery/gcd_api_flow.h" | |
| 10 #include "net/url_request/url_fetcher.h" | |
| 11 #include "net/url_request/url_fetcher_delegate.h" | |
| 12 | |
| 13 namespace local_discovery { | |
| 14 | |
| 15 namespace { | |
| 16 const char kCloudPrintOAuthHeaderFormat[] = "Authorization: Bearer %s"; | |
| 17 } | |
| 18 | |
| 19 class GCDApiFlowImpl : public GCDApiFlow, | |
| 20 public net::URLFetcherDelegate, | |
| 21 public OAuth2TokenService::Consumer { | |
| 22 public: | |
| 23 // Create an OAuth2-based confirmation. | |
| 24 GCDApiFlowImpl(net::URLRequestContextGetter* request_context, | |
| 25 OAuth2TokenService* token_service, | |
| 26 const std::string& account_id); | |
| 27 | |
| 28 ~GCDApiFlowImpl() override; | |
| 29 | |
| 30 void Start(scoped_ptr<Request> request) override; | |
| 31 | |
| 32 // net::URLFetcherDelegate implementation: | |
| 33 void OnURLFetchComplete(const net::URLFetcher* source) override; | |
| 34 | |
| 35 // OAuth2TokenService::Consumer implementation: | |
| 36 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | |
| 37 const std::string& access_token, | |
| 38 const base::Time& expiration_time) override; | |
| 39 void OnGetTokenFailure(const OAuth2TokenService::Request* request, | |
| 40 const GoogleServiceAuthError& error) override; | |
| 41 | |
| 42 private: | |
| 43 void CreateRequest(const GURL& url); | |
| 44 | |
| 45 scoped_ptr<net::URLFetcher> url_fetcher_; | |
| 46 scoped_ptr<OAuth2TokenService::Request> oauth_request_; | |
| 47 scoped_refptr<net::URLRequestContextGetter> request_context_; | |
| 48 OAuth2TokenService* token_service_; | |
| 49 std::string account_id_; | |
| 50 scoped_ptr<Request> request_; | |
| 51 | |
| 52 DISALLOW_COPY_AND_ASSIGN(GCDApiFlowImpl); | |
| 53 }; | |
| 54 | |
| 55 } // namespace local_discovery | |
| 56 | |
| 57 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_GCD_API_FLOW_IMPL_H_ | |
| OLD | NEW |