OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_COMMON_NET_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ | 5 #ifndef CHROME_COMMON_NET_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ |
6 #define CHROME_COMMON_NET_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ | 6 #define CHROME_COMMON_NET_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 OAuth2AccessTokenFetcher(OAuth2AccessTokenConsumer* consumer, | 45 OAuth2AccessTokenFetcher(OAuth2AccessTokenConsumer* consumer, |
46 net::URLRequestContextGetter* getter); | 46 net::URLRequestContextGetter* getter); |
47 virtual ~OAuth2AccessTokenFetcher(); | 47 virtual ~OAuth2AccessTokenFetcher(); |
48 | 48 |
49 // Starts the flow with the given parameters. | 49 // Starts the flow with the given parameters. |
50 // |scopes| can be empty. If it is empty then the access token will have the | 50 // |scopes| can be empty. If it is empty then the access token will have the |
51 // same scope as the refresh token. If not empty, then access token will have | 51 // same scope as the refresh token. If not empty, then access token will have |
52 // the scopes specified. In this case, the access token will successfully be | 52 // the scopes specified. In this case, the access token will successfully be |
53 // generated only if refresh token has login scope of a list of scopes that is | 53 // generated only if refresh token has login scope of a list of scopes that is |
54 // a super-set of the specified scopes. | 54 // a super-set of the specified scopes. |
55 void Start(const std::string& client_id, | 55 virtual void Start(const std::string& client_id, |
56 const std::string& client_secret, | 56 const std::string& client_secret, |
57 const std::string& refresh_token, | 57 const std::string& refresh_token, |
58 const std::vector<std::string>& scopes); | 58 const std::vector<std::string>& scopes); |
59 | 59 |
60 void CancelRequest(); | 60 void CancelRequest(); |
61 | 61 |
62 // Implementation of content::URLFetcherDelegate | 62 // Implementation of content::URLFetcherDelegate |
63 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; | 63 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; |
64 | 64 |
65 private: | 65 private: |
66 enum State { | 66 enum State { |
67 INITIAL, | 67 INITIAL, |
68 GET_ACCESS_TOKEN_STARTED, | 68 GET_ACCESS_TOKEN_STARTED, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 friend class OAuth2AccessTokenFetcherTest; | 103 friend class OAuth2AccessTokenFetcherTest; |
104 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, | 104 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, |
105 ParseGetAccessTokenResponse); | 105 ParseGetAccessTokenResponse); |
106 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, | 106 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, |
107 MakeGetAccessTokenBody); | 107 MakeGetAccessTokenBody); |
108 | 108 |
109 DISALLOW_COPY_AND_ASSIGN(OAuth2AccessTokenFetcher); | 109 DISALLOW_COPY_AND_ASSIGN(OAuth2AccessTokenFetcher); |
110 }; | 110 }; |
111 | 111 |
112 #endif // CHROME_COMMON_NET_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ | 112 #endif // CHROME_COMMON_NET_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ |
OLD | NEW |