OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_CLOUD_PRINT_BASE_API_FLOW_H_ | 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_BASE_API_FLOW_H_ |
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_BASE_API_FLOW_H_ | 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_BASE_API_FLOW_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "chrome/browser/local_discovery/privet_constants.h" | 10 #include "chrome/browser/local_discovery/privet_constants.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // net::URLFetcherDelegate implementation: | 70 // net::URLFetcherDelegate implementation: |
71 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 71 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
72 | 72 |
73 // OAuth2TokenService::Consumer implementation: | 73 // OAuth2TokenService::Consumer implementation: |
74 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 74 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
75 const std::string& access_token, | 75 const std::string& access_token, |
76 const base::Time& expiration_time) OVERRIDE; | 76 const base::Time& expiration_time) OVERRIDE; |
77 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 77 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
78 const GoogleServiceAuthError& error) OVERRIDE; | 78 const GoogleServiceAuthError& error) OVERRIDE; |
79 | 79 |
| 80 // Return the user index or kAccountIndexUseOAuth2 if none is available. |
| 81 int user_index() { return user_index_; } |
| 82 |
80 private: | 83 private: |
81 bool UseOAuth2() { return token_service_ != NULL; } | 84 bool UseOAuth2() { return user_index_ == kAccountIndexUseOAuth2; } |
82 | 85 |
83 void CreateRequest(const GURL& url); | 86 void CreateRequest(const GURL& url); |
84 | 87 |
85 scoped_ptr<net::URLFetcher> url_fetcher_; | 88 scoped_ptr<net::URLFetcher> url_fetcher_; |
86 scoped_ptr<OAuth2TokenService::Request> oauth_request_; | 89 scoped_ptr<OAuth2TokenService::Request> oauth_request_; |
87 scoped_refptr<net::URLRequestContextGetter> request_context_; | 90 scoped_refptr<net::URLRequestContextGetter> request_context_; |
88 OAuth2TokenService* token_service_; | 91 OAuth2TokenService* token_service_; |
89 int user_index_; | 92 int user_index_; |
90 std::string xsrf_token_; | 93 std::string xsrf_token_; |
91 GURL url_; | 94 GURL url_; |
92 Delegate* delegate_; | 95 Delegate* delegate_; |
93 }; | 96 }; |
94 | 97 |
95 } // namespace local_discovery | 98 } // namespace local_discovery |
96 | 99 |
97 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_BASE_API_FLOW_H_ | 100 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_BASE_API_FLOW_H_ |
OLD | NEW |