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

Side by Side Diff: chrome/browser/chromeos/login/oauth2_login_manager.cc

Issue 12330008: Get rid of the ability to unregister preferences. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit. Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/chromeos/login/oauth2_login_manager.h" 5 #include "chrome/browser/chromeos/login/oauth2_login_manager.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/chromeos/login/user_manager.h" 11 #include "chrome/browser/chromeos/login/user_manager.h"
12 #include "chrome/browser/policy/browser_policy_connector.h" 12 #include "chrome/browser/policy/browser_policy_connector.h"
13 #include "chrome/browser/prefs/pref_registry_syncable.h" 13 #include "chrome/browser/prefs/pref_registry_syncable.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/signin/token_service.h" 15 #include "chrome/browser/signin/token_service.h"
16 #include "chrome/browser/signin/token_service_factory.h" 16 #include "chrome/browser/signin/token_service_factory.h"
17 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
18 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
20 #include "google_apis/gaia/gaia_constants.h" 20 #include "google_apis/gaia/gaia_constants.h"
21 #include "net/url_request/url_request_context_getter.h" 21 #include "net/url_request/url_request_context_getter.h"
22 22
23 namespace {
24
25 // Prefs registered only for migration purposes.
26 const char kOAuth1Token[] = "settings.account.oauth1_token";
27 const char kOAuth1Secret[] = "settings.account.oauth1_secret";
28
29 } // namespace
30
23 namespace chromeos { 31 namespace chromeos {
24 32
25 OAuth2LoginManager::OAuth2LoginManager(OAuthLoginManager::Delegate* delegate) 33 OAuth2LoginManager::OAuth2LoginManager(OAuthLoginManager::Delegate* delegate)
26 : OAuthLoginManager(delegate), 34 : OAuthLoginManager(delegate),
27 loading_reported_(false) { 35 loading_reported_(false) {
28 } 36 }
29 37
30 OAuth2LoginManager::~OAuth2LoginManager() { 38 OAuth2LoginManager::~OAuth2LoginManager() {
31 } 39 }
32 40
41 void OAuth2LoginManager::RegisterUserPrefs(PrefRegistrySyncable* registry) {
42 registry->RegisterStringPref(kOAuth1Token,
43 "",
44 PrefRegistrySyncable::UNSYNCABLE_PREF);
45 registry->RegisterStringPref(kOAuth1Secret,
46 "",
47 PrefRegistrySyncable::UNSYNCABLE_PREF);
48 }
49
33 void OAuth2LoginManager::RestoreSession( 50 void OAuth2LoginManager::RestoreSession(
34 Profile* user_profile, 51 Profile* user_profile,
35 net::URLRequestContextGetter* auth_request_context, 52 net::URLRequestContextGetter* auth_request_context,
36 bool restore_from_auth_cookies) { 53 bool restore_from_auth_cookies) {
37 user_profile_ = user_profile; 54 user_profile_ = user_profile;
38 auth_request_context_ = auth_request_context; 55 auth_request_context_ = auth_request_context;
39 state_ = OAuthLoginManager::SESSION_RESTORE_IN_PROGRESS; 56 state_ = OAuthLoginManager::SESSION_RESTORE_IN_PROGRESS;
40 restore_from_auth_cookies_ = restore_from_auth_cookies; 57 restore_from_auth_cookies_ = restore_from_auth_cookies;
41 58
42 // TODO(zelidrag): Remove eventually the next line in some future milestone. 59 // TODO(zelidrag): Remove eventually the next line in some future milestone.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 content::Source<TokenService>(token_service)); 103 content::Source<TokenService>(token_service));
87 registrar_.Add(this, 104 registrar_.Add(this,
88 chrome::NOTIFICATION_TOKEN_AVAILABLE, 105 chrome::NOTIFICATION_TOKEN_AVAILABLE,
89 content::Source<TokenService>(token_service)); 106 content::Source<TokenService>(token_service));
90 } 107 }
91 return token_service; 108 return token_service;
92 } 109 }
93 110
94 void OAuth2LoginManager::RemoveLegacyTokens() { 111 void OAuth2LoginManager::RemoveLegacyTokens() {
95 PrefService* prefs = user_profile_->GetPrefs(); 112 PrefService* prefs = user_profile_->GetPrefs();
96 // TODO(joi): Handle migration more elegantly. 113 prefs->ClearPref(kOAuth1Token);
97 scoped_refptr<PrefRegistrySyncable> registry( 114 prefs->ClearPref(kOAuth1Secret);
98 static_cast<PrefRegistrySyncable*>(prefs->DeprecatedGetPrefRegistry()));
99 registry->RegisterStringPref(prefs::kOAuth1Token,
100 "",
101 PrefRegistrySyncable::UNSYNCABLE_PREF);
102 registry->RegisterStringPref(prefs::kOAuth1Secret,
103 "",
104 PrefRegistrySyncable::UNSYNCABLE_PREF);
105 prefs->ClearPref(prefs::kOAuth1Token);
106 prefs->ClearPref(prefs::kOAuth1Secret);
107 registry->DeprecatedUnregisterPreference(prefs::kOAuth1Token);
108 registry->DeprecatedUnregisterPreference(prefs::kOAuth1Secret);
109 } 115 }
110 116
111 void OAuth2LoginManager::StoreOAuth2Tokens( 117 void OAuth2LoginManager::StoreOAuth2Tokens(
112 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) { 118 const GaiaAuthConsumer::ClientOAuthResult& oauth2_tokens) {
113 TokenService* token_service = SetupTokenService(); 119 TokenService* token_service = SetupTokenService();
114 token_service->UpdateCredentialsWithOAuth2(oauth2_tokens); 120 token_service->UpdateCredentialsWithOAuth2(oauth2_tokens);
115 } 121 }
116 122
117 void OAuth2LoginManager::LoadAndVerifyOAuth2Tokens() { 123 void OAuth2LoginManager::LoadAndVerifyOAuth2Tokens() {
118 // If we have no cookies, try to load saved OAuth2 token from TokenService. 124 // If we have no cookies, try to load saved OAuth2 token from TokenService.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } 264 }
259 265
260 void OAuth2LoginManager::StartTokenService( 266 void OAuth2LoginManager::StartTokenService(
261 const GaiaAuthConsumer::ClientLoginResult& gaia_credentials) { 267 const GaiaAuthConsumer::ClientLoginResult& gaia_credentials) {
262 TokenService* token_service = SetupTokenService(); 268 TokenService* token_service = SetupTokenService();
263 token_service->UpdateCredentials(gaia_credentials); 269 token_service->UpdateCredentials(gaia_credentials);
264 CompleteAuthentication(); 270 CompleteAuthentication();
265 } 271 }
266 272
267 } // namespace chromeos 273 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/oauth2_login_manager.h ('k') | chrome/browser/prefs/browser_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698