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 "chrome/browser/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 "https://clients4.google.com/chrome-sync/dev"; | 113 "https://clients4.google.com/chrome-sync/dev"; |
114 | 114 |
115 static const int kSyncClearDataTimeoutInSeconds = 60; // 1 minute. | 115 static const int kSyncClearDataTimeoutInSeconds = 60; // 1 minute. |
116 | 116 |
117 static const char* kOAuth2Scopes[] = { | 117 static const char* kOAuth2Scopes[] = { |
118 GaiaConstants::kChromeSyncOAuth2Scope, | 118 GaiaConstants::kChromeSyncOAuth2Scope, |
119 // GoogleTalk scope is needed for notifications. | 119 // GoogleTalk scope is needed for notifications. |
120 GaiaConstants::kGoogleTalkOAuth2Scope | 120 GaiaConstants::kGoogleTalkOAuth2Scope |
121 }; | 121 }; |
122 | 122 |
123 static const char* kManagedOAuth2Scopes[] = { | |
124 GaiaConstants::kChromeSyncManagedOAuth2Scope | |
125 }; | |
123 | 126 |
124 static const char* kSyncUnrecoverableErrorHistogram = | 127 static const char* kSyncUnrecoverableErrorHistogram = |
125 "Sync.UnrecoverableErrors"; | 128 "Sync.UnrecoverableErrors"; |
126 | 129 |
127 const net::BackoffEntry::Policy kRequestAccessTokenBackoffPolicy = { | 130 const net::BackoffEntry::Policy kRequestAccessTokenBackoffPolicy = { |
128 // Number of initial errors (in sequence) to ignore before applying | 131 // Number of initial errors (in sequence) to ignore before applying |
129 // exponential back-off rules. | 132 // exponential back-off rules. |
130 0, | 133 0, |
131 | 134 |
132 // Initial delay for exponential back-off in ms. | 135 // Initial delay for exponential back-off in ms. |
(...skipping 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1916 if (!IsUsingSecondaryPassphrase()) | 1919 if (!IsUsingSecondaryPassphrase()) |
1917 SetEncryptionPassphrase(passphrase, IMPLICIT); | 1920 SetEncryptionPassphrase(passphrase, IMPLICIT); |
1918 } | 1921 } |
1919 | 1922 |
1920 void ProfileSyncService::RequestAccessToken() { | 1923 void ProfileSyncService::RequestAccessToken() { |
1921 // Only one active request at a time. | 1924 // Only one active request at a time. |
1922 if (access_token_request_ != NULL) | 1925 if (access_token_request_ != NULL) |
1923 return; | 1926 return; |
1924 request_access_token_retry_timer_.Stop(); | 1927 request_access_token_retry_timer_.Stop(); |
1925 OAuth2TokenService::ScopeSet oauth2_scopes; | 1928 OAuth2TokenService::ScopeSet oauth2_scopes; |
1926 for (size_t i = 0; i < arraysize(kOAuth2Scopes); i++) | 1929 if (ManagedUserService::ProfileIsManaged(profile_)) { |
1927 oauth2_scopes.insert(kOAuth2Scopes[i]); | 1930 for (size_t i = 0; i < arraysize(kManagedOAuth2Scopes); i++) |
1931 oauth2_scopes.insert(kManagedOAuth2Scopes[i]); | |
1932 } else { | |
1933 for (size_t i = 0; i < arraysize(kOAuth2Scopes); i++) | |
1934 oauth2_scopes.insert(kOAuth2Scopes[i]); | |
1935 } | |
1936 | |
pavely
2013/06/17 22:36:31
Currently access token is passed to both sync serv
Bernhard Bauer
2013/06/18 13:44:35
Hm, true. I did notice this when testing and worke
| |
1928 OAuth2TokenService* token_service = | 1937 OAuth2TokenService* token_service = |
1929 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | 1938 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
1930 // Invalidate previous token, otherwise token service will return the same | 1939 // Invalidate previous token, otherwise token service will return the same |
1931 // token again. | 1940 // token again. |
1932 token_service->InvalidateToken(oauth2_scopes, access_token_); | 1941 token_service->InvalidateToken(oauth2_scopes, access_token_); |
1933 access_token_.clear(); | 1942 access_token_.clear(); |
1934 access_token_request_ = token_service->StartRequest(oauth2_scopes, this); | 1943 access_token_request_ = token_service->StartRequest(oauth2_scopes, this); |
1935 } | 1944 } |
1936 | 1945 |
1937 void ProfileSyncService::SetEncryptionPassphrase(const std::string& passphrase, | 1946 void ProfileSyncService::SetEncryptionPassphrase(const std::string& passphrase, |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2215 std::string ProfileSyncService::GetEffectiveUsername() { | 2224 std::string ProfileSyncService::GetEffectiveUsername() { |
2216 #if defined(ENABLE_MANAGED_USERS) | 2225 #if defined(ENABLE_MANAGED_USERS) |
2217 if (ManagedUserService::ProfileIsManaged(profile_)) { | 2226 if (ManagedUserService::ProfileIsManaged(profile_)) { |
2218 DCHECK_EQ(std::string(), signin_->GetAuthenticatedUsername()); | 2227 DCHECK_EQ(std::string(), signin_->GetAuthenticatedUsername()); |
2219 return ManagedUserService::GetManagedUserPseudoEmail(); | 2228 return ManagedUserService::GetManagedUserPseudoEmail(); |
2220 } | 2229 } |
2221 #endif | 2230 #endif |
2222 | 2231 |
2223 return signin_->GetAuthenticatedUsername(); | 2232 return signin_->GetAuthenticatedUsername(); |
2224 } | 2233 } |
OLD | NEW |