| 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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 } | 178 } |
| 179 | 179 |
| 180 void OneClickSigninSyncStarter::SigninDialogDelegate::OnCancelSignin() { | 180 void OneClickSigninSyncStarter::SigninDialogDelegate::OnCancelSignin() { |
| 181 SetUserChoiceHistogram(SIGNIN_CHOICE_CANCEL); | 181 SetUserChoiceHistogram(SIGNIN_CHOICE_CANCEL); |
| 182 if (sync_starter_ != NULL) | 182 if (sync_starter_ != NULL) |
| 183 sync_starter_->CancelSigninAndDelete(); | 183 sync_starter_->CancelSigninAndDelete(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void OneClickSigninSyncStarter::SigninDialogDelegate::OnContinueSignin() { | 186 void OneClickSigninSyncStarter::SigninDialogDelegate::OnContinueSignin() { |
| 187 SetUserChoiceHistogram(SIGNIN_CHOICE_CONTINUE); | 187 SetUserChoiceHistogram(SIGNIN_CHOICE_CONTINUE); |
| 188 |
| 189 // If the user signs in from the new avatar bubble, the enterprise |
| 190 // confirmation dialog would dismiss the avatar bubble, thus it won't show any |
| 191 // confirmation upon sign in completes. This cofirmation dialog already |
| 192 // mentions that user data would be synced, thus we just start sync |
| 193 // immediately. |
| 194 |
| 195 // TODO(guohui): add a sync settings link to allow user to configure sync |
| 196 // settings before sync starts. |
| 197 if (start_mode == CONFIRM_SYNC_SETTINGS_FIRST) |
| 198 start_mode = SYNC_WITH_DEFAULT_SETTINGS; |
| 199 |
| 188 if (sync_starter_ != NULL) | 200 if (sync_starter_ != NULL) |
| 189 sync_starter_->LoadPolicyWithCachedCredentials(); | 201 sync_starter_->LoadPolicyWithCachedCredentials(); |
| 190 } | 202 } |
| 191 | 203 |
| 192 void OneClickSigninSyncStarter::SigninDialogDelegate::OnSigninWithNewProfile() { | 204 void OneClickSigninSyncStarter::SigninDialogDelegate::OnSigninWithNewProfile() { |
| 193 SetUserChoiceHistogram(SIGNIN_CHOICE_NEW_PROFILE); | 205 SetUserChoiceHistogram(SIGNIN_CHOICE_NEW_PROFILE); |
| 206 |
| 207 // TODO(guohui): add a sync settings link to allow user to configure sync |
| 208 // settings before sync starts. |
| 209 if (start_mode == CONFIRM_SYNC_SETTINGS_FIRST) |
| 210 start_mode = SYNC_WITH_DEFAULT_SETTINGS; |
| 211 |
| 194 if (sync_starter_ != NULL) | 212 if (sync_starter_ != NULL) |
| 195 sync_starter_->CreateNewSignedInProfile(); | 213 sync_starter_->CreateNewSignedInProfile(); |
| 196 } | 214 } |
| 197 | 215 |
| 198 void OneClickSigninSyncStarter::OnRegisteredForPolicy( | 216 void OneClickSigninSyncStarter::OnRegisteredForPolicy( |
| 199 const std::string& dm_token, const std::string& client_id) { | 217 const std::string& dm_token, const std::string& client_id) { |
| 200 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 218 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
| 201 // If there's no token for the user (policy registration did not succeed) just | 219 // If there's no token for the user (policy registration did not succeed) just |
| 202 // finish signing in. | 220 // finish signing in. |
| 203 if (dm_token.empty()) { | 221 if (dm_token.empty()) { |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 } | 380 } |
| 363 } | 381 } |
| 364 | 382 |
| 365 void OneClickSigninSyncStarter::UntrustedSigninConfirmed( | 383 void OneClickSigninSyncStarter::UntrustedSigninConfirmed( |
| 366 StartSyncMode response) { | 384 StartSyncMode response) { |
| 367 if (response == UNDO_SYNC) { | 385 if (response == UNDO_SYNC) { |
| 368 CancelSigninAndDelete(); // This statement frees this object. | 386 CancelSigninAndDelete(); // This statement frees this object. |
| 369 } else { | 387 } else { |
| 370 // If the user clicked the "Advanced" link in the confirmation dialog, then | 388 // If the user clicked the "Advanced" link in the confirmation dialog, then |
| 371 // override the current start_mode_ to bring up the advanced sync settings. | 389 // override the current start_mode_ to bring up the advanced sync settings. |
| 390 |
| 391 // If the user signs in from the new avatar bubble, the untrusted dialog |
| 392 // would dismiss the avatar bubble, thus it won't show any confirmation upon |
| 393 // sign in completes. This dialog already has a settings link, thus we just |
| 394 // start sync immediately . |
| 395 |
| 372 if (response == CONFIGURE_SYNC_FIRST) | 396 if (response == CONFIGURE_SYNC_FIRST) |
| 373 start_mode_ = response; | 397 start_mode_ = response; |
| 398 else if (start_mode_ == CONFIRM_SYNC_SETTINGS_FIRST) |
| 399 start_mode_ = SYNC_WITH_DEFAULT_SETTINGS |
| 400 |
| 374 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 401 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
| 375 signin->CompletePendingSignin(); | 402 signin->CompletePendingSignin(); |
| 376 } | 403 } |
| 377 } | 404 } |
| 378 | 405 |
| 379 void OneClickSigninSyncStarter::SigninFailed( | 406 void OneClickSigninSyncStarter::SigninFailed( |
| 380 const GoogleServiceAuthError& error) { | 407 const GoogleServiceAuthError& error) { |
| 381 if (!sync_setup_completed_callback_.is_null()) | 408 if (!sync_setup_completed_callback_.is_null()) |
| 382 sync_setup_completed_callback_.Run(SYNC_SETUP_FAILURE); | 409 sync_setup_completed_callback_.Run(SYNC_SETUP_FAILURE); |
| 383 | 410 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 false /* user_gesture */); | 607 false /* user_gesture */); |
| 581 } | 608 } |
| 582 | 609 |
| 583 void OneClickSigninSyncStarter::LoadContinueUrl() { | 610 void OneClickSigninSyncStarter::LoadContinueUrl() { |
| 584 web_contents()->GetController().LoadURL( | 611 web_contents()->GetController().LoadURL( |
| 585 continue_url_, | 612 continue_url_, |
| 586 content::Referrer(), | 613 content::Referrer(), |
| 587 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 614 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 588 std::string()); | 615 std::string()); |
| 589 } | 616 } |
| OLD | NEW |