| OLD | NEW |
| 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/sync/profile_sync_service.h" | 5 #include "chrome/browser/sync/profile_sync_service.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 141 } |
| 142 | 142 |
| 143 RegisterAuthNotifications(); | 143 RegisterAuthNotifications(); |
| 144 | 144 |
| 145 // In Chrome, we integrate a SigninManager which works with the sync | 145 // In Chrome, we integrate a SigninManager which works with the sync |
| 146 // setup wizard to kick off the TokenService. CrOS does its own plumbing | 146 // setup wizard to kick off the TokenService. CrOS does its own plumbing |
| 147 // for the TokenService. | 147 // for the TokenService. |
| 148 if (cros_user_.empty()) { | 148 if (cros_user_.empty()) { |
| 149 // Will load tokens from DB and broadcast Token events after. | 149 // Will load tokens from DB and broadcast Token events after. |
| 150 // Note: We rely on signin_ != NULL unless !cros_user_.empty(). | 150 // Note: We rely on signin_ != NULL unless !cros_user_.empty(). |
| 151 signin_.reset(new SigninManager()); | 151 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 152 switches::kEnableSyncOAuth)) { |
| 153 signin_.reset(SigninManager::CreateSigninManager( |
| 154 SigninManager::kOAuthVariant)); |
| 155 } else { |
| 156 signin_.reset(SigninManager::CreateSigninManager()); |
| 157 } |
| 152 signin_->Initialize(profile_); | 158 signin_->Initialize(profile_); |
| 153 } | 159 } |
| 154 | 160 |
| 155 if (!HasSyncSetupCompleted()) { | 161 if (!HasSyncSetupCompleted()) { |
| 156 DisableForUser(); // Clean up in case of previous crash / setup abort. | 162 DisableForUser(); // Clean up in case of previous crash / setup abort. |
| 157 | 163 |
| 158 // Under ChromeOS, just autostart it anyway if creds are here and start | 164 // Under ChromeOS, just autostart it anyway if creds are here and start |
| 159 // is not being suppressed by preferences. | 165 // is not being suppressed by preferences. |
| 160 if (!cros_user_.empty() && | 166 if (!cros_user_.empty() && |
| 161 !profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart) && | 167 !profile_->GetPrefs()->GetBoolean(prefs::kSyncSuppressStart) && |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 last_attempted_user_email_ = username; | 791 last_attempted_user_email_ = username; |
| 786 is_auth_in_progress_ = true; | 792 is_auth_in_progress_ = true; |
| 787 NotifyObservers(); | 793 NotifyObservers(); |
| 788 | 794 |
| 789 auth_start_time_ = base::TimeTicks::Now(); | 795 auth_start_time_ = base::TimeTicks::Now(); |
| 790 | 796 |
| 791 if (!signin_.get()) { | 797 if (!signin_.get()) { |
| 792 // In ChromeOS we sign in during login, so we do not instantiate signin_. | 798 // In ChromeOS we sign in during login, so we do not instantiate signin_. |
| 793 // If this function gets called, we need to re-authenticate (e.g. for | 799 // If this function gets called, we need to re-authenticate (e.g. for |
| 794 // two factor signin), so instantiante signin_ here. | 800 // two factor signin), so instantiante signin_ here. |
| 795 signin_.reset(new SigninManager()); | 801 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 802 switches::kEnableSyncOAuth)) { |
| 803 signin_.reset(SigninManager::CreateSigninManager( |
| 804 SigninManager::kOAuthVariant)); |
| 805 } else { |
| 806 signin_.reset(SigninManager::CreateSigninManager()); |
| 807 } |
| 796 signin_->Initialize(profile_); | 808 signin_->Initialize(profile_); |
| 797 } | 809 } |
| 798 | 810 |
| 799 if (!access_code.empty()) { | 811 if (!access_code.empty()) { |
| 800 signin_->ProvideSecondFactorAccessCode(access_code); | 812 signin_->ProvideSecondFactorAccessCode(access_code); |
| 801 return; | 813 return; |
| 802 } | 814 } |
| 803 | 815 |
| 804 if (!signin_->GetUsername().empty()) { | 816 if (!signin_->GetUsername().empty()) { |
| 805 signin_->SignOut(); | 817 signin_->SignOut(); |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1259 // is initialized, all enabled data types are consistent with one | 1271 // is initialized, all enabled data types are consistent with one |
| 1260 // another, and no unrecoverable error has transpired. | 1272 // another, and no unrecoverable error has transpired. |
| 1261 if (unrecoverable_error_detected_) | 1273 if (unrecoverable_error_detected_) |
| 1262 return false; | 1274 return false; |
| 1263 | 1275 |
| 1264 if (!data_type_manager_.get()) | 1276 if (!data_type_manager_.get()) |
| 1265 return false; | 1277 return false; |
| 1266 | 1278 |
| 1267 return data_type_manager_->state() == DataTypeManager::CONFIGURED; | 1279 return data_type_manager_->state() == DataTypeManager::CONFIGURED; |
| 1268 } | 1280 } |
| OLD | NEW |