| 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 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "ui/base/resource/resource_bundle.h" | 41 #include "ui/base/resource/resource_bundle.h" |
| 42 | 42 |
| 43 OneClickSigninSyncStarter::OneClickSigninSyncStarter( | 43 OneClickSigninSyncStarter::OneClickSigninSyncStarter( |
| 44 Profile* profile, | 44 Profile* profile, |
| 45 Browser* browser, | 45 Browser* browser, |
| 46 const std::string& session_index, | 46 const std::string& session_index, |
| 47 const std::string& email, | 47 const std::string& email, |
| 48 const std::string& password, | 48 const std::string& password, |
| 49 StartSyncMode start_mode, | 49 StartSyncMode start_mode, |
| 50 bool force_same_tab_navigation, | 50 bool force_same_tab_navigation, |
| 51 ConfirmationRequired confirmation_required) | 51 ConfirmationRequired confirmation_required, |
| 52 SyncPromoUI::Source source) |
| 52 : start_mode_(start_mode), | 53 : start_mode_(start_mode), |
| 53 force_same_tab_navigation_(force_same_tab_navigation), | 54 force_same_tab_navigation_(force_same_tab_navigation), |
| 54 confirmation_required_(confirmation_required), | 55 confirmation_required_(confirmation_required), |
| 56 source_(source), |
| 55 weak_pointer_factory_(this) { | 57 weak_pointer_factory_(this) { |
| 56 DCHECK(profile); | 58 DCHECK(profile); |
| 57 BrowserList::AddObserver(this); | 59 BrowserList::AddObserver(this); |
| 58 | 60 |
| 59 Initialize(profile, browser); | 61 Initialize(profile, browser); |
| 60 | 62 |
| 61 // Start the signin process using the cookies in the cookie jar. | 63 // Start the signin process using the cookies in the cookie jar. |
| 62 SigninManager* manager = SigninManagerFactory::GetForProfile(profile_); | 64 SigninManager* manager = SigninManagerFactory::GetForProfile(profile_); |
| 63 SigninManager::OAuthTokenFetchedCallback callback; | 65 SigninManager::OAuthTokenFetchedCallback callback; |
| 64 // Policy is enabled, so pass in a callback to do extra policy-related UI | 66 // Policy is enabled, so pass in a callback to do extra policy-related UI |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 } else { | 307 } else { |
| 306 // No confirmation required - just sign in the user. | 308 // No confirmation required - just sign in the user. |
| 307 signin->CompletePendingSignin(); | 309 signin->CompletePendingSignin(); |
| 308 } | 310 } |
| 309 } | 311 } |
| 310 | 312 |
| 311 void OneClickSigninSyncStarter::UntrustedSigninConfirmed( | 313 void OneClickSigninSyncStarter::UntrustedSigninConfirmed( |
| 312 StartSyncMode response) { | 314 StartSyncMode response) { |
| 313 if (response == UNDO_SYNC) { | 315 if (response == UNDO_SYNC) { |
| 314 CancelSigninAndDelete(); | 316 CancelSigninAndDelete(); |
| 317 // If this was not an interstitial signin, (i.e. it was a SAML signin) |
| 318 // then the browser page is now blank and should redirect to the NTP. |
| 319 if (source_ != SyncPromoUI::SOURCE_UNKNOWN) { |
| 320 EnsureBrowser(); |
| 321 chrome::NavigateParams params(browser_, GURL(chrome::kChromeUINewTabURL), |
| 322 content::PAGE_TRANSITION_AUTO_TOPLEVEL); |
| 323 params.disposition = CURRENT_TAB; |
| 324 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 325 chrome::Navigate(¶ms); |
| 326 } |
| 315 } else { | 327 } else { |
| 316 // If the user clicked the "Advanced" link in the confirmation dialog, then | 328 // If the user clicked the "Advanced" link in the confirmation dialog, then |
| 317 // override the current start_mode_ to bring up the advanced sync settings. | 329 // override the current start_mode_ to bring up the advanced sync settings. |
| 318 if (response == CONFIGURE_SYNC_FIRST) | 330 if (response == CONFIGURE_SYNC_FIRST) |
| 319 start_mode_ = response; | 331 start_mode_ = response; |
| 320 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 332 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
| 321 signin->CompletePendingSignin(); | 333 signin->CompletePendingSignin(); |
| 322 } | 334 } |
| 323 } | 335 } |
| 324 | 336 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 | 451 |
| 440 void OneClickSigninSyncStarter::ShowSyncSettingsPageOnSameTab() { | 452 void OneClickSigninSyncStarter::ShowSyncSettingsPageOnSameTab() { |
| 441 std::string url = std::string(chrome::kChromeUISettingsURL) + | 453 std::string url = std::string(chrome::kChromeUISettingsURL) + |
| 442 chrome::kSyncSetupSubPage; | 454 chrome::kSyncSetupSubPage; |
| 443 chrome::NavigateParams params( | 455 chrome::NavigateParams params( |
| 444 browser_, GURL(url), content::PAGE_TRANSITION_AUTO_TOPLEVEL); | 456 browser_, GURL(url), content::PAGE_TRANSITION_AUTO_TOPLEVEL); |
| 445 params.disposition = CURRENT_TAB; | 457 params.disposition = CURRENT_TAB; |
| 446 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 458 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 447 chrome::Navigate(¶ms); | 459 chrome::Navigate(¶ms); |
| 448 } | 460 } |
| OLD | NEW |