| 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 GOOGLE_APIS_GAIA_OAUTH2_MINT_TOKEN_FLOW_H_ | 5 #ifndef GOOGLE_APIS_GAIA_OAUTH2_MINT_TOKEN_FLOW_H_ |
| 6 #define GOOGLE_APIS_GAIA_OAUTH2_MINT_TOKEN_FLOW_H_ | 6 #define GOOGLE_APIS_GAIA_OAUTH2_MINT_TOKEN_FLOW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 std::string login_refresh_token; | 84 std::string login_refresh_token; |
| 85 std::string extension_id; | 85 std::string extension_id; |
| 86 std::string client_id; | 86 std::string client_id; |
| 87 std::vector<std::string> scopes; | 87 std::vector<std::string> scopes; |
| 88 Mode mode; | 88 Mode mode; |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 class Delegate { | 91 class Delegate { |
| 92 public: | 92 public: |
| 93 virtual void OnMintTokenSuccess(const std::string& access_token) {} | 93 virtual void OnMintTokenSuccess(const std::string& access_token, |
| 94 int time_to_live) {} |
| 94 virtual void OnIssueAdviceSuccess(const IssueAdviceInfo& issue_advice) {} | 95 virtual void OnIssueAdviceSuccess(const IssueAdviceInfo& issue_advice) {} |
| 95 virtual void OnMintTokenFailure(const GoogleServiceAuthError& error) {} | 96 virtual void OnMintTokenFailure(const GoogleServiceAuthError& error) {} |
| 96 | 97 |
| 97 protected: | 98 protected: |
| 98 virtual ~Delegate() {} | 99 virtual ~Delegate() {} |
| 99 }; | 100 }; |
| 100 | 101 |
| 101 OAuth2MintTokenFlow(net::URLRequestContextGetter* context, | 102 OAuth2MintTokenFlow(net::URLRequestContextGetter* context, |
| 102 Delegate* delegate, | 103 Delegate* delegate, |
| 103 const Parameters& parameters); | 104 const Parameters& parameters); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 119 private: | 120 private: |
| 120 friend class OAuth2MintTokenFlowTest; | 121 friend class OAuth2MintTokenFlowTest; |
| 121 FRIEND_TEST_ALL_PREFIXES(OAuth2MintTokenFlowTest, CreateApiCallBody); | 122 FRIEND_TEST_ALL_PREFIXES(OAuth2MintTokenFlowTest, CreateApiCallBody); |
| 122 FRIEND_TEST_ALL_PREFIXES(OAuth2MintTokenFlowTest, ParseIssueAdviceResponse); | 123 FRIEND_TEST_ALL_PREFIXES(OAuth2MintTokenFlowTest, ParseIssueAdviceResponse); |
| 123 FRIEND_TEST_ALL_PREFIXES(OAuth2MintTokenFlowTest, ParseMintTokenResponse); | 124 FRIEND_TEST_ALL_PREFIXES(OAuth2MintTokenFlowTest, ParseMintTokenResponse); |
| 124 FRIEND_TEST_ALL_PREFIXES(OAuth2MintTokenFlowTest, ProcessApiCallSuccess); | 125 FRIEND_TEST_ALL_PREFIXES(OAuth2MintTokenFlowTest, ProcessApiCallSuccess); |
| 125 FRIEND_TEST_ALL_PREFIXES(OAuth2MintTokenFlowTest, ProcessApiCallFailure); | 126 FRIEND_TEST_ALL_PREFIXES(OAuth2MintTokenFlowTest, ProcessApiCallFailure); |
| 126 FRIEND_TEST_ALL_PREFIXES(OAuth2MintTokenFlowTest, | 127 FRIEND_TEST_ALL_PREFIXES(OAuth2MintTokenFlowTest, |
| 127 ProcessMintAccessTokenFailure); | 128 ProcessMintAccessTokenFailure); |
| 128 | 129 |
| 129 void ReportSuccess(const std::string& access_token); | 130 void ReportSuccess(const std::string& access_token, int time_to_live); |
| 130 void ReportIssueAdviceSuccess(const IssueAdviceInfo& issue_advice); | 131 void ReportIssueAdviceSuccess(const IssueAdviceInfo& issue_advice); |
| 131 void ReportFailure(const GoogleServiceAuthError& error); | 132 void ReportFailure(const GoogleServiceAuthError& error); |
| 132 | 133 |
| 133 static bool ParseIssueAdviceResponse( | 134 static bool ParseIssueAdviceResponse( |
| 134 const base::DictionaryValue* dict, IssueAdviceInfo* issue_advice); | 135 const base::DictionaryValue* dict, IssueAdviceInfo* issue_advice); |
| 135 static bool ParseMintTokenResponse( | 136 static bool ParseMintTokenResponse( |
| 136 const base::DictionaryValue* dict, std::string* access_token); | 137 const base::DictionaryValue* dict, std::string* access_token, |
| 138 int* time_to_live); |
| 137 | 139 |
| 138 Delegate* delegate_; | 140 Delegate* delegate_; |
| 139 Parameters parameters_; | 141 Parameters parameters_; |
| 140 base::WeakPtrFactory<OAuth2MintTokenFlow> weak_factory_; | 142 base::WeakPtrFactory<OAuth2MintTokenFlow> weak_factory_; |
| 141 | 143 |
| 142 DISALLOW_COPY_AND_ASSIGN(OAuth2MintTokenFlow); | 144 DISALLOW_COPY_AND_ASSIGN(OAuth2MintTokenFlow); |
| 143 }; | 145 }; |
| 144 | 146 |
| 145 #endif // GOOGLE_APIS_GAIA_OAUTH2_MINT_TOKEN_FLOW_H_ | 147 #endif // GOOGLE_APIS_GAIA_OAUTH2_MINT_TOKEN_FLOW_H_ |
| OLD | NEW |