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 #include "extensions/browser/updater/extension_downloader.h" | 5 #include "extensions/browser/updater/extension_downloader.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 return true; | 907 return true; |
908 case ExtensionFetch::CREDENTIALS_OAUTH2_TOKEN: | 908 case ExtensionFetch::CREDENTIALS_OAUTH2_TOKEN: |
909 fetch->oauth2_attempt_count++; | 909 fetch->oauth2_attempt_count++; |
910 // OAuth2 may fail due to an expired access token, in which case we | 910 // OAuth2 may fail due to an expired access token, in which case we |
911 // should invalidate the token and try again. | 911 // should invalidate the token and try again. |
912 if (response_code == net::HTTP_UNAUTHORIZED && | 912 if (response_code == net::HTTP_UNAUTHORIZED && |
913 fetch->oauth2_attempt_count <= kMaxOAuth2Attempts) { | 913 fetch->oauth2_attempt_count <= kMaxOAuth2Attempts) { |
914 DCHECK(identity_provider_.get()); | 914 DCHECK(identity_provider_.get()); |
915 OAuth2TokenService::ScopeSet webstore_scopes; | 915 OAuth2TokenService::ScopeSet webstore_scopes; |
916 webstore_scopes.insert(kWebstoreOAuth2Scope); | 916 webstore_scopes.insert(kWebstoreOAuth2Scope); |
917 identity_provider_->GetTokenService()->InvalidateToken( | 917 identity_provider_->GetTokenService()->InvalidateAccessToken( |
918 identity_provider_->GetActiveAccountId(), | 918 identity_provider_->GetActiveAccountId(), webstore_scopes, |
919 webstore_scopes, | |
920 access_token_); | 919 access_token_); |
921 access_token_.clear(); | 920 access_token_.clear(); |
922 return true; | 921 return true; |
923 } | 922 } |
924 // Either there is no Gaia identity available, the active identity | 923 // Either there is no Gaia identity available, the active identity |
925 // doesn't have access to this resource, or the server keeps returning | 924 // doesn't have access to this resource, or the server keeps returning |
926 // 401s and we've retried too many times. Fall back on cookies. | 925 // 401s and we've retried too many times. Fall back on cookies. |
927 if (access_token_.empty() || response_code == net::HTTP_FORBIDDEN || | 926 if (access_token_.empty() || response_code == net::HTTP_FORBIDDEN || |
928 fetch->oauth2_attempt_count > kMaxOAuth2Attempts) { | 927 fetch->oauth2_attempt_count > kMaxOAuth2Attempts) { |
929 fetch->credentials = ExtensionFetch::CREDENTIALS_COOKIES; | 928 fetch->credentials = ExtensionFetch::CREDENTIALS_COOKIES; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
968 const GURL& update_url, | 967 const GURL& update_url, |
969 int request_id) { | 968 int request_id) { |
970 ManifestFetchData::PingMode ping_mode = ManifestFetchData::NO_PING; | 969 ManifestFetchData::PingMode ping_mode = ManifestFetchData::NO_PING; |
971 if (update_url.DomainIs(ping_enabled_domain_.c_str())) | 970 if (update_url.DomainIs(ping_enabled_domain_.c_str())) |
972 ping_mode = ManifestFetchData::PING_WITH_ENABLED_STATE; | 971 ping_mode = ManifestFetchData::PING_WITH_ENABLED_STATE; |
973 return new ManifestFetchData( | 972 return new ManifestFetchData( |
974 update_url, request_id, brand_code_, manifest_query_params_, ping_mode); | 973 update_url, request_id, brand_code_, manifest_query_params_, ping_mode); |
975 } | 974 } |
976 | 975 |
977 } // namespace extensions | 976 } // namespace extensions |
OLD | NEW |