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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 | 10 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 } | 292 } |
293 } | 293 } |
294 delete this; | 294 delete this; |
295 } | 295 } |
296 | 296 |
297 void OneClickSigninSyncStarter::SigninSuccess() { | 297 void OneClickSigninSyncStarter::SigninSuccess() { |
298 ProfileSyncService* profile_sync_service = GetProfileSyncService(); | 298 ProfileSyncService* profile_sync_service = GetProfileSyncService(); |
299 switch (start_mode_) { | 299 switch (start_mode_) { |
300 case SYNC_WITH_DEFAULT_SETTINGS: | 300 case SYNC_WITH_DEFAULT_SETTINGS: |
301 if (profile_sync_service) { | 301 if (profile_sync_service) { |
302 // Just kick off the sync machine, no need to configure it first. | 302 if (!profile_sync_service->IsManaged()) { |
Andrew T Wilson (Slow)
2013/05/24 15:13:10
If you move IsManaged() into IsSyncAccessible(), t
pavely
2013/05/24 22:17:11
I need pointer to PSS to call SetSetupInProgress(f
| |
303 profile_sync_service->OnUserChoseDatatypes(true, | 303 // Just kick off the sync machine, no need to configure it first. |
304 syncer::ModelTypeSet()); | 304 profile_sync_service->OnUserChoseDatatypes(true, |
305 profile_sync_service->SetSyncSetupCompleted(); | 305 syncer::ModelTypeSet()); |
306 profile_sync_service->SetSyncSetupCompleted(); | |
307 } | |
306 profile_sync_service->SetSetupInProgress(false); | 308 profile_sync_service->SetSetupInProgress(false); |
307 } | 309 } |
308 if (confirmation_required_ == CONFIRM_AFTER_SIGNIN) { | 310 if (confirmation_required_ == CONFIRM_AFTER_SIGNIN) { |
309 string16 message; | 311 string16 message; |
310 if (!profile_sync_service) { | 312 if (!profile_sync_service || profile_sync_service->IsManaged()) { |
311 // Sync is disabled by policy. | 313 // Sync is disabled by policy. |
312 message = l10n_util::GetStringUTF16( | 314 message = l10n_util::GetStringUTF16( |
313 IDS_ONE_CLICK_SIGNIN_BUBBLE_SYNC_DISABLED_MESSAGE); | 315 IDS_ONE_CLICK_SIGNIN_BUBBLE_SYNC_DISABLED_MESSAGE); |
314 } | 316 } |
315 DisplayFinalConfirmationBubble(message); | 317 DisplayFinalConfirmationBubble(message); |
316 } | 318 } |
317 break; | 319 break; |
318 case CONFIGURE_SYNC_FIRST: | 320 case CONFIGURE_SYNC_FIRST: |
319 ConfigureSync(); | 321 ConfigureSync(); |
320 break; | 322 break; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 // Give the user a chance to configure things. We don't clear the | 355 // Give the user a chance to configure things. We don't clear the |
354 // ProfileSyncService::setup_in_progress flag because we don't want sync | 356 // ProfileSyncService::setup_in_progress flag because we don't want sync |
355 // to start up until after the configure UI is displayed (the configure UI | 357 // to start up until after the configure UI is displayed (the configure UI |
356 // will clear the flag when the user is done setting up sync). | 358 // will clear the flag when the user is done setting up sync). |
357 ProfileSyncService* profile_sync_service = GetProfileSyncService(); | 359 ProfileSyncService* profile_sync_service = GetProfileSyncService(); |
358 LoginUIService* login_ui = LoginUIServiceFactory::GetForProfile(profile_); | 360 LoginUIService* login_ui = LoginUIServiceFactory::GetForProfile(profile_); |
359 if (login_ui->current_login_ui()) { | 361 if (login_ui->current_login_ui()) { |
360 login_ui->current_login_ui()->FocusUI(); | 362 login_ui->current_login_ui()->FocusUI(); |
361 } else { | 363 } else { |
362 EnsureBrowser(); | 364 EnsureBrowser(); |
363 if (profile_sync_service) { | 365 if (profile_sync_service && !profile_sync_service->IsManaged()) { |
364 // Need to navigate to the settings page and display the sync UI. | 366 // Need to navigate to the settings page and display the sync UI. |
365 if (force_same_tab_navigation_) { | 367 if (force_same_tab_navigation_) { |
366 ShowSyncSettingsPageOnSameTab(); | 368 ShowSyncSettingsPageOnSameTab(); |
367 } else { | 369 } else { |
368 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage); | 370 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage); |
369 } | 371 } |
370 } else { | 372 } else { |
371 // Sync is disabled - just display the settings page. | 373 // Sync is disabled - just display the settings page. |
372 chrome::ShowSettings(browser_); | 374 chrome::ShowSettings(browser_); |
373 } | 375 } |
374 } | 376 } |
375 } | 377 } |
376 | 378 |
377 ProfileSyncService* OneClickSigninSyncStarter::GetProfileSyncService() { | 379 ProfileSyncService* OneClickSigninSyncStarter::GetProfileSyncService() { |
378 ProfileSyncService* service = NULL; | 380 ProfileSyncService* service = NULL; |
379 if (profile_->IsSyncAccessible()) | 381 if (profile_->IsSyncAccessible()) |
380 service = ProfileSyncServiceFactory::GetForProfile(profile_); | 382 service = ProfileSyncServiceFactory::GetForProfile(profile_); |
381 return service; | 383 return service; |
382 } | 384 } |
383 | 385 |
384 void OneClickSigninSyncStarter::ShowSyncSettingsPageOnSameTab() { | 386 void OneClickSigninSyncStarter::ShowSyncSettingsPageOnSameTab() { |
385 std::string url = std::string(chrome::kChromeUISettingsURL) + | 387 std::string url = std::string(chrome::kChromeUISettingsURL) + |
386 chrome::kSyncSetupSubPage; | 388 chrome::kSyncSetupSubPage; |
387 chrome::NavigateParams params( | 389 chrome::NavigateParams params( |
388 browser_, GURL(url), content::PAGE_TRANSITION_AUTO_TOPLEVEL); | 390 browser_, GURL(url), content::PAGE_TRANSITION_AUTO_TOPLEVEL); |
389 params.disposition = CURRENT_TAB; | 391 params.disposition = CURRENT_TAB; |
390 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 392 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
391 chrome::Navigate(¶ms); | 393 chrome::Navigate(¶ms); |
392 } | 394 } |
OLD | NEW |