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

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

Issue 8840003: Replace ProfileManagerObserver with callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 9 years 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/login_utils.h" 5 #include "chrome/browser/chromeos/login/login_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 } 514 }
515 } 515 }
516 516
517 int pid_; 517 int pid_;
518 std::string command_line_; 518 std::string command_line_;
519 PrefService* local_state_; 519 PrefService* local_state_;
520 base::OneShotTimer<JobRestartRequest> timer_; 520 base::OneShotTimer<JobRestartRequest> timer_;
521 }; 521 };
522 522
523 class LoginUtilsImpl : public LoginUtils, 523 class LoginUtilsImpl : public LoginUtils,
524 public ProfileManagerObserver,
525 public GaiaOAuthConsumer, 524 public GaiaOAuthConsumer,
526 public OAuthLoginVerifier::Delegate, 525 public OAuthLoginVerifier::Delegate,
527 public net::NetworkChangeNotifier::OnlineStateObserver { 526 public net::NetworkChangeNotifier::OnlineStateObserver,
527 public base::SupportsWeakPtr<LoginUtilsImpl> {
528 public: 528 public:
529 LoginUtilsImpl() 529 LoginUtilsImpl()
530 : background_view_(NULL), 530 : background_view_(NULL),
531 pending_requests_(false), 531 pending_requests_(false),
532 using_oauth_(false), 532 using_oauth_(false),
533 has_cookies_(false), 533 has_cookies_(false),
534 delegate_(NULL), 534 delegate_(NULL),
535 job_restart_request_(NULL) { 535 job_restart_request_(NULL) {
536 net::NetworkChangeNotifier::AddOnlineStateObserver(this); 536 net::NetworkChangeNotifier::AddOnlineStateObserver(this);
537 } 537 }
(...skipping 24 matching lines...) Expand all
562 Profile* profile, 562 Profile* profile,
563 const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE; 563 const GaiaAuthConsumer::ClientLoginResult& credentials) OVERRIDE;
564 virtual void SetBackgroundView( 564 virtual void SetBackgroundView(
565 chromeos::BackgroundView* background_view) OVERRIDE; 565 chromeos::BackgroundView* background_view) OVERRIDE;
566 virtual chromeos::BackgroundView* GetBackgroundView() OVERRIDE; 566 virtual chromeos::BackgroundView* GetBackgroundView() OVERRIDE;
567 virtual void TransferDefaultCookies(Profile* default_profile, 567 virtual void TransferDefaultCookies(Profile* default_profile,
568 Profile* new_profile) OVERRIDE; 568 Profile* new_profile) OVERRIDE;
569 virtual void TransferDefaultAuthCache(Profile* default_profile, 569 virtual void TransferDefaultAuthCache(Profile* default_profile,
570 Profile* new_profile) OVERRIDE; 570 Profile* new_profile) OVERRIDE;
571 571
572 // ProfileManagerObserver implementation:
573 virtual void OnProfileCreated(Profile* profile, Status status) OVERRIDE;
574
575 // GaiaOAuthConsumer overrides. 572 // GaiaOAuthConsumer overrides.
576 virtual void OnGetOAuthTokenSuccess(const std::string& oauth_token) OVERRIDE; 573 virtual void OnGetOAuthTokenSuccess(const std::string& oauth_token) OVERRIDE;
577 virtual void OnGetOAuthTokenFailure( 574 virtual void OnGetOAuthTokenFailure(
578 const GoogleServiceAuthError& error) OVERRIDE; 575 const GoogleServiceAuthError& error) OVERRIDE;
579 virtual void OnOAuthGetAccessTokenSuccess(const std::string& token, 576 virtual void OnOAuthGetAccessTokenSuccess(const std::string& token,
580 const std::string& secret) OVERRIDE; 577 const std::string& secret) OVERRIDE;
581 virtual void OnOAuthGetAccessTokenFailure( 578 virtual void OnOAuthGetAccessTokenFailure(
582 const GoogleServiceAuthError& error) OVERRIDE; 579 const GoogleServiceAuthError& error) OVERRIDE;
583 580
584 // OAuthLoginVerifier::Delegate overrides. 581 // OAuthLoginVerifier::Delegate overrides.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 const std::string& secret); 629 const std::string& secret);
633 630
634 // Fetch enterprise policy OAuth2 given OAuth1 access |token| and |secret|. 631 // Fetch enterprise policy OAuth2 given OAuth1 access |token| and |secret|.
635 void FetchPolicyToken(Profile* offrecord_profile, 632 void FetchPolicyToken(Profile* offrecord_profile,
636 const std::string& token, 633 const std::string& token,
637 const std::string& secret); 634 const std::string& secret);
638 635
639 // Check user's profile for kApplicationLocale setting. 636 // Check user's profile for kApplicationLocale setting.
640 void RespectLocalePreference(Profile* pref); 637 void RespectLocalePreference(Profile* pref);
641 638
639 // Callback for asynchronous profile creation.
640 void OnProfileCreated(Profile* profile,
641 Profile::CreateStatus status);
642
642 // The current background view. 643 // The current background view.
643 chromeos::BackgroundView* background_view_; 644 chromeos::BackgroundView* background_view_;
644 645
645 std::string password_; 646 std::string password_;
646 GaiaAuthConsumer::ClientLoginResult credentials_; 647 GaiaAuthConsumer::ClientLoginResult credentials_;
647 bool pending_requests_; 648 bool pending_requests_;
648 bool using_oauth_; 649 bool using_oauth_;
649 bool has_cookies_; 650 bool has_cookies_;
650 // Has to be scoped_refptr, see comment for CreateAuthenticator(...). 651 // Has to be scoped_refptr, see comment for CreateAuthenticator(...).
651 scoped_refptr<Authenticator> authenticator_; 652 scoped_refptr<Authenticator> authenticator_;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 // Profile creation will block until user policy is fetched, which 752 // Profile creation will block until user policy is fetched, which
752 // requires the DeviceManagement token. Try to fetch it now. 753 // requires the DeviceManagement token. Try to fetch it now.
753 VLOG(1) << "Profile creation requires policy token, fetching now"; 754 VLOG(1) << "Profile creation requires policy token, fetching now";
754 policy_oauth_fetcher_.reset( 755 policy_oauth_fetcher_.reset(
755 new PolicyOAuthFetcher(authenticator_->authentication_profile())); 756 new PolicyOAuthFetcher(authenticator_->authentication_profile()));
756 policy_oauth_fetcher_->Start(); 757 policy_oauth_fetcher_->Start();
757 } 758 }
758 759
759 // The default profile will have been changed because the ProfileManager 760 // The default profile will have been changed because the ProfileManager
760 // will process the notification that the UserManager sends out. 761 // will process the notification that the UserManager sends out.
761 ProfileManager::CreateDefaultProfileAsync(this); 762 ProfileManager::CreateDefaultProfileAsync(
763 base::Bind(&LoginUtilsImpl::OnProfileCreated, AsWeakPtr()));
762 } 764 }
763 765
764 void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) { 766 void LoginUtilsImpl::DelegateDeleted(LoginUtils::Delegate* delegate) {
765 if (delegate_ == delegate) 767 if (delegate_ == delegate)
766 delegate_ = NULL; 768 delegate_ = NULL;
767 } 769 }
768 770
769 void LoginUtilsImpl::OnProfileCreated(Profile* user_profile, Status status) { 771 void LoginUtilsImpl::OnProfileCreated(
772 Profile* user_profile,
773 Profile::CreateStatus status) {
770 CHECK(user_profile); 774 CHECK(user_profile);
771 switch (status) { 775 switch (status) {
772 case STATUS_INITIALIZED: 776 case Profile::CREATE_STATUS_INITIALIZED:
773 break; 777 break;
774 case STATUS_CREATED: 778 case Profile::CREATE_STATUS_CREATED:
775 if (UserManager::Get()->current_user_is_new()) 779 if (UserManager::Get()->current_user_is_new())
776 SetFirstLoginPrefs(user_profile->GetPrefs()); 780 SetFirstLoginPrefs(user_profile->GetPrefs());
777 RespectLocalePreference(user_profile); 781 RespectLocalePreference(user_profile);
778 return; 782 return;
779 case STATUS_FAIL: 783 case Profile::CREATE_STATUS_FAIL:
780 default: 784 default:
781 NOTREACHED(); 785 NOTREACHED();
782 return; 786 return;
783 } 787 }
784 788
785 BootTimesLoader* btl = BootTimesLoader::Get(); 789 BootTimesLoader* btl = BootTimesLoader::Get();
786 btl->AddLoginTimeMarker("UserProfileGotten", false); 790 btl->AddLoginTimeMarker("UserProfileGotten", false);
787 791
788 if (using_oauth_) { 792 if (using_oauth_) {
789 // Reuse the access token fetched by the PolicyOAuthFetcher, if it was 793 // Reuse the access token fetched by the PolicyOAuthFetcher, if it was
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 // Mark login host for deletion after browser starts. This 1336 // Mark login host for deletion after browser starts. This
1333 // guarantees that the message loop will be referenced by the 1337 // guarantees that the message loop will be referenced by the
1334 // browser before it is dereferenced by the login host. 1338 // browser before it is dereferenced by the login host.
1335 if (login_host) { 1339 if (login_host) {
1336 login_host->OnSessionStart(); 1340 login_host->OnSessionStart();
1337 login_host = NULL; 1341 login_host = NULL;
1338 } 1342 }
1339 } 1343 }
1340 1344
1341 } // namespace chromeos 1345 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/login_performer.cc ('k') | chrome/browser/profiles/avatar_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698