| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/webui/signin/inline_login_handler_impl.h" | 5 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 379 |
| 380 InvestigatorDependencyProvider provider(profile_); | 380 InvestigatorDependencyProvider provider(profile_); |
| 381 InvestigatedScenario scenario = | 381 InvestigatedScenario scenario = |
| 382 SigninInvestigator(email_, gaia_id_, &provider).Investigate(); | 382 SigninInvestigator(email_, gaia_id_, &provider).Investigate(); |
| 383 | 383 |
| 384 // TODO(skym): Warn for high risk upgrade scenario, crbug.com/572754. | 384 // TODO(skym): Warn for high risk upgrade scenario, crbug.com/572754. |
| 385 if (scenario != InvestigatedScenario::DIFFERENT_ACCOUNT) { | 385 if (scenario != InvestigatedScenario::DIFFERENT_ACCOUNT) { |
| 386 return false; | 386 return false; |
| 387 } | 387 } |
| 388 | 388 |
| 389 Browser* browser = chrome::FindLastActiveWithProfile( | 389 Browser* browser = chrome::FindLastActiveWithProfile(profile_); |
| 390 profile_, chrome::GetActiveDesktop()); | |
| 391 content::WebContents* web_contents = | 390 content::WebContents* web_contents = |
| 392 browser->tab_strip_model()->GetActiveWebContents(); | 391 browser->tab_strip_model()->GetActiveWebContents(); |
| 393 | 392 |
| 394 ConfirmEmailDialogDelegate::AskForConfirmation( | 393 ConfirmEmailDialogDelegate::AskForConfirmation( |
| 395 web_contents, | 394 web_contents, |
| 396 last_email, | 395 last_email, |
| 397 email_, | 396 email_, |
| 398 base::Bind(&InlineSigninHelper::ConfirmEmailAction, | 397 base::Bind(&InlineSigninHelper::ConfirmEmailAction, |
| 399 base::Unretained(this), | 398 base::Unretained(this), |
| 400 web_contents, | 399 web_contents, |
| 401 refresh_token, | 400 refresh_token, |
| 402 confirmation_required, | 401 confirmation_required, |
| 403 start_mode)); | 402 start_mode)); |
| 404 return true; | 403 return true; |
| 405 } | 404 } |
| 406 | 405 |
| 407 void InlineSigninHelper::ConfirmEmailAction( | 406 void InlineSigninHelper::ConfirmEmailAction( |
| 408 content::WebContents* web_contents, | 407 content::WebContents* web_contents, |
| 409 const std::string& refresh_token, | 408 const std::string& refresh_token, |
| 410 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required, | 409 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required, |
| 411 OneClickSigninSyncStarter::StartSyncMode start_mode, | 410 OneClickSigninSyncStarter::StartSyncMode start_mode, |
| 412 InlineSigninHelper::Action action) { | 411 InlineSigninHelper::Action action) { |
| 413 Browser* browser = chrome::FindLastActiveWithProfile( | 412 Browser* browser = chrome::FindLastActiveWithProfile(profile_); |
| 414 profile_, chrome::GetActiveDesktop()); | |
| 415 switch (action) { | 413 switch (action) { |
| 416 case InlineSigninHelper::CREATE_NEW_USER: | 414 case InlineSigninHelper::CREATE_NEW_USER: |
| 417 content::RecordAction( | 415 content::RecordAction( |
| 418 base::UserMetricsAction("Signin_ImportDataPrompt_DontImport")); | 416 base::UserMetricsAction("Signin_ImportDataPrompt_DontImport")); |
| 419 if (handler_) { | 417 if (handler_) { |
| 420 handler_->SyncStarterCallback( | 418 handler_->SyncStarterCallback( |
| 421 OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); | 419 OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); |
| 422 } | 420 } |
| 423 chrome::ShowSettingsSubPage(browser, | 421 chrome::ShowSettingsSubPage(browser, |
| 424 std::string(chrome::kCreateProfileSubPage)); | 422 std::string(chrome::kCreateProfileSubPage)); |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 Browser* browser = GetDesktopBrowser(); | 850 Browser* browser = GetDesktopBrowser(); |
| 853 if (browser && !error_msg.empty()) { | 851 if (browser && !error_msg.empty()) { |
| 854 LoginUIServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> | 852 LoginUIServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> |
| 855 DisplayLoginResult(browser, base::UTF8ToUTF16(error_msg)); | 853 DisplayLoginResult(browser, base::UTF8ToUTF16(error_msg)); |
| 856 } | 854 } |
| 857 } | 855 } |
| 858 | 856 |
| 859 Browser* InlineLoginHandlerImpl::GetDesktopBrowser() { | 857 Browser* InlineLoginHandlerImpl::GetDesktopBrowser() { |
| 860 Browser* browser = chrome::FindBrowserWithWebContents( | 858 Browser* browser = chrome::FindBrowserWithWebContents( |
| 861 web_ui()->GetWebContents()); | 859 web_ui()->GetWebContents()); |
| 862 if (!browser) { | 860 if (!browser) |
| 863 browser = chrome::FindLastActiveWithProfile( | 861 browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); |
| 864 Profile::FromWebUI(web_ui()), chrome::GetActiveDesktop()); | |
| 865 } | |
| 866 return browser; | 862 return browser; |
| 867 } | 863 } |
| 868 | 864 |
| 869 void InlineLoginHandlerImpl::SyncStarterCallback( | 865 void InlineLoginHandlerImpl::SyncStarterCallback( |
| 870 OneClickSigninSyncStarter::SyncSetupResult result) { | 866 OneClickSigninSyncStarter::SyncSetupResult result) { |
| 871 content::WebContents* contents = web_ui()->GetWebContents(); | 867 content::WebContents* contents = web_ui()->GetWebContents(); |
| 872 | 868 |
| 873 if (contents->GetController().GetPendingEntry()) { | 869 if (contents->GetController().GetPendingEntry()) { |
| 874 // Do nothing if a navigation is pending, since this call can be triggered | 870 // Do nothing if a navigation is pending, since this call can be triggered |
| 875 // from DidStartLoading. This avoids deleting the pending entry while we are | 871 // from DidStartLoading. This avoids deleting the pending entry while we are |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 } | 905 } |
| 910 | 906 |
| 911 if (show_account_management) { | 907 if (show_account_management) { |
| 912 browser->window()->ShowAvatarBubbleFromAvatarButton( | 908 browser->window()->ShowAvatarBubbleFromAvatarButton( |
| 913 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, | 909 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, |
| 914 signin::ManageAccountsParams(), | 910 signin::ManageAccountsParams(), |
| 915 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN); | 911 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN); |
| 916 } | 912 } |
| 917 } | 913 } |
| 918 } | 914 } |
| OLD | NEW |