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 #include "chrome/browser/signin/android_profile_oauth2_token_service.h" | 5 #include "chrome/browser/signin/android_profile_oauth2_token_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "chrome/browser/sync/profile_sync_service_android.h" | 8 #include "chrome/browser/sync/profile_sync_service_android.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "net/url_request/url_request_context_getter.h" | 10 #include "net/url_request/url_request_context_getter.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 if (HasCacheEntry(scopes)) | 26 if (HasCacheEntry(scopes)) |
27 return StartCacheLookupRequest(scopes, consumer); | 27 return StartCacheLookupRequest(scopes, consumer); |
28 | 28 |
29 scoped_ptr<RequestImpl> request(new RequestImpl(consumer)); | 29 scoped_ptr<RequestImpl> request(new RequestImpl(consumer)); |
30 DCHECK_EQ(scopes.size(), 1U); | 30 DCHECK_EQ(scopes.size(), 1U); |
31 std::vector<std::string> scope_list(scopes.begin(), scopes.end()); | 31 std::vector<std::string> scope_list(scopes.begin(), scopes.end()); |
32 ProfileSyncServiceAndroid* sync_service = | 32 ProfileSyncServiceAndroid* sync_service = |
33 ProfileSyncServiceAndroid::GetProfileSyncServiceAndroid(); | 33 ProfileSyncServiceAndroid::GetProfileSyncServiceAndroid(); |
34 sync_service->FetchOAuth2Token( | 34 sync_service->FetchOAuth2Token( |
35 scope_list.front(), | 35 scope_list.front(), |
36 base::Bind(&OAuth2TokenService::InformConsumer, | 36 base::Bind(&RequestImpl::InformConsumer, |
37 request->AsWeakPtr())); | 37 request->AsWeakPtr())); |
38 return request.PassAs<Request>(); | 38 return request.PassAs<Request>(); |
39 } | 39 } |
40 | 40 |
41 void AndroidProfileOAuth2TokenService::InvalidateToken( | 41 void AndroidProfileOAuth2TokenService::InvalidateToken( |
42 const ScopeSet& scopes, | 42 const ScopeSet& scopes, |
43 const std::string& invalid_token) { | 43 const std::string& invalid_token) { |
44 OAuth2TokenService::InvalidateToken(scopes, invalid_token); | 44 OAuth2TokenService::InvalidateToken(scopes, invalid_token); |
45 | 45 |
46 DCHECK_EQ(scopes.size(), 1U); | 46 DCHECK_EQ(scopes.size(), 1U); |
47 std::vector<std::string> scope_list(scopes.begin(), scopes.end()); | 47 std::vector<std::string> scope_list(scopes.begin(), scopes.end()); |
48 ProfileSyncServiceAndroid* sync_service = | 48 ProfileSyncServiceAndroid* sync_service = |
49 ProfileSyncServiceAndroid::GetProfileSyncServiceAndroid(); | 49 ProfileSyncServiceAndroid::GetProfileSyncServiceAndroid(); |
50 sync_service->InvalidateOAuth2Token( | 50 sync_service->InvalidateOAuth2Token( |
51 scope_list.front(), | 51 scope_list.front(), |
52 invalid_token); | 52 invalid_token); |
53 } | 53 } |
54 | 54 |
55 bool AndroidProfileOAuth2TokenService::ShouldCacheForRefreshToken( | 55 bool AndroidProfileOAuth2TokenService::ShouldCacheForRefreshToken( |
56 TokenService *token_service, | 56 TokenService *token_service, |
57 const std::string& refresh_token) { | 57 const std::string& refresh_token) { |
58 // The parent class skips caching if the TokenService login token is stale, | 58 // The parent class skips caching if the TokenService login token is stale, |
59 // but on Android the user is always logged in to exactly one profile, so | 59 // but on Android the user is always logged in to exactly one profile, so |
60 // this concept doesn't exist and we can simply always cache. | 60 // this concept doesn't exist and we can simply always cache. |
61 return true; | 61 return true; |
62 } | 62 } |
OLD | NEW |