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 #include "chrome/browser/supervised_user/supervised_user_refresh_token_fetcher.h
" | 5 #include "chrome/browser/supervised_user/supervised_user_refresh_token_fetcher.h
" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 SupervisedUserRefreshTokenFetcherImpl( | 58 SupervisedUserRefreshTokenFetcherImpl( |
59 OAuth2TokenService* oauth2_token_service, | 59 OAuth2TokenService* oauth2_token_service, |
60 const std::string& account_id, | 60 const std::string& account_id, |
61 const std::string& device_id, | 61 const std::string& device_id, |
62 URLRequestContextGetter* context); | 62 URLRequestContextGetter* context); |
63 virtual ~SupervisedUserRefreshTokenFetcherImpl(); | 63 virtual ~SupervisedUserRefreshTokenFetcherImpl(); |
64 | 64 |
65 // SupervisedUserRefreshTokenFetcher implementation: | 65 // SupervisedUserRefreshTokenFetcher implementation: |
66 virtual void Start(const std::string& supervised_user_id, | 66 virtual void Start(const std::string& supervised_user_id, |
67 const std::string& device_name, | 67 const std::string& device_name, |
68 const TokenCallback& callback) OVERRIDE; | 68 const TokenCallback& callback) override; |
69 | 69 |
70 protected: | 70 protected: |
71 // OAuth2TokenService::Consumer implementation: | 71 // OAuth2TokenService::Consumer implementation: |
72 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 72 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
73 const std::string& access_token, | 73 const std::string& access_token, |
74 const Time& expiration_time) OVERRIDE; | 74 const Time& expiration_time) override; |
75 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 75 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
76 const GoogleServiceAuthError& error) OVERRIDE; | 76 const GoogleServiceAuthError& error) override; |
77 | 77 |
78 // net::URLFetcherDelegate implementation. | 78 // net::URLFetcherDelegate implementation. |
79 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE; | 79 virtual void OnURLFetchComplete(const URLFetcher* source) override; |
80 | 80 |
81 // GaiaOAuthClient::Delegate implementation: | 81 // GaiaOAuthClient::Delegate implementation: |
82 virtual void OnGetTokensResponse(const std::string& refresh_token, | 82 virtual void OnGetTokensResponse(const std::string& refresh_token, |
83 const std::string& access_token, | 83 const std::string& access_token, |
84 int expires_in_seconds) OVERRIDE; | 84 int expires_in_seconds) override; |
85 virtual void OnRefreshTokenResponse(const std::string& access_token, | 85 virtual void OnRefreshTokenResponse(const std::string& access_token, |
86 int expires_in_seconds) OVERRIDE; | 86 int expires_in_seconds) override; |
87 virtual void OnOAuthError() OVERRIDE; | 87 virtual void OnOAuthError() override; |
88 virtual void OnNetworkError(int response_code) OVERRIDE; | 88 virtual void OnNetworkError(int response_code) override; |
89 | 89 |
90 private: | 90 private: |
91 // Requests an access token, which is the first thing we need. This is where | 91 // Requests an access token, which is the first thing we need. This is where |
92 // we restart when the returned access token has expired. | 92 // we restart when the returned access token has expired. |
93 void StartFetching(); | 93 void StartFetching(); |
94 | 94 |
95 void DispatchNetworkError(int error_code); | 95 void DispatchNetworkError(int error_code); |
96 void DispatchGoogleServiceAuthError(const GoogleServiceAuthError& error, | 96 void DispatchGoogleServiceAuthError(const GoogleServiceAuthError& error, |
97 const std::string& token); | 97 const std::string& token); |
98 OAuth2TokenService* oauth2_token_service_; | 98 OAuth2TokenService* oauth2_token_service_; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 URLRequestContextGetter* context) { | 294 URLRequestContextGetter* context) { |
295 scoped_ptr<SupervisedUserRefreshTokenFetcher> fetcher( | 295 scoped_ptr<SupervisedUserRefreshTokenFetcher> fetcher( |
296 new SupervisedUserRefreshTokenFetcherImpl(oauth2_token_service, | 296 new SupervisedUserRefreshTokenFetcherImpl(oauth2_token_service, |
297 account_id, | 297 account_id, |
298 device_id, | 298 device_id, |
299 context)); | 299 context)); |
300 return fetcher.Pass(); | 300 return fetcher.Pass(); |
301 } | 301 } |
302 | 302 |
303 SupervisedUserRefreshTokenFetcher::~SupervisedUserRefreshTokenFetcher() {} | 303 SupervisedUserRefreshTokenFetcher::~SupervisedUserRefreshTokenFetcher() {} |
OLD | NEW |