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

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_sync_starter.cc

Issue 447883002: Make sure sync setup completes when signing in from the avatar bubble with modal warnings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 4 months 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
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_sync_starter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 if (sync_starter_ != NULL) 188
189 if (sync_starter_ != NULL) {
190 // If the user signs in from the new avatar bubble, the enterprise
191 // confirmation dialog would dismiss the avatar bubble, thus it won't show
192 // any confirmation upon sign in completes. This cofirmation dialog already
193 // mentions that user data would be synced, thus we just start sync
194 // immediately.
195
196 // TODO(guohui): add a sync settings link to allow user to configure sync
197 // settings before sync starts.
198 if (sync_starter_->GetStartSyncMode() == CONFIRM_SYNC_SETTINGS_FIRST)
199 sync_starter_->SetStartSyncMode(SYNC_WITH_DEFAULT_SETTINGS);
189 sync_starter_->LoadPolicyWithCachedCredentials(); 200 sync_starter_->LoadPolicyWithCachedCredentials();
201 }
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);
194 if (sync_starter_ != NULL) 206
207 if (sync_starter_ != NULL) {
208 // TODO(guohui): add a sync settings link to allow user to configure sync
209 // settings before sync starts.
210 if (sync_starter_->GetStartSyncMode() == CONFIRM_SYNC_SETTINGS_FIRST)
211 sync_starter_->SetStartSyncMode(SYNC_WITH_DEFAULT_SETTINGS);
195 sync_starter_->CreateNewSignedInProfile(); 212 sync_starter_->CreateNewSignedInProfile();
213 }
214 }
215
216 void OneClickSigninSyncStarter::SetStartSyncMode(StartSyncMode start_mode) {
217 start_mode_ = start_mode;
218 }
219
220 OneClickSigninSyncStarter::StartSyncMode
221 OneClickSigninSyncStarter::GetStartSyncMode() {
222 return start_mode_;
196 } 223 }
197 224
198 void OneClickSigninSyncStarter::OnRegisteredForPolicy( 225 void OneClickSigninSyncStarter::OnRegisteredForPolicy(
199 const std::string& dm_token, const std::string& client_id) { 226 const std::string& dm_token, const std::string& client_id) {
200 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); 227 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
201 // If there's no token for the user (policy registration did not succeed) just 228 // If there's no token for the user (policy registration did not succeed) just
202 // finish signing in. 229 // finish signing in.
203 if (dm_token.empty()) { 230 if (dm_token.empty()) {
204 DVLOG(1) << "Policy registration failed"; 231 DVLOG(1) << "Policy registration failed";
205 ConfirmAndSignin(); 232 ConfirmAndSignin();
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 } 389 }
363 } 390 }
364 391
365 void OneClickSigninSyncStarter::UntrustedSigninConfirmed( 392 void OneClickSigninSyncStarter::UntrustedSigninConfirmed(
366 StartSyncMode response) { 393 StartSyncMode response) {
367 if (response == UNDO_SYNC) { 394 if (response == UNDO_SYNC) {
368 CancelSigninAndDelete(); // This statement frees this object. 395 CancelSigninAndDelete(); // This statement frees this object.
369 } else { 396 } else {
370 // If the user clicked the "Advanced" link in the confirmation dialog, then 397 // 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. 398 // override the current start_mode_ to bring up the advanced sync settings.
399
400 // If the user signs in from the new avatar bubble, the untrusted dialog
401 // would dismiss the avatar bubble, thus it won't show any confirmation upon
402 // sign in completes. This dialog already has a settings link, thus we just
403 // start sync immediately .
404
372 if (response == CONFIGURE_SYNC_FIRST) 405 if (response == CONFIGURE_SYNC_FIRST)
373 start_mode_ = response; 406 start_mode_ = response;
407 else if (start_mode_ == CONFIRM_SYNC_SETTINGS_FIRST)
408 start_mode_ = SYNC_WITH_DEFAULT_SETTINGS;
409
374 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); 410 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_);
375 signin->CompletePendingSignin(); 411 signin->CompletePendingSignin();
376 } 412 }
377 } 413 }
378 414
379 void OneClickSigninSyncStarter::OnSyncConfirmationUIClosed( 415 void OneClickSigninSyncStarter::OnSyncConfirmationUIClosed(
380 bool configure_sync_first) { 416 bool configure_sync_first) {
381 if (configure_sync_first) { 417 if (configure_sync_first) {
382 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage); 418 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage);
383 } else { 419 } else {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 false /* user_gesture */); 633 false /* user_gesture */);
598 } 634 }
599 635
600 void OneClickSigninSyncStarter::LoadContinueUrl() { 636 void OneClickSigninSyncStarter::LoadContinueUrl() {
601 web_contents()->GetController().LoadURL( 637 web_contents()->GetController().LoadURL(
602 continue_url_, 638 continue_url_,
603 content::Referrer(), 639 content::Referrer(),
604 content::PAGE_TRANSITION_AUTO_TOPLEVEL, 640 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
605 std::string()); 641 std::string());
606 } 642 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_sync_starter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698