| 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 CloseModalSigninWindow(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS, args); |
| 45 } | 47 } |
| 46 | 48 |
| 47 void SyncConfirmationHandler::HandleGoToSettings(const base::ListValue* args) { | 49 void SyncConfirmationHandler::HandleGoToSettings(const base::ListValue* args) { |
| 48 CloseModalSigninWindow(LoginUIService::CONFIGURE_SYNC_FIRST); | 50 CloseModalSigninWindow(LoginUIService::CONFIGURE_SYNC_FIRST, args); |
| 49 } | 51 } |
| 50 | 52 |
| 51 void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) { | 53 void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) { |
| 52 content::RecordAction(base::UserMetricsAction("Signin_Undo_Signin")); | 54 content::RecordAction(base::UserMetricsAction("Signin_Undo_Signin")); |
| 53 Browser* browser = GetDesktopBrowser(); | 55 Browser* browser = GetDesktopBrowser(); |
| 54 LoginUIServiceFactory::GetForProfile(browser->profile())-> | 56 LoginUIServiceFactory::GetForProfile(browser->profile())-> |
| 55 SyncConfirmationUIClosed(LoginUIService::ABORT_SIGNIN); | 57 SyncConfirmationUIClosed(LoginUIService::ABORT_SIGNIN, false); |
| 56 SigninManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()))->SignOut( | 58 SigninManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()))->SignOut( |
| 57 signin_metrics::ABORT_SIGNIN, | 59 signin_metrics::ABORT_SIGNIN, |
| 58 signin_metrics::SignoutDelete::IGNORE_METRIC); | 60 signin_metrics::SignoutDelete::IGNORE_METRIC); |
| 59 browser->CloseModalSigninWindow(); | 61 browser->CloseModalSigninWindow(); |
| 60 } | 62 } |
| 61 | 63 |
| 62 void SyncConfirmationHandler::HandleInitialized(const base::ListValue* args) { | 64 void SyncConfirmationHandler::HandleInitialized(const base::ListValue* args) { |
| 63 Browser* browser = GetDesktopBrowser(); | 65 Browser* browser = GetDesktopBrowser(); |
| 64 Profile* profile = browser->profile(); | 66 Profile* profile = browser->profile(); |
| 65 std::vector<AccountInfo> accounts = | 67 std::vector<AccountInfo> accounts = |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 Browser* SyncConfirmationHandler::GetDesktopBrowser() { | 100 Browser* SyncConfirmationHandler::GetDesktopBrowser() { |
| 99 Browser* browser = chrome::FindBrowserWithWebContents( | 101 Browser* browser = chrome::FindBrowserWithWebContents( |
| 100 web_ui()->GetWebContents()); | 102 web_ui()->GetWebContents()); |
| 101 if (!browser) | 103 if (!browser) |
| 102 browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); | 104 browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); |
| 103 DCHECK(browser); | 105 DCHECK(browser); |
| 104 return browser; | 106 return browser; |
| 105 } | 107 } |
| 106 | 108 |
| 107 void SyncConfirmationHandler::CloseModalSigninWindow( | 109 void SyncConfirmationHandler::CloseModalSigninWindow( |
| 108 LoginUIService::SyncConfirmationUIClosedResults results) { | 110 LoginUIService::SyncConfirmationUIClosedResults results, |
| 111 const base::ListValue* args) { |
| 112 bool open_activity_controls_url = false; |
| 113 bool success = args->GetBoolean(0, &open_activity_controls_url); |
| 114 DCHECK(success); |
| 109 Browser* browser = GetDesktopBrowser(); | 115 Browser* browser = GetDesktopBrowser(); |
| 110 LoginUIServiceFactory::GetForProfile(browser->profile())-> | 116 LoginUIServiceFactory::GetForProfile(browser->profile())-> |
| 111 SyncConfirmationUIClosed(results); | 117 SyncConfirmationUIClosed(results, open_activity_controls_url); |
| 112 browser->CloseModalSigninWindow(); | 118 browser->CloseModalSigninWindow(); |
| 113 } | 119 } |
| OLD | NEW |