| 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/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 | 10 |
| 11 #if defined(ENABLE_CONFIGURATION_POLICY) | 11 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 12 #include "chrome/browser/policy/cloud/user_policy_signin_service.h" | 12 #include "chrome/browser/policy/cloud/user_policy_signin_service.h" |
| 13 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h" | 13 #include "chrome/browser/policy/cloud/user_policy_signin_service_factory.h" |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/profiles/profile_info_cache.h" | 17 #include "chrome/browser/profiles/profile_info_cache.h" |
| 18 #include "chrome/browser/profiles/profile_io_data.h" | 18 #include "chrome/browser/profiles/profile_io_data.h" |
| 19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/browser/profiles/profile_window.h" | 20 #include "chrome/browser/profiles/profile_window.h" |
| 21 #include "chrome/browser/signin/signin_manager.h" | 21 #include "chrome/browser/signin/signin_manager.h" |
| 22 #include "chrome/browser/signin/signin_manager_factory.h" | 22 #include "chrome/browser/signin/signin_manager_factory.h" |
| 23 #include "chrome/browser/sync/profile_sync_service.h" | 23 #include "chrome/browser/sync/profile_sync_service.h" |
| 24 #include "chrome/browser/sync/profile_sync_service_factory.h" | 24 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 25 #include "chrome/browser/sync/sync_prefs.h" | |
| 26 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| 27 #include "chrome/browser/ui/browser_dialogs.h" | 26 #include "chrome/browser/ui/browser_dialogs.h" |
| 28 #include "chrome/browser/ui/browser_finder.h" | 27 #include "chrome/browser/ui/browser_finder.h" |
| 29 #include "chrome/browser/ui/browser_list.h" | 28 #include "chrome/browser/ui/browser_list.h" |
| 30 #include "chrome/browser/ui/browser_navigator.h" | 29 #include "chrome/browser/ui/browser_navigator.h" |
| 31 #include "chrome/browser/ui/browser_tabstrip.h" | 30 #include "chrome/browser/ui/browser_tabstrip.h" |
| 32 #include "chrome/browser/ui/browser_window.h" | 31 #include "chrome/browser/ui/browser_window.h" |
| 33 #include "chrome/browser/ui/chrome_pages.h" | 32 #include "chrome/browser/ui/chrome_pages.h" |
| 34 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 33 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 35 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 34 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 36 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 35 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 37 #include "chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.h" | 36 #include "chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.h" |
| 38 #include "chrome/common/profile_management_switches.h" | 37 #include "chrome/common/profile_management_switches.h" |
| 39 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
| 39 #include "components/sync_driver/sync_prefs.h" |
| 40 #include "grit/chromium_strings.h" | 40 #include "grit/chromium_strings.h" |
| 41 #include "grit/generated_resources.h" | 41 #include "grit/generated_resources.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
| 43 #include "ui/base/resource/resource_bundle.h" | 43 #include "ui/base/resource/resource_bundle.h" |
| 44 | 44 |
| 45 OneClickSigninSyncStarter::OneClickSigninSyncStarter( | 45 OneClickSigninSyncStarter::OneClickSigninSyncStarter( |
| 46 Profile* profile, | 46 Profile* profile, |
| 47 Browser* browser, | 47 Browser* browser, |
| 48 const std::string& session_index, | 48 const std::string& session_index, |
| 49 const std::string& email, | 49 const std::string& email, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 signin_tracker_.reset(new SigninTracker(profile_, this)); | 106 signin_tracker_.reset(new SigninTracker(profile_, this)); |
| 107 | 107 |
| 108 // Let the sync service know that setup is in progress so it doesn't start | 108 // Let the sync service know that setup is in progress so it doesn't start |
| 109 // syncing until the user has finished any configuration. | 109 // syncing until the user has finished any configuration. |
| 110 ProfileSyncService* profile_sync_service = GetProfileSyncService(); | 110 ProfileSyncService* profile_sync_service = GetProfileSyncService(); |
| 111 if (profile_sync_service) | 111 if (profile_sync_service) |
| 112 profile_sync_service->SetSetupInProgress(true); | 112 profile_sync_service->SetSetupInProgress(true); |
| 113 | 113 |
| 114 // Make sure the syncing is not suppressed, otherwise the SigninManager | 114 // Make sure the syncing is not suppressed, otherwise the SigninManager |
| 115 // will not be able to complete sucessfully. | 115 // will not be able to complete sucessfully. |
| 116 browser_sync::SyncPrefs sync_prefs(profile_->GetPrefs()); | 116 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); |
| 117 sync_prefs.SetStartSuppressed(false); | 117 sync_prefs.SetStartSuppressed(false); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void OneClickSigninSyncStarter::ConfirmSignin(const std::string& oauth_token) { | 120 void OneClickSigninSyncStarter::ConfirmSignin(const std::string& oauth_token) { |
| 121 DCHECK(!oauth_token.empty()); | 121 DCHECK(!oauth_token.empty()); |
| 122 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 122 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
| 123 // If this is a new signin (no authenticated username yet) try loading | 123 // If this is a new signin (no authenticated username yet) try loading |
| 124 // policy for this user now, before any signed in services are initialized. | 124 // policy for this user now, before any signed in services are initialized. |
| 125 if (signin->GetAuthenticatedUsername().empty()) { | 125 if (signin->GetAuthenticatedUsername().empty()) { |
| 126 #if defined(ENABLE_CONFIGURATION_POLICY) | 126 #if defined(ENABLE_CONFIGURATION_POLICY) |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 false); | 520 false); |
| 521 contents->OpenURL(params); | 521 contents->OpenURL(params); |
| 522 | 522 |
| 523 // Activate the tab. | 523 // Activate the tab. |
| 524 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 524 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
| 525 int content_index = | 525 int content_index = |
| 526 browser->tab_strip_model()->GetIndexOfWebContents(contents); | 526 browser->tab_strip_model()->GetIndexOfWebContents(contents); |
| 527 browser->tab_strip_model()->ActivateTabAt(content_index, | 527 browser->tab_strip_model()->ActivateTabAt(content_index, |
| 528 false /* user_gesture */); | 528 false /* user_gesture */); |
| 529 } | 529 } |
| OLD | NEW |