Chromium Code Reviews| 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 CloseModalSigninWindow(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS, | |
| 50 open_activity_controls_url); | |
| 45 } | 51 } |
| 46 | 52 |
| 47 void SyncConfirmationHandler::HandleGoToSettings(const base::ListValue* args) { | 53 void SyncConfirmationHandler::HandleGoToSettings(const base::ListValue* args) { |
| 48 CloseModalSigninWindow(LoginUIService::CONFIGURE_SYNC_FIRST); | 54 bool open_activity_controls_url = false; |
| 55 bool success = args->GetBoolean(0, &open_activity_controls_url); | |
| 56 DCHECK(success); | |
| 57 CloseModalSigninWindow(LoginUIService::CONFIGURE_SYNC_FIRST, | |
| 58 open_activity_controls_url); | |
| 49 } | 59 } |
| 50 | 60 |
| 51 void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) { | 61 void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) { |
| 52 content::RecordAction(base::UserMetricsAction("Signin_Undo_Signin")); | 62 content::RecordAction(base::UserMetricsAction("Signin_Undo_Signin")); |
| 53 Browser* browser = GetDesktopBrowser(); | 63 Browser* browser = GetDesktopBrowser(); |
| 54 LoginUIServiceFactory::GetForProfile(browser->profile())-> | 64 LoginUIServiceFactory::GetForProfile(browser->profile())-> |
| 55 SyncConfirmationUIClosed(LoginUIService::ABORT_SIGNIN); | 65 SyncConfirmationUIClosed(LoginUIService::ABORT_SIGNIN, false); |
| 56 SigninManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()))->SignOut( | 66 SigninManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()))->SignOut( |
| 57 signin_metrics::ABORT_SIGNIN, | 67 signin_metrics::ABORT_SIGNIN, |
| 58 signin_metrics::SignoutDelete::IGNORE_METRIC); | 68 signin_metrics::SignoutDelete::IGNORE_METRIC); |
| 59 browser->CloseModalSigninWindow(); | 69 browser->CloseModalSigninWindow(); |
| 60 } | 70 } |
| 61 | 71 |
| 62 void SyncConfirmationHandler::HandleInitialized(const base::ListValue* args) { | 72 void SyncConfirmationHandler::HandleInitialized(const base::ListValue* args) { |
| 63 Browser* browser = GetDesktopBrowser(); | 73 Browser* browser = GetDesktopBrowser(); |
| 64 Profile* profile = browser->profile(); | 74 Profile* profile = browser->profile(); |
| 65 std::vector<AccountInfo> accounts = | 75 std::vector<AccountInfo> accounts = |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 Browser* SyncConfirmationHandler::GetDesktopBrowser() { | 108 Browser* SyncConfirmationHandler::GetDesktopBrowser() { |
| 99 Browser* browser = chrome::FindBrowserWithWebContents( | 109 Browser* browser = chrome::FindBrowserWithWebContents( |
| 100 web_ui()->GetWebContents()); | 110 web_ui()->GetWebContents()); |
| 101 if (!browser) | 111 if (!browser) |
| 102 browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); | 112 browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); |
| 103 DCHECK(browser); | 113 DCHECK(browser); |
| 104 return browser; | 114 return browser; |
| 105 } | 115 } |
| 106 | 116 |
| 107 void SyncConfirmationHandler::CloseModalSigninWindow( | 117 void SyncConfirmationHandler::CloseModalSigninWindow( |
| 108 LoginUIService::SyncConfirmationUIClosedResults results) { | 118 LoginUIService::SyncConfirmationUIClosedResults results, |
|
Evan Stade
2016/03/29 22:50:21
nit: SyncConfirmationUIClosedResults made me think
Moe
2016/03/30 18:07:47
Done.
| |
| 119 bool open_activity_controls_url) { | |
| 109 Browser* browser = GetDesktopBrowser(); | 120 Browser* browser = GetDesktopBrowser(); |
| 110 LoginUIServiceFactory::GetForProfile(browser->profile())-> | 121 LoginUIServiceFactory::GetForProfile(browser->profile())-> |
| 111 SyncConfirmationUIClosed(results); | 122 SyncConfirmationUIClosed(results, open_activity_controls_url); |
| 112 browser->CloseModalSigninWindow(); | 123 browser->CloseModalSigninWindow(); |
| 113 } | 124 } |
| OLD | NEW |