| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/sync_confirmation_handler.h" | 5 #include "chrome/browser/ui/webui/signin/sync_confirmation_handler.h" |
| 6 | 6 |
| 7 #include <vector> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 10 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 9 #include "chrome/browser/signin/account_tracker_service_factory.h" | 11 #include "chrome/browser/signin/account_tracker_service_factory.h" |
| 10 #include "chrome/browser/signin/signin_manager_factory.h" | 12 #include "chrome/browser/signin/signin_manager_factory.h" |
| 11 #include "chrome/browser/ui/browser_finder.h" | 13 #include "chrome/browser/ui/browser_finder.h" |
| 12 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 15 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 14 #include "components/signin/core/browser/account_tracker_service.h" | 16 #include "components/signin/core/browser/account_tracker_service.h" |
| 15 #include "content/public/browser/user_metrics.h" | 17 #include "content/public/browser/user_metrics.h" |
| 16 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 34 base::Bind(&SyncConfirmationHandler::HandleUndo, base::Unretained(this))); | 36 base::Bind(&SyncConfirmationHandler::HandleUndo, base::Unretained(this))); |
| 35 web_ui()->RegisterMessageCallback("initialized", | 37 web_ui()->RegisterMessageCallback("initialized", |
| 36 base::Bind(&SyncConfirmationHandler::HandleInitialized, | 38 base::Bind(&SyncConfirmationHandler::HandleInitialized, |
| 37 base::Unretained(this))); | 39 base::Unretained(this))); |
| 38 web_ui()->RegisterMessageCallback("goToSettings", | 40 web_ui()->RegisterMessageCallback("goToSettings", |
| 39 base::Bind(&SyncConfirmationHandler::HandleGoToSettings, | 41 base::Bind(&SyncConfirmationHandler::HandleGoToSettings, |
| 40 base::Unretained(this))); | 42 base::Unretained(this))); |
| 41 } | 43 } |
| 42 | 44 |
| 43 void SyncConfirmationHandler::HandleConfirm(const base::ListValue* args) { | 45 void SyncConfirmationHandler::HandleConfirm(const base::ListValue* args) { |
| 44 CloseModalSigninWindow(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS); | 46 bool open_activity_controls_url = false; |
| 47 bool success = args->GetBoolean(0, &open_activity_controls_url); |
| 48 DCHECK(success); |
| 49 LoginUIService::SyncConfirmationUIClosedResult result = |
| 50 open_activity_controls_url ? |
| 51 LoginUIService::DEFAULT_SETTINGS_OPEN_ACTIVITY_CONTROLS_URL : |
| 52 LoginUIService::SYNC_WITH_DEFAULT_SETTINGS; |
| 53 CloseModalSigninWindow(result); |
| 45 } | 54 } |
| 46 | 55 |
| 47 void SyncConfirmationHandler::HandleGoToSettings(const base::ListValue* args) { | 56 void SyncConfirmationHandler::HandleGoToSettings(const base::ListValue* args) { |
| 48 CloseModalSigninWindow(LoginUIService::CONFIGURE_SYNC_FIRST); | 57 bool open_activity_controls_url = false; |
| 58 bool success = args->GetBoolean(0, &open_activity_controls_url); |
| 59 DCHECK(success); |
| 60 LoginUIService::SyncConfirmationUIClosedResult result = |
| 61 open_activity_controls_url ? |
| 62 LoginUIService::CONFIGURE_FIRST_OPEN_ACTIVITY_CONTROLS_URL : |
| 63 LoginUIService::CONFIGURE_SYNC_FIRST; |
| 64 CloseModalSigninWindow(result); |
| 49 } | 65 } |
| 50 | 66 |
| 51 void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) { | 67 void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) { |
| 52 content::RecordAction(base::UserMetricsAction("Signin_Undo_Signin")); | 68 content::RecordAction(base::UserMetricsAction("Signin_Undo_Signin")); |
| 53 Browser* browser = GetDesktopBrowser(); | 69 Browser* browser = GetDesktopBrowser(); |
| 54 LoginUIServiceFactory::GetForProfile(browser->profile())-> | 70 LoginUIServiceFactory::GetForProfile(browser->profile())-> |
| 55 SyncConfirmationUIClosed(LoginUIService::ABORT_SIGNIN); | 71 SyncConfirmationUIClosed(LoginUIService::ABORT_SIGNIN); |
| 56 SigninManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()))->SignOut( | 72 SigninManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()))->SignOut( |
| 57 signin_metrics::ABORT_SIGNIN, | 73 signin_metrics::ABORT_SIGNIN, |
| 58 signin_metrics::SignoutDelete::IGNORE_METRIC); | 74 signin_metrics::SignoutDelete::IGNORE_METRIC); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 Browser* SyncConfirmationHandler::GetDesktopBrowser() { | 114 Browser* SyncConfirmationHandler::GetDesktopBrowser() { |
| 99 Browser* browser = chrome::FindBrowserWithWebContents( | 115 Browser* browser = chrome::FindBrowserWithWebContents( |
| 100 web_ui()->GetWebContents()); | 116 web_ui()->GetWebContents()); |
| 101 if (!browser) | 117 if (!browser) |
| 102 browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); | 118 browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); |
| 103 DCHECK(browser); | 119 DCHECK(browser); |
| 104 return browser; | 120 return browser; |
| 105 } | 121 } |
| 106 | 122 |
| 107 void SyncConfirmationHandler::CloseModalSigninWindow( | 123 void SyncConfirmationHandler::CloseModalSigninWindow( |
| 108 LoginUIService::SyncConfirmationUIClosedResults results) { | 124 LoginUIService::SyncConfirmationUIClosedResult result) { |
| 109 Browser* browser = GetDesktopBrowser(); | 125 Browser* browser = GetDesktopBrowser(); |
| 110 LoginUIServiceFactory::GetForProfile(browser->profile())-> | 126 LoginUIServiceFactory::GetForProfile(browser->profile())-> |
| 111 SyncConfirmationUIClosed(results); | 127 SyncConfirmationUIClosed(result); |
| 112 browser->CloseModalSigninWindow(); | 128 browser->CloseModalSigninWindow(); |
| 113 } | 129 } |
| OLD | NEW |