OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/signin/core/browser/account_tracker_service.h" | 5 #include "components/signin/core/browser/account_tracker_service.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
11 #include "base/prefs/scoped_user_pref_update.h" | 11 #include "base/prefs/scoped_user_pref_update.h" |
12 #include "base/profiler/scoped_tracker.h" | 12 #include "base/profiler/scoped_tracker.h" |
13 #include "base/strings/string_split.h" | |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
15 #include "components/signin/core/browser/refresh_token_annotation_request.h" | 16 #include "components/signin/core/browser/refresh_token_annotation_request.h" |
16 #include "components/signin/core/browser/signin_client.h" | 17 #include "components/signin/core/browser/signin_client.h" |
17 #include "components/signin/core/browser/signin_manager.h" | 18 #include "components/signin/core/browser/signin_manager.h" |
18 #include "components/signin/core/common/signin_pref_names.h" | 19 #include "components/signin/core/common/signin_pref_names.h" |
19 #include "components/signin/core/common/signin_switches.h" | 20 #include "components/signin/core/common/signin_switches.h" |
21 #include "google_apis/gaia/gaia_auth_consumer.h" | |
22 #include "google_apis/gaia/gaia_auth_fetcher.h" | |
20 #include "google_apis/gaia/gaia_auth_util.h" | 23 #include "google_apis/gaia/gaia_auth_util.h" |
21 #include "google_apis/gaia/gaia_constants.h" | 24 #include "google_apis/gaia/gaia_constants.h" |
22 #include "google_apis/gaia/gaia_oauth_client.h" | 25 #include "google_apis/gaia/gaia_oauth_client.h" |
23 #include "net/url_request/url_request_context_getter.h" | 26 #include "net/url_request/url_request_context_getter.h" |
24 | 27 |
25 namespace { | 28 namespace { |
26 | 29 |
27 const char kAccountKeyPath[] = "account_id"; | 30 const char kAccountKeyPath[] = "account_id"; |
28 const char kAccountEmailPath[] = "email"; | 31 const char kAccountEmailPath[] = "email"; |
29 const char kAccountGaiaPath[] = "gaia"; | 32 const char kAccountGaiaPath[] = "gaia"; |
30 const char kAccountHostedDomainPath[] = "hd"; | 33 const char kAccountHostedDomainPath[] = "hd"; |
31 const char kAccountFullNamePath[] = "full_name"; | 34 const char kAccountFullNamePath[] = "full_name"; |
32 const char kAccountGivenNamePath[] = "given_name"; | 35 const char kAccountGivenNamePath[] = "given_name"; |
33 const char kAccountLocalePath[] = "locale"; | 36 const char kAccountLocalePath[] = "locale"; |
37 const char kAccountServiceFlagsPath[] = "service_flags"; | |
34 | 38 |
35 const base::TimeDelta kRefreshFromTokenServiceDelay = | 39 const base::TimeDelta kRefreshFromTokenServiceDelay = |
36 base::TimeDelta::FromHours(24); | 40 base::TimeDelta::FromHours(24); |
37 | 41 |
38 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 42 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
39 // IsRefreshTokenDeviceIdExperimentEnabled is called from | 43 // IsRefreshTokenDeviceIdExperimentEnabled is called from |
40 // SendRefreshTokenAnnotationRequest only on desktop platforms. | 44 // SendRefreshTokenAnnotationRequest only on desktop platforms. |
41 bool IsRefreshTokenDeviceIdExperimentEnabled() { | 45 bool IsRefreshTokenDeviceIdExperimentEnabled() { |
42 const std::string group_name = | 46 const std::string group_name = |
43 base::FieldTrialList::FindFullName("RefreshTokenDeviceId"); | 47 base::FieldTrialList::FindFullName("RefreshTokenDeviceId"); |
44 return group_name == "Enabled"; | 48 return group_name == "Enabled"; |
45 } | 49 } |
46 #endif | 50 #endif |
47 } | 51 } |
48 | 52 |
49 // This must be a string which can never be a valid domain. | 53 // This must be a string which can never be a valid domain. |
50 const char AccountTrackerService::kNoHostedDomainFound[] = "NO_HOSTED_DOMAIN"; | 54 const char AccountTrackerService::kNoHostedDomainFound[] = "NO_HOSTED_DOMAIN"; |
51 | 55 |
52 class AccountInfoFetcher : public OAuth2TokenService::Consumer, | 56 class AccountInfoFetcher : public OAuth2TokenService::Consumer, |
53 public gaia::GaiaOAuthClient::Delegate { | 57 public gaia::GaiaOAuthClient::Delegate, |
58 public GaiaAuthConsumer { | |
54 public: | 59 public: |
55 AccountInfoFetcher(OAuth2TokenService* token_service, | 60 AccountInfoFetcher(OAuth2TokenService* token_service, |
56 net::URLRequestContextGetter* request_context_getter, | 61 net::URLRequestContextGetter* request_context_getter, |
57 AccountTrackerService* service, | 62 AccountTrackerService* service, |
58 const std::string& account_id); | 63 const std::string& account_id); |
59 ~AccountInfoFetcher() override; | 64 ~AccountInfoFetcher() override; |
60 | 65 |
61 const std::string& account_id() { return account_id_; } | 66 const std::string& account_id() { return account_id_; } |
62 | 67 |
63 void Start(); | 68 void Start(); |
69 void SendSuccessIfDoneFetching(); | |
64 | 70 |
65 // OAuth2TokenService::Consumer implementation. | 71 // OAuth2TokenService::Consumer implementation. |
66 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 72 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
67 const std::string& access_token, | 73 const std::string& access_token, |
68 const base::Time& expiration_time) override; | 74 const base::Time& expiration_time) override; |
69 void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 75 void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
70 const GoogleServiceAuthError& error) override; | 76 const GoogleServiceAuthError& error) override; |
71 | 77 |
72 // gaia::GaiaOAuthClient::Delegate implementation. | 78 // gaia::GaiaOAuthClient::Delegate implementation. |
73 void OnGetUserInfoResponse( | 79 void OnGetUserInfoResponse( |
74 scoped_ptr<base::DictionaryValue> user_info) override; | 80 scoped_ptr<base::DictionaryValue> user_info) override; |
75 void OnOAuthError() override; | 81 void OnOAuthError() override; |
76 void OnNetworkError(int response_code) override; | 82 void OnNetworkError(int response_code) override; |
77 | 83 |
84 // Overridden from GaiaAuthConsumer: | |
85 void OnClientLoginSuccess(const ClientLoginResult& result) override; | |
86 void OnClientLoginFailure(const GoogleServiceAuthError& error) override; | |
87 void OnGetUserInfoSuccess(const UserInfoMap& data) override; | |
88 void OnGetUserInfoFailure(const GoogleServiceAuthError& error) override; | |
89 | |
78 private: | 90 private: |
79 OAuth2TokenService* token_service_; | 91 OAuth2TokenService* token_service_; |
80 net::URLRequestContextGetter* request_context_getter_; | 92 net::URLRequestContextGetter* request_context_getter_; |
81 AccountTrackerService* service_; | 93 AccountTrackerService* service_; |
82 const std::string account_id_; | 94 const std::string account_id_; |
83 | 95 |
84 scoped_ptr<OAuth2TokenService::Request> login_token_request_; | 96 scoped_ptr<OAuth2TokenService::Request> login_token_request_; |
85 scoped_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_; | 97 scoped_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_; |
98 scoped_ptr<GaiaAuthFetcher> gaia_auth_fetcher_; | |
99 | |
100 scoped_ptr<base::DictionaryValue> fetched_user_info_; | |
101 scoped_ptr<std::vector<std::string> > fetched_service_flags_; | |
86 }; | 102 }; |
87 | 103 |
88 AccountInfoFetcher::AccountInfoFetcher( | 104 AccountInfoFetcher::AccountInfoFetcher( |
89 OAuth2TokenService* token_service, | 105 OAuth2TokenService* token_service, |
90 net::URLRequestContextGetter* request_context_getter, | 106 net::URLRequestContextGetter* request_context_getter, |
91 AccountTrackerService* service, | 107 AccountTrackerService* service, |
92 const std::string& account_id) | 108 const std::string& account_id) |
93 : OAuth2TokenService::Consumer("gaia_account_tracker"), | 109 : OAuth2TokenService::Consumer("gaia_account_tracker"), |
94 token_service_(token_service), | 110 token_service_(token_service), |
95 request_context_getter_(request_context_getter), | 111 request_context_getter_(request_context_getter), |
96 service_(service), | 112 service_(service), |
97 account_id_(account_id) { | 113 account_id_(account_id) { |
98 TRACE_EVENT_ASYNC_BEGIN1( | 114 TRACE_EVENT_ASYNC_BEGIN1( |
99 "AccountTrackerService", "AccountIdFetcher", this, | 115 "AccountTrackerService", "AccountIdFetcher", this, |
100 "account_id", account_id); | 116 "account_id", account_id); |
101 } | 117 } |
102 | 118 |
103 AccountInfoFetcher::~AccountInfoFetcher() { | 119 AccountInfoFetcher::~AccountInfoFetcher() { |
104 TRACE_EVENT_ASYNC_END0("AccountTrackerService", "AccountIdFetcher", this); | 120 TRACE_EVENT_ASYNC_END0("AccountTrackerService", "AccountIdFetcher", this); |
105 } | 121 } |
106 | 122 |
107 void AccountInfoFetcher::Start() { | 123 void AccountInfoFetcher::Start() { |
108 OAuth2TokenService::ScopeSet scopes; | 124 OAuth2TokenService::ScopeSet scopes; |
109 scopes.insert(GaiaConstants::kGoogleUserInfoEmail); | 125 scopes.insert(GaiaConstants::kGoogleUserInfoEmail); |
110 scopes.insert(GaiaConstants::kGoogleUserInfoProfile); | 126 scopes.insert(GaiaConstants::kGoogleUserInfoProfile); |
127 scopes.insert(GaiaConstants::kOAuth1LoginScope); | |
111 login_token_request_ = token_service_->StartRequest( | 128 login_token_request_ = token_service_->StartRequest( |
112 account_id_, scopes, this); | 129 account_id_, scopes, this); |
113 } | 130 } |
114 | 131 |
132 void AccountInfoFetcher::SendSuccessIfDoneFetching() { | |
133 if (fetched_user_info_ && fetched_service_flags_) { | |
134 service_->OnUserInfoFetchSuccess( | |
135 this, fetched_user_info_.get(), fetched_service_flags_.get()); | |
136 } | |
137 } | |
138 | |
115 void AccountInfoFetcher::OnGetTokenSuccess( | 139 void AccountInfoFetcher::OnGetTokenSuccess( |
116 const OAuth2TokenService::Request* request, | 140 const OAuth2TokenService::Request* request, |
117 const std::string& access_token, | 141 const std::string& access_token, |
118 const base::Time& expiration_time) { | 142 const base::Time& expiration_time) { |
119 TRACE_EVENT_ASYNC_STEP_PAST0( | 143 TRACE_EVENT_ASYNC_STEP_PAST0( |
120 "AccountTrackerService", "AccountIdFetcher", this, "OnGetTokenSuccess"); | 144 "AccountTrackerService", "AccountIdFetcher", this, "OnGetTokenSuccess"); |
121 DCHECK_EQ(request, login_token_request_.get()); | 145 DCHECK_EQ(request, login_token_request_.get()); |
122 | 146 |
123 gaia_oauth_client_.reset(new gaia::GaiaOAuthClient(request_context_getter_)); | 147 gaia_oauth_client_.reset(new gaia::GaiaOAuthClient(request_context_getter_)); |
124 | |
125 const int kMaxRetries = 3; | 148 const int kMaxRetries = 3; |
126 gaia_oauth_client_->GetUserInfo(access_token, kMaxRetries, this); | 149 gaia_oauth_client_->GetUserInfo(access_token, kMaxRetries, this); |
150 | |
151 gaia_auth_fetcher_.reset( | |
152 new GaiaAuthFetcher( | |
153 this, GaiaConstants::kChromeSource, request_context_getter_)); | |
154 gaia_auth_fetcher_->StartOAuthLogin( | |
155 access_token, GaiaConstants::kGaiaService); | |
127 } | 156 } |
128 | 157 |
129 void AccountInfoFetcher::OnGetTokenFailure( | 158 void AccountInfoFetcher::OnGetTokenFailure( |
130 const OAuth2TokenService::Request* request, | 159 const OAuth2TokenService::Request* request, |
131 const GoogleServiceAuthError& error) { | 160 const GoogleServiceAuthError& error) { |
132 TRACE_EVENT_ASYNC_STEP_PAST1("AccountTrackerService", | 161 TRACE_EVENT_ASYNC_STEP_PAST1("AccountTrackerService", |
133 "AccountIdFetcher", | 162 "AccountIdFetcher", |
134 this, | 163 this, |
135 "OnGetTokenFailure", | 164 "OnGetTokenFailure", |
136 "google_service_auth_error", | 165 "google_service_auth_error", |
137 error.ToString()); | 166 error.ToString()); |
138 LOG(ERROR) << "OnGetTokenFailure: " << error.ToString(); | 167 LOG(ERROR) << "OnGetTokenFailure: " << error.ToString(); |
139 DCHECK_EQ(request, login_token_request_.get()); | 168 DCHECK_EQ(request, login_token_request_.get()); |
140 service_->OnUserInfoFetchFailure(this); | 169 service_->OnUserInfoFetchFailure(this); |
141 } | 170 } |
142 | 171 |
143 void AccountInfoFetcher::OnGetUserInfoResponse( | 172 void AccountInfoFetcher::OnGetUserInfoResponse( |
144 scoped_ptr<base::DictionaryValue> user_info) { | 173 scoped_ptr<base::DictionaryValue> user_info) { |
145 TRACE_EVENT_ASYNC_STEP_PAST1("AccountTrackerService", | 174 TRACE_EVENT_ASYNC_STEP_PAST1("AccountTrackerService", |
146 "AccountIdFetcher", | 175 "AccountIdFetcher", |
147 this, | 176 this, |
148 "OnGetUserInfoResponse", | 177 "OnGetUserInfoResponse", |
149 "account_id", | 178 "account_id", |
150 account_id_); | 179 account_id_); |
151 service_->OnUserInfoFetchSuccess(this, user_info.get()); | 180 fetched_user_info_ = user_info.Pass(); |
181 SendSuccessIfDoneFetching(); | |
182 } | |
183 | |
184 void AccountInfoFetcher::OnClientLoginSuccess( | |
185 const ClientLoginResult& result) { | |
186 gaia_auth_fetcher_->StartGetUserInfo(result.lsid); | |
187 } | |
188 | |
189 void AccountInfoFetcher::OnClientLoginFailure( | |
190 const GoogleServiceAuthError& error) { | |
191 service_->OnUserInfoFetchFailure(this); | |
192 } | |
193 | |
194 void AccountInfoFetcher::OnGetUserInfoSuccess(const UserInfoMap& data) { | |
195 fetched_service_flags_.reset(new std::vector<std::string>); | |
196 UserInfoMap::const_iterator services_iter = data.find("allServices"); | |
197 if (services_iter != data.end()) { | |
198 base::SplitString(services_iter->second, ',', fetched_service_flags_.get()); | |
199 SendSuccessIfDoneFetching(); | |
200 } else { | |
201 DLOG(WARNING) << "AccountInfoFetcher::OnGetUserInfoSuccess: " | |
202 << "GetUserInfo response didn't include allServices field."; | |
203 service_->OnUserInfoFetchFailure(this); | |
204 } | |
205 } | |
206 | |
207 void AccountInfoFetcher::OnGetUserInfoFailure( | |
208 const GoogleServiceAuthError& error) { | |
209 service_->OnUserInfoFetchFailure(this); | |
152 } | 210 } |
153 | 211 |
154 void AccountInfoFetcher::OnOAuthError() { | 212 void AccountInfoFetcher::OnOAuthError() { |
155 TRACE_EVENT_ASYNC_STEP_PAST0( | 213 TRACE_EVENT_ASYNC_STEP_PAST0( |
156 "AccountTrackerService", "AccountIdFetcher", this, "OnOAuthError"); | 214 "AccountTrackerService", "AccountIdFetcher", this, "OnOAuthError"); |
157 LOG(ERROR) << "OnOAuthError"; | 215 LOG(ERROR) << "OnOAuthError"; |
158 service_->OnUserInfoFetchFailure(this); | 216 service_->OnUserInfoFetchFailure(this); |
159 } | 217 } |
160 | 218 |
161 void AccountInfoFetcher::OnNetworkError(int response_code) { | 219 void AccountInfoFetcher::OnNetworkError(int response_code) { |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 signin_client_->GetURLRequestContext(), | 491 signin_client_->GetURLRequestContext(), |
434 this, | 492 this, |
435 account_id); | 493 account_id); |
436 user_info_requests_[account_id] = fetcher; | 494 user_info_requests_[account_id] = fetcher; |
437 fetcher->Start(); | 495 fetcher->Start(); |
438 } | 496 } |
439 } | 497 } |
440 | 498 |
441 void AccountTrackerService::SetAccountStateFromUserInfo( | 499 void AccountTrackerService::SetAccountStateFromUserInfo( |
442 const std::string& account_id, | 500 const std::string& account_id, |
443 const base::DictionaryValue* user_info) { | 501 const base::DictionaryValue* user_info, |
502 const std::vector<std::string>* service_flags) { | |
444 AccountState& state = accounts_[account_id]; | 503 AccountState& state = accounts_[account_id]; |
445 | 504 |
446 std::string gaia_id; | 505 std::string gaia_id; |
447 std::string email; | 506 std::string email; |
448 if (user_info->GetString("id", &gaia_id) && | 507 if (user_info->GetString("id", &gaia_id) && |
449 user_info->GetString("email", &email)) { | 508 user_info->GetString("email", &email)) { |
450 state.info.gaia = gaia_id; | 509 state.info.gaia = gaia_id; |
451 state.info.email = email; | 510 state.info.email = email; |
452 | 511 |
453 std::string hosted_domain; | 512 std::string hosted_domain; |
454 if (user_info->GetString("hd", &hosted_domain) && !hosted_domain.empty()) { | 513 if (user_info->GetString("hd", &hosted_domain) && !hosted_domain.empty()) { |
455 state.info.hosted_domain = hosted_domain; | 514 state.info.hosted_domain = hosted_domain; |
456 } else { | 515 } else { |
457 state.info.hosted_domain = kNoHostedDomainFound; | 516 state.info.hosted_domain = kNoHostedDomainFound; |
458 } | 517 } |
459 | 518 |
460 user_info->GetString("name", &state.info.full_name); | 519 user_info->GetString("name", &state.info.full_name); |
461 user_info->GetString("given_name", &state.info.given_name); | 520 user_info->GetString("given_name", &state.info.given_name); |
462 user_info->GetString("locale", &state.info.locale); | 521 user_info->GetString("locale", &state.info.locale); |
463 | 522 |
523 state.info.service_flags = *service_flags; | |
524 | |
464 NotifyAccountUpdated(state); | 525 NotifyAccountUpdated(state); |
465 SaveToPrefs(state); | 526 SaveToPrefs(state); |
466 } | 527 } |
467 } | 528 } |
468 | 529 |
469 void AccountTrackerService::OnUserInfoFetchSuccess( | 530 void AccountTrackerService::OnUserInfoFetchSuccess( |
470 AccountInfoFetcher* fetcher, | 531 AccountInfoFetcher* fetcher, |
471 const base::DictionaryValue* user_info) { | 532 const base::DictionaryValue* user_info, |
533 const std::vector<std::string>* service_flags) { | |
472 const std::string& account_id = fetcher->account_id(); | 534 const std::string& account_id = fetcher->account_id(); |
473 DCHECK(ContainsKey(accounts_, account_id)); | 535 DCHECK(ContainsKey(accounts_, account_id)); |
474 | 536 |
475 SetAccountStateFromUserInfo(account_id, user_info); | 537 SetAccountStateFromUserInfo(account_id, user_info, service_flags); |
476 DeleteFetcher(fetcher); | 538 DeleteFetcher(fetcher); |
477 } | 539 } |
478 | 540 |
479 void AccountTrackerService::OnUserInfoFetchFailure( | 541 void AccountTrackerService::OnUserInfoFetchFailure( |
480 AccountInfoFetcher* fetcher) { | 542 AccountInfoFetcher* fetcher) { |
481 LOG(WARNING) << "Failed to get UserInfo for " << fetcher->account_id(); | 543 LOG(WARNING) << "Failed to get UserInfo for " << fetcher->account_id(); |
482 NotifyAccountUpdateFailed(fetcher->account_id()); | 544 NotifyAccountUpdateFailed(fetcher->account_id()); |
483 DeleteFetcher(fetcher); | 545 DeleteFetcher(fetcher); |
484 } | 546 } |
485 | 547 |
(...skipping 23 matching lines...) Expand all Loading... | |
509 if (dict->GetString(kAccountEmailPath, &value)) | 571 if (dict->GetString(kAccountEmailPath, &value)) |
510 state.info.email = base::UTF16ToUTF8(value); | 572 state.info.email = base::UTF16ToUTF8(value); |
511 if (dict->GetString(kAccountHostedDomainPath, &value)) | 573 if (dict->GetString(kAccountHostedDomainPath, &value)) |
512 state.info.hosted_domain = base::UTF16ToUTF8(value); | 574 state.info.hosted_domain = base::UTF16ToUTF8(value); |
513 if (dict->GetString(kAccountFullNamePath, &value)) | 575 if (dict->GetString(kAccountFullNamePath, &value)) |
514 state.info.full_name = base::UTF16ToUTF8(value); | 576 state.info.full_name = base::UTF16ToUTF8(value); |
515 if (dict->GetString(kAccountGivenNamePath, &value)) | 577 if (dict->GetString(kAccountGivenNamePath, &value)) |
516 state.info.given_name = base::UTF16ToUTF8(value); | 578 state.info.given_name = base::UTF16ToUTF8(value); |
517 if (dict->GetString(kAccountLocalePath, &value)) | 579 if (dict->GetString(kAccountLocalePath, &value)) |
518 state.info.locale = base::UTF16ToUTF8(value); | 580 state.info.locale = base::UTF16ToUTF8(value); |
581 | |
582 const base::ListValue* service_flags_list; | |
583 if (dict->GetList(kAccountServiceFlagsPath, &service_flags_list)) { | |
584 std::string flag; | |
brucedawson
2015/05/18 23:43:13
This variable is never used. It should be deleted
| |
585 for(base::Value* flag: *service_flags_list) { | |
brucedawson
2015/05/18 23:43:13
The Google C++ style guide recommends "for (base::
| |
586 std::string flag_string; | |
587 if(flag->GetAsString(&flag_string)) { | |
588 state.info.service_flags.push_back(flag_string); | |
589 } | |
590 } | |
591 } | |
592 | |
519 if (state.info.IsValid()) | 593 if (state.info.IsValid()) |
520 NotifyAccountUpdated(state); | 594 NotifyAccountUpdated(state); |
521 } | 595 } |
522 } | 596 } |
523 } | 597 } |
524 last_updated_ = base::Time::FromInternalValue( | 598 last_updated_ = base::Time::FromInternalValue( |
525 signin_client_->GetPrefs()->GetInt64(kAccountTrackerServiceLastUpdate)); | 599 signin_client_->GetPrefs()->GetInt64(kAccountTrackerServiceLastUpdate)); |
526 } | 600 } |
527 | 601 |
528 void AccountTrackerService::SaveToPrefs(const AccountState& state) { | 602 void AccountTrackerService::SaveToPrefs(const AccountState& state) { |
(...skipping 16 matching lines...) Expand all Loading... | |
545 update->Append(dict); // |update| takes ownership. | 619 update->Append(dict); // |update| takes ownership. |
546 dict->SetString(kAccountKeyPath, account_id_16); | 620 dict->SetString(kAccountKeyPath, account_id_16); |
547 } | 621 } |
548 | 622 |
549 dict->SetString(kAccountEmailPath, state.info.email); | 623 dict->SetString(kAccountEmailPath, state.info.email); |
550 dict->SetString(kAccountGaiaPath, state.info.gaia); | 624 dict->SetString(kAccountGaiaPath, state.info.gaia); |
551 dict->SetString(kAccountHostedDomainPath, state.info.hosted_domain); | 625 dict->SetString(kAccountHostedDomainPath, state.info.hosted_domain); |
552 dict->SetString(kAccountFullNamePath, state.info.full_name); | 626 dict->SetString(kAccountFullNamePath, state.info.full_name); |
553 dict->SetString(kAccountGivenNamePath, state.info.given_name); | 627 dict->SetString(kAccountGivenNamePath, state.info.given_name); |
554 dict->SetString(kAccountLocalePath, state.info.locale); | 628 dict->SetString(kAccountLocalePath, state.info.locale); |
629 | |
630 scoped_ptr<base::ListValue> service_flags_list; | |
631 service_flags_list.reset(new base::ListValue); | |
632 service_flags_list->AppendStrings(state.info.service_flags); | |
633 | |
634 dict->Set(kAccountServiceFlagsPath, service_flags_list.Pass()); | |
555 } | 635 } |
556 | 636 |
557 void AccountTrackerService::RemoveFromPrefs(const AccountState& state) { | 637 void AccountTrackerService::RemoveFromPrefs(const AccountState& state) { |
558 if (!signin_client_->GetPrefs()) | 638 if (!signin_client_->GetPrefs()) |
559 return; | 639 return; |
560 | 640 |
561 base::string16 account_id_16 = base::UTF8ToUTF16(state.info.account_id); | 641 base::string16 account_id_16 = base::UTF8ToUTF16(state.info.account_id); |
562 ListPrefUpdate update(signin_client_->GetPrefs(), kAccountInfoPref); | 642 ListPrefUpdate update(signin_client_->GetPrefs(), kAccountInfoPref); |
563 for(size_t i = 0; i < update->GetSize(); ++i) { | 643 for(size_t i = 0; i < update->GetSize(); ++i) { |
564 base::DictionaryValue* dict = NULL; | 644 base::DictionaryValue* dict = NULL; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
672 state.info.email = email; | 752 state.info.email = email; |
673 SaveToPrefs(state); | 753 SaveToPrefs(state); |
674 | 754 |
675 DVLOG(1) << "AccountTrackerService::SeedAccountInfo" | 755 DVLOG(1) << "AccountTrackerService::SeedAccountInfo" |
676 << " account_id=" << account_id | 756 << " account_id=" << account_id |
677 << " gaia_id=" << gaia | 757 << " gaia_id=" << gaia |
678 << " email=" << email; | 758 << " email=" << email; |
679 | 759 |
680 return account_id; | 760 return account_id; |
681 } | 761 } |
OLD | NEW |