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

Side by Side Diff: components/user_manager/user_manager_base.cc

Issue 2884933002: Remove raw base::DictionaryValue::SetWithoutPathExpansion (Closed)
Patch Set: Include Created 3 years, 7 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 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/user_manager/user_manager_base.h" 5 #include "components/user_manager/user_manager_base.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 user->set_oauth_token_status(oauth_token_status); 367 user->set_oauth_token_status(oauth_token_status);
368 368
369 // Do not update local state if data stored or cached outside the user's 369 // Do not update local state if data stored or cached outside the user's
370 // cryptohome is to be treated as ephemeral. 370 // cryptohome is to be treated as ephemeral.
371 if (IsUserNonCryptohomeDataEphemeral(account_id)) 371 if (IsUserNonCryptohomeDataEphemeral(account_id))
372 return; 372 return;
373 373
374 { 374 {
375 DictionaryPrefUpdate oauth_status_update(GetLocalState(), 375 DictionaryPrefUpdate oauth_status_update(GetLocalState(),
376 kUserOAuthTokenStatus); 376 kUserOAuthTokenStatus);
377 oauth_status_update->SetWithoutPathExpansion( 377 oauth_status_update->SetIntegerWithoutPathExpansion(
378 account_id.GetUserEmail(), 378 account_id.GetUserEmail(), static_cast<int>(oauth_token_status));
379 new base::Value(static_cast<int>(oauth_token_status)));
380 } 379 }
381 GetLocalState()->CommitPendingWrite(); 380 GetLocalState()->CommitPendingWrite();
382 } 381 }
383 382
384 void UserManagerBase::SaveForceOnlineSignin(const AccountId& account_id, 383 void UserManagerBase::SaveForceOnlineSignin(const AccountId& account_id,
385 bool force_online_signin) { 384 bool force_online_signin) {
386 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 385 DCHECK(task_runner_->RunsTasksOnCurrentThread());
387 386
388 // Do not update local state if data stored or cached outside the user's 387 // Do not update local state if data stored or cached outside the user's
389 // cryptohome is to be treated as ephemeral. 388 // cryptohome is to be treated as ephemeral.
(...skipping 14 matching lines...) Expand all
404 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 403 DCHECK(task_runner_->RunsTasksOnCurrentThread());
405 404
406 if (User* user = FindUserAndModify(account_id)) { 405 if (User* user = FindUserAndModify(account_id)) {
407 user->set_display_name(display_name); 406 user->set_display_name(display_name);
408 407
409 // Do not update local state if data stored or cached outside the user's 408 // Do not update local state if data stored or cached outside the user's
410 // cryptohome is to be treated as ephemeral. 409 // cryptohome is to be treated as ephemeral.
411 if (!IsUserNonCryptohomeDataEphemeral(account_id)) { 410 if (!IsUserNonCryptohomeDataEphemeral(account_id)) {
412 DictionaryPrefUpdate display_name_update(GetLocalState(), 411 DictionaryPrefUpdate display_name_update(GetLocalState(),
413 kUserDisplayName); 412 kUserDisplayName);
414 display_name_update->SetWithoutPathExpansion( 413 display_name_update->SetStringWithoutPathExpansion(
415 account_id.GetUserEmail(), new base::Value(display_name)); 414 account_id.GetUserEmail(), display_name);
416 } 415 }
417 } 416 }
418 } 417 }
419 418
420 base::string16 UserManagerBase::GetUserDisplayName( 419 base::string16 UserManagerBase::GetUserDisplayName(
421 const AccountId& account_id) const { 420 const AccountId& account_id) const {
422 const User* user = FindUser(account_id); 421 const User* user = FindUser(account_id);
423 return user ? user->display_name() : base::string16(); 422 return user ? user->display_name() : base::string16();
424 } 423 }
425 424
426 void UserManagerBase::SaveUserDisplayEmail(const AccountId& account_id, 425 void UserManagerBase::SaveUserDisplayEmail(const AccountId& account_id,
427 const std::string& display_email) { 426 const std::string& display_email) {
428 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 427 DCHECK(task_runner_->RunsTasksOnCurrentThread());
429 428
430 User* user = FindUserAndModify(account_id); 429 User* user = FindUserAndModify(account_id);
431 if (!user) { 430 if (!user) {
432 LOG(ERROR) << "User not found: " << account_id.GetUserEmail(); 431 LOG(ERROR) << "User not found: " << account_id.GetUserEmail();
433 return; // Ignore if there is no such user. 432 return; // Ignore if there is no such user.
434 } 433 }
435 434
436 user->set_display_email(display_email); 435 user->set_display_email(display_email);
437 436
438 // Do not update local state if data stored or cached outside the user's 437 // Do not update local state if data stored or cached outside the user's
439 // cryptohome is to be treated as ephemeral. 438 // cryptohome is to be treated as ephemeral.
440 if (IsUserNonCryptohomeDataEphemeral(account_id)) 439 if (IsUserNonCryptohomeDataEphemeral(account_id))
441 return; 440 return;
442 441
443 DictionaryPrefUpdate display_email_update(GetLocalState(), kUserDisplayEmail); 442 DictionaryPrefUpdate display_email_update(GetLocalState(), kUserDisplayEmail);
444 display_email_update->SetWithoutPathExpansion(account_id.GetUserEmail(), 443 display_email_update->SetStringWithoutPathExpansion(account_id.GetUserEmail(),
445 new base::Value(display_email)); 444 display_email);
446 } 445 }
447 446
448 std::string UserManagerBase::GetUserDisplayEmail( 447 std::string UserManagerBase::GetUserDisplayEmail(
449 const AccountId& account_id) const { 448 const AccountId& account_id) const {
450 const User* user = FindUser(account_id); 449 const User* user = FindUser(account_id);
451 return user ? user->display_email() : account_id.GetUserEmail(); 450 return user ? user->display_email() : account_id.GetUserEmail();
452 } 451 }
453 452
454 void UserManagerBase::SaveUserType(const AccountId& account_id, 453 void UserManagerBase::SaveUserType(const AccountId& account_id,
455 const UserType& user_type) { 454 const UserType& user_type) {
456 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 455 DCHECK(task_runner_->RunsTasksOnCurrentThread());
457 456
458 User* user = FindUserAndModify(account_id); 457 User* user = FindUserAndModify(account_id);
459 if (!user) { 458 if (!user) {
460 LOG(ERROR) << "User not found: " << account_id.GetUserEmail(); 459 LOG(ERROR) << "User not found: " << account_id.GetUserEmail();
461 return; // Ignore if there is no such user. 460 return; // Ignore if there is no such user.
462 } 461 }
463 462
464 // Do not update local state if data stored or cached outside the user's 463 // Do not update local state if data stored or cached outside the user's
465 // cryptohome is to be treated as ephemeral. 464 // cryptohome is to be treated as ephemeral.
466 if (IsUserNonCryptohomeDataEphemeral(account_id)) 465 if (IsUserNonCryptohomeDataEphemeral(account_id))
467 return; 466 return;
468 467
469 DictionaryPrefUpdate user_type_update(GetLocalState(), kUserType); 468 DictionaryPrefUpdate user_type_update(GetLocalState(), kUserType);
470 user_type_update->SetWithoutPathExpansion( 469 user_type_update->SetIntegerWithoutPathExpansion(account_id.GetUserEmail(),
471 account_id.GetUserEmail(), new base::Value(static_cast<int>(user_type))); 470 static_cast<int>(user_type));
472 GetLocalState()->CommitPendingWrite(); 471 GetLocalState()->CommitPendingWrite();
473 } 472 }
474 473
475 void UserManagerBase::UpdateUserAccountData( 474 void UserManagerBase::UpdateUserAccountData(
476 const AccountId& account_id, 475 const AccountId& account_id,
477 const UserAccountData& account_data) { 476 const UserAccountData& account_data) {
478 DCHECK(task_runner_->RunsTasksOnCurrentThread()); 477 DCHECK(task_runner_->RunsTasksOnCurrentThread());
479 478
480 SaveUserDisplayName(account_id, account_data.display_name()); 479 SaveUserDisplayName(account_id, account_data.display_name());
481 480
482 if (User* user = FindUserAndModify(account_id)) { 481 if (User* user = FindUserAndModify(account_id)) {
483 base::string16 given_name = account_data.given_name(); 482 base::string16 given_name = account_data.given_name();
484 user->set_given_name(given_name); 483 user->set_given_name(given_name);
485 if (!IsUserNonCryptohomeDataEphemeral(account_id)) { 484 if (!IsUserNonCryptohomeDataEphemeral(account_id)) {
486 DictionaryPrefUpdate given_name_update(GetLocalState(), kUserGivenName); 485 DictionaryPrefUpdate given_name_update(GetLocalState(), kUserGivenName);
487 given_name_update->SetWithoutPathExpansion(account_id.GetUserEmail(), 486 given_name_update->SetStringWithoutPathExpansion(
488 new base::Value(given_name)); 487 account_id.GetUserEmail(), given_name);
489 } 488 }
490 } 489 }
491 490
492 UpdateUserAccountLocale(account_id, account_data.locale()); 491 UpdateUserAccountLocale(account_id, account_data.locale());
493 } 492 }
494 493
495 void UserManagerBase::ParseUserList(const base::ListValue& users_list, 494 void UserManagerBase::ParseUserList(const base::ListValue& users_list,
496 const std::set<AccountId>& existing_users, 495 const std::set<AccountId>& existing_users,
497 std::vector<AccountId>* users_vector, 496 std::vector<AccountId>* users_vector,
498 std::set<AccountId>* users_set) { 497 std::set<AccountId>* users_set) {
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 } 1094 }
1096 1095
1097 void UserManagerBase::DeleteUser(User* user) { 1096 void UserManagerBase::DeleteUser(User* user) {
1098 const bool is_active_user = (user == active_user_); 1097 const bool is_active_user = (user == active_user_);
1099 delete user; 1098 delete user;
1100 if (is_active_user) 1099 if (is_active_user)
1101 active_user_ = nullptr; 1100 active_user_ = nullptr;
1102 } 1101 }
1103 1102
1104 } // namespace user_manager 1103 } // namespace user_manager
OLDNEW
« no previous file with comments | « components/url_matcher/url_matcher_factory_unittest.cc ('k') | components/wifi/wifi_service_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698