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 sync_blocker_ = profile_sync_service->GetSetupInProgressHandle(); | 136 profile_sync_service->SetSetupInProgress(true); |
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 sync_blocker_.reset(); | 618 ProfileSyncService* service = |
| 619 ProfileSyncServiceFactory::GetForProfile(profile_); |
| 620 if (service) |
| 621 service->SetSetupInProgress(false); |
619 } | 622 } |
620 | 623 |
621 void OneClickSigninSyncStarter::ShowSettingsPageInWebContents( | 624 void OneClickSigninSyncStarter::ShowSettingsPageInWebContents( |
622 content::WebContents* contents, | 625 content::WebContents* contents, |
623 const std::string& sub_page) { | 626 const std::string& sub_page) { |
624 if (!continue_url_.is_empty()) { | 627 if (!continue_url_.is_empty()) { |
625 // The observer deletes itself once it's done. | 628 // The observer deletes itself once it's done. |
626 DCHECK(!sub_page.empty()); | 629 DCHECK(!sub_page.empty()); |
627 new OneClickSigninSyncObserver(contents, continue_url_); | 630 new OneClickSigninSyncObserver(contents, continue_url_); |
628 } | 631 } |
(...skipping 14 matching lines...) Expand all Loading... |
643 false /* user_gesture */); | 646 false /* user_gesture */); |
644 } | 647 } |
645 | 648 |
646 void OneClickSigninSyncStarter::LoadContinueUrl() { | 649 void OneClickSigninSyncStarter::LoadContinueUrl() { |
647 web_contents()->GetController().LoadURL( | 650 web_contents()->GetController().LoadURL( |
648 continue_url_, | 651 continue_url_, |
649 content::Referrer(), | 652 content::Referrer(), |
650 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 653 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
651 std::string()); | 654 std::string()); |
652 } | 655 } |
OLD | NEW |