| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 OneClickSigninSyncStarter::OneClickSigninSyncStarter( | 72 OneClickSigninSyncStarter::OneClickSigninSyncStarter( |
| 73 Profile* profile, | 73 Profile* profile, |
| 74 Browser* browser, | 74 Browser* browser, |
| 75 const std::string& gaia_id, | 75 const std::string& gaia_id, |
| 76 const std::string& email, | 76 const std::string& email, |
| 77 const std::string& password, | 77 const std::string& password, |
| 78 const std::string& refresh_token, | 78 const std::string& refresh_token, |
| 79 StartSyncMode start_mode, | 79 StartSyncMode start_mode, |
| 80 content::WebContents* web_contents, | 80 content::WebContents* web_contents, |
| 81 ConfirmationRequired confirmation_required, | 81 ConfirmationRequired confirmation_required, |
| 82 const GURL& current_url, |
| 82 const GURL& continue_url, | 83 const GURL& continue_url, |
| 83 Callback sync_setup_completed_callback) | 84 Callback sync_setup_completed_callback) |
| 84 : content::WebContentsObserver(web_contents), | 85 : content::WebContentsObserver(web_contents), |
| 85 profile_(NULL), | 86 profile_(NULL), |
| 86 start_mode_(start_mode), | 87 start_mode_(start_mode), |
| 87 desktop_type_(chrome::HOST_DESKTOP_TYPE_NATIVE), | 88 desktop_type_(chrome::HOST_DESKTOP_TYPE_NATIVE), |
| 88 confirmation_required_(confirmation_required), | 89 confirmation_required_(confirmation_required), |
| 90 current_url_(current_url), |
| 89 continue_url_(continue_url), | 91 continue_url_(continue_url), |
| 90 sync_setup_completed_callback_(sync_setup_completed_callback), | 92 sync_setup_completed_callback_(sync_setup_completed_callback), |
| 91 weak_pointer_factory_(this) { | 93 weak_pointer_factory_(this) { |
| 92 DCHECK(profile); | 94 DCHECK(profile); |
| 93 DCHECK(web_contents || continue_url.is_empty()); | 95 DCHECK(web_contents || continue_url.is_empty()); |
| 94 BrowserList::AddObserver(this); | 96 BrowserList::AddObserver(this); |
| 95 Initialize(profile, browser); | 97 Initialize(profile, browser); |
| 96 | 98 |
| 97 // Policy is enabled, so pass in a callback to do extra policy-related UI | 99 // Policy is enabled, so pass in a callback to do extra policy-related UI |
| 98 // before signin completes. | 100 // before signin completes. |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 default: | 424 default: |
| 423 DisplayFinalConfirmationBubble(l10n_util::GetStringUTF16( | 425 DisplayFinalConfirmationBubble(l10n_util::GetStringUTF16( |
| 424 IDS_SYNC_ERROR_SIGNING_IN)); | 426 IDS_SYNC_ERROR_SIGNING_IN)); |
| 425 break; | 427 break; |
| 426 } | 428 } |
| 427 } | 429 } |
| 428 delete this; | 430 delete this; |
| 429 } | 431 } |
| 430 | 432 |
| 431 void OneClickSigninSyncStarter::SigninSuccess() { | 433 void OneClickSigninSyncStarter::SigninSuccess() { |
| 434 if (!current_url_.is_valid()) // Could be invalid for tests. |
| 435 return; |
| 436 signin_metrics::LogSigninAccessPointCompleted( |
| 437 signin::GetAccessPointForPromoURL(current_url_)); |
| 438 signin_metrics::LogSigninReason( |
| 439 signin::GetSigninReasonForPromoURL(current_url_)); |
| 432 } | 440 } |
| 433 | 441 |
| 434 void OneClickSigninSyncStarter::AccountAddedToCookie( | 442 void OneClickSigninSyncStarter::AccountAddedToCookie( |
| 435 const GoogleServiceAuthError& error) { | 443 const GoogleServiceAuthError& error) { |
| 436 // Regardless of whether the account was successfully added or not, | 444 // Regardless of whether the account was successfully added or not, |
| 437 // continue with sync starting. | 445 // continue with sync starting. |
| 438 | 446 |
| 439 if (!sync_setup_completed_callback_.is_null()) | 447 if (!sync_setup_completed_callback_.is_null()) |
| 440 sync_setup_completed_callback_.Run(SYNC_SETUP_SUCCESS); | 448 sync_setup_completed_callback_.Run(SYNC_SETUP_SUCCESS); |
| 441 | 449 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 false /* user_gesture */); | 613 false /* user_gesture */); |
| 606 } | 614 } |
| 607 | 615 |
| 608 void OneClickSigninSyncStarter::LoadContinueUrl() { | 616 void OneClickSigninSyncStarter::LoadContinueUrl() { |
| 609 web_contents()->GetController().LoadURL( | 617 web_contents()->GetController().LoadURL( |
| 610 continue_url_, | 618 continue_url_, |
| 611 content::Referrer(), | 619 content::Referrer(), |
| 612 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 620 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 613 std::string()); | 621 std::string()); |
| 614 } | 622 } |
| OLD | NEW |