Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: chrome/browser/sync/profile_sync_service.cc

Issue 15780020: Setup Sync to use OAuth token for managed users. (Closed) Base URL: http://git.chromium.org/chromium/src.git@issue226464a
Patch Set: review Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 "https://clients4.google.com/chrome-sync/dev"; 112 "https://clients4.google.com/chrome-sync/dev";
113 113
114 static const int kSyncClearDataTimeoutInSeconds = 60; // 1 minute. 114 static const int kSyncClearDataTimeoutInSeconds = 60; // 1 minute.
115 115
116 static const char* kOAuth2Scopes[] = { 116 static const char* kOAuth2Scopes[] = {
117 GaiaConstants::kChromeSyncOAuth2Scope, 117 GaiaConstants::kChromeSyncOAuth2Scope,
118 // GoogleTalk scope is needed for notifications. 118 // GoogleTalk scope is needed for notifications.
119 GaiaConstants::kGoogleTalkOAuth2Scope 119 GaiaConstants::kGoogleTalkOAuth2Scope
120 }; 120 };
121 121
122 static const char* kManagedOAuth2Scopes[] = {
123 GaiaConstants::kChromeSyncManagedOAuth2Scope
124 };
122 125
123 static const char* kSyncUnrecoverableErrorHistogram = 126 static const char* kSyncUnrecoverableErrorHistogram =
124 "Sync.UnrecoverableErrors"; 127 "Sync.UnrecoverableErrors";
125 128
126 const net::BackoffEntry::Policy kRequestAccessTokenBackoffPolicy = { 129 const net::BackoffEntry::Policy kRequestAccessTokenBackoffPolicy = {
127 // Number of initial errors (in sequence) to ignore before applying 130 // Number of initial errors (in sequence) to ignore before applying
128 // exponential back-off rules. 131 // exponential back-off rules.
129 0, 132 0,
130 133
131 // Initial delay for exponential back-off in ms. 134 // Initial delay for exponential back-off in ms.
(...skipping 1757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 if (!IsUsingSecondaryPassphrase()) 1892 if (!IsUsingSecondaryPassphrase())
1890 SetEncryptionPassphrase(passphrase, IMPLICIT); 1893 SetEncryptionPassphrase(passphrase, IMPLICIT);
1891 } 1894 }
1892 1895
1893 void ProfileSyncService::RequestAccessToken() { 1896 void ProfileSyncService::RequestAccessToken() {
1894 // Only one active request at a time. 1897 // Only one active request at a time.
1895 if (access_token_request_ != NULL) 1898 if (access_token_request_ != NULL)
1896 return; 1899 return;
1897 request_access_token_retry_timer_.Stop(); 1900 request_access_token_retry_timer_.Stop();
1898 OAuth2TokenService::ScopeSet oauth2_scopes; 1901 OAuth2TokenService::ScopeSet oauth2_scopes;
1899 for (size_t i = 0; i < arraysize(kOAuth2Scopes); i++) 1902 if (ManagedUserService::ProfileIsManaged(profile_)) {
1900 oauth2_scopes.insert(kOAuth2Scopes[i]); 1903 for (size_t i = 0; i < arraysize(kManagedOAuth2Scopes); i++)
1904 oauth2_scopes.insert(kManagedOAuth2Scopes[i]);
1905 } else {
1906 for (size_t i = 0; i < arraysize(kOAuth2Scopes); i++)
1907 oauth2_scopes.insert(kOAuth2Scopes[i]);
1908 }
1909
1901 OAuth2TokenService* token_service = 1910 OAuth2TokenService* token_service =
1902 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); 1911 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
1903 // Invalidate previous token, otherwise token service will return the same 1912 // Invalidate previous token, otherwise token service will return the same
1904 // token again. 1913 // token again.
1905 token_service->InvalidateToken(oauth2_scopes, access_token_); 1914 token_service->InvalidateToken(oauth2_scopes, access_token_);
1906 access_token_.clear(); 1915 access_token_.clear();
1907 access_token_request_ = token_service->StartRequest(oauth2_scopes, this); 1916 access_token_request_ = token_service->StartRequest(oauth2_scopes, this);
1908 } 1917 }
1909 1918
1910 void ProfileSyncService::SetEncryptionPassphrase(const std::string& passphrase, 1919 void ProfileSyncService::SetEncryptionPassphrase(const std::string& passphrase,
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 std::string ProfileSyncService::GetEffectiveUsername() { 2193 std::string ProfileSyncService::GetEffectiveUsername() {
2185 #if defined(ENABLE_MANAGED_USERS) 2194 #if defined(ENABLE_MANAGED_USERS)
2186 if (ManagedUserService::ProfileIsManaged(profile_)) { 2195 if (ManagedUserService::ProfileIsManaged(profile_)) {
2187 DCHECK_EQ(std::string(), signin_->GetAuthenticatedUsername()); 2196 DCHECK_EQ(std::string(), signin_->GetAuthenticatedUsername());
2188 return ManagedUserService::GetManagedUserPseudoEmail(); 2197 return ManagedUserService::GetManagedUserPseudoEmail();
2189 } 2198 }
2190 #endif 2199 #endif
2191 2200
2192 return signin_->GetAuthenticatedUsername(); 2201 return signin_->GetAuthenticatedUsername();
2193 } 2202 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698