OLD | NEW |
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/ui/sync/one_click_signin_sync_starter.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 browser_ = browser; | 126 browser_ = browser; |
127 | 127 |
128 LoginUIServiceFactory::GetForProfile(profile_)->AddObserver(this); | 128 LoginUIServiceFactory::GetForProfile(profile_)->AddObserver(this); |
129 | 129 |
130 signin_tracker_ = SigninTrackerFactory::CreateForProfile(profile_, this); | 130 signin_tracker_ = SigninTrackerFactory::CreateForProfile(profile_, this); |
131 | 131 |
132 // Let the sync service know that setup is in progress so it doesn't start | 132 // Let the sync service know that setup is in progress so it doesn't start |
133 // syncing until the user has finished any configuration. | 133 // syncing until the user has finished any configuration. |
134 ProfileSyncService* profile_sync_service = GetProfileSyncService(); | 134 ProfileSyncService* profile_sync_service = GetProfileSyncService(); |
135 if (profile_sync_service) | 135 if (profile_sync_service) |
136 profile_sync_service->SetSetupInProgress(true); | 136 setup_handle_ = profile_sync_service->GetSetupInProgressHandle(); |
137 | 137 |
138 // Make sure the syncing is requested, otherwise the SigninManager | 138 // Make sure the syncing is requested, otherwise the SigninManager |
139 // will not be able to complete successfully. | 139 // will not be able to complete successfully. |
140 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); | 140 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); |
141 sync_prefs.SetSyncRequested(true); | 141 sync_prefs.SetSyncRequested(true); |
142 } | 142 } |
143 | 143 |
144 void OneClickSigninSyncStarter::ConfirmSignin(const std::string& oauth_token) { | 144 void OneClickSigninSyncStarter::ConfirmSignin(const std::string& oauth_token) { |
145 DCHECK(!oauth_token.empty()); | 145 DCHECK(!oauth_token.empty()); |
146 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 146 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 } | 608 } |
609 | 609 |
610 ProfileSyncService* OneClickSigninSyncStarter::GetProfileSyncService() { | 610 ProfileSyncService* OneClickSigninSyncStarter::GetProfileSyncService() { |
611 ProfileSyncService* service = NULL; | 611 ProfileSyncService* service = NULL; |
612 if (profile_->IsSyncAllowed()) | 612 if (profile_->IsSyncAllowed()) |
613 service = ProfileSyncServiceFactory::GetForProfile(profile_); | 613 service = ProfileSyncServiceFactory::GetForProfile(profile_); |
614 return service; | 614 return service; |
615 } | 615 } |
616 | 616 |
617 void OneClickSigninSyncStarter::FinishProfileSyncServiceSetup() { | 617 void OneClickSigninSyncStarter::FinishProfileSyncServiceSetup() { |
618 ProfileSyncService* service = | 618 setup_handle_.reset(); |
619 ProfileSyncServiceFactory::GetForProfile(profile_); | |
620 if (service) | |
621 service->SetSetupInProgress(false); | |
622 } | 619 } |
623 | 620 |
624 void OneClickSigninSyncStarter::ShowSettingsPageInWebContents( | 621 void OneClickSigninSyncStarter::ShowSettingsPageInWebContents( |
625 content::WebContents* contents, | 622 content::WebContents* contents, |
626 const std::string& sub_page) { | 623 const std::string& sub_page) { |
627 if (!continue_url_.is_empty()) { | 624 if (!continue_url_.is_empty()) { |
628 // The observer deletes itself once it's done. | 625 // The observer deletes itself once it's done. |
629 DCHECK(!sub_page.empty()); | 626 DCHECK(!sub_page.empty()); |
630 new OneClickSigninSyncObserver(contents, continue_url_); | 627 new OneClickSigninSyncObserver(contents, continue_url_); |
631 } | 628 } |
(...skipping 14 matching lines...) Expand all Loading... |
646 false /* user_gesture */); | 643 false /* user_gesture */); |
647 } | 644 } |
648 | 645 |
649 void OneClickSigninSyncStarter::LoadContinueUrl() { | 646 void OneClickSigninSyncStarter::LoadContinueUrl() { |
650 web_contents()->GetController().LoadURL( | 647 web_contents()->GetController().LoadURL( |
651 continue_url_, | 648 continue_url_, |
652 content::Referrer(), | 649 content::Referrer(), |
653 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 650 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
654 std::string()); | 651 std::string()); |
655 } | 652 } |
OLD | NEW |