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