Index: chrome/browser/ui/webui/signin/sync_confirmation_handler.cc |
diff --git a/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc b/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc |
index b538951d47f26e5dc6aeec41d7fdde8ebaf10077..7b407aa94aaa6f3ebf048bb6e2324b914083ee88 100644 |
--- a/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc |
+++ b/chrome/browser/ui/webui/signin/sync_confirmation_handler.cc |
@@ -10,10 +10,10 @@ |
#include "chrome/browser/profiles/profile_avatar_icon_util.h" |
#include "chrome/browser/signin/account_tracker_service_factory.h" |
#include "chrome/browser/signin/signin_manager_factory.h" |
-#include "chrome/browser/ui/browser_finder.h" |
#include "chrome/browser/ui/browser_window.h" |
#include "chrome/browser/ui/signin_view_controller_delegate.h" |
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
+#include "chrome/browser/ui/webui/signin/signin_utils.h" |
#include "components/signin/core/browser/account_tracker_service.h" |
#include "content/public/browser/user_metrics.h" |
#include "content/public/browser/web_contents.h" |
@@ -64,13 +64,15 @@ void SyncConfirmationHandler::HandleGoToSettings(const base::ListValue* args) { |
void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) { |
did_user_explicitly_interact = true; |
content::RecordAction(base::UserMetricsAction("Signin_Undo_Signin")); |
- Browser* browser = GetDesktopBrowser(); |
- LoginUIServiceFactory::GetForProfile(browser->profile())-> |
- SyncConfirmationUIClosed(LoginUIService::ABORT_SIGNIN); |
- SigninManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()))->SignOut( |
- signin_metrics::ABORT_SIGNIN, |
- signin_metrics::SignoutDelete::IGNORE_METRIC); |
- browser->CloseModalSigninWindow(); |
+ Browser* browser = signin::GetDesktopBrowser(web_ui()); |
+ if (browser) { |
+ LoginUIServiceFactory::GetForProfile(browser->profile())-> |
+ SyncConfirmationUIClosed(LoginUIService::ABORT_SIGNIN); |
+ SigninManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()))->SignOut( |
+ signin_metrics::ABORT_SIGNIN, |
+ signin_metrics::SignoutDelete::IGNORE_METRIC); |
+ browser->CloseModalSigninWindow(); |
+ } |
} |
void SyncConfirmationHandler::SetUserImageURL(const std::string& picture_url) { |
@@ -92,26 +94,22 @@ void SyncConfirmationHandler::OnAccountUpdated(const AccountInfo& info) { |
SetUserImageURL(info.picture_url); |
} |
-Browser* SyncConfirmationHandler::GetDesktopBrowser() { |
- Browser* browser = chrome::FindBrowserWithWebContents( |
- web_ui()->GetWebContents()); |
- if (!browser) |
- browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); |
- DCHECK(browser); |
- return browser; |
-} |
- |
void SyncConfirmationHandler::CloseModalSigninWindow( |
LoginUIService::SyncConfirmationUIClosedResult result) { |
- Browser* browser = GetDesktopBrowser(); |
- LoginUIServiceFactory::GetForProfile(browser->profile())-> |
- SyncConfirmationUIClosed(result); |
- browser->CloseModalSigninWindow(); |
+ Browser* browser = signin::GetDesktopBrowser(web_ui()); |
+ if (browser) { |
+ LoginUIServiceFactory::GetForProfile(browser->profile())-> |
+ SyncConfirmationUIClosed(result); |
+ browser->CloseModalSigninWindow(); |
+ } |
} |
void SyncConfirmationHandler::HandleInitializedWithSize( |
const base::ListValue* args) { |
- Browser* browser = GetDesktopBrowser(); |
+ Browser* browser = signin::GetDesktopBrowser(web_ui()); |
+ if (!browser) |
+ return; |
+ |
Profile* profile = browser->profile(); |
std::vector<AccountInfo> accounts = |
AccountTrackerServiceFactory::GetForProfile(profile)->GetAccounts(); |
@@ -126,12 +124,7 @@ void SyncConfirmationHandler::HandleInitializedWithSize( |
else |
SetUserImageURL(primary_account_info.picture_url); |
- double height; |
- bool success = args->GetDouble(0, &height); |
- DCHECK(success); |
- |
- browser->signin_view_controller()->SetModalSigninHeight( |
- static_cast<int>(height)); |
+ signin::SetInitializedModalHeight(web_ui(), args); |
// After the dialog is shown, some platforms might have an element focused. |
// To be consistent, clear the focused element on all platforms. |