Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: chrome/browser/ui/webui/signin/sync_confirmation_handler.cc

Issue 1806353002: Enhanced Sync Confirmation modal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 uint32_t result = LoginUIService::SYNC_WITH_DEFAULT_SETTINGS;
50 if (open_activity_controls_url)
51 result |= LoginUIService::OPEN_ACTIVITY_CONTROLS_URL;
52 CloseModalSigninWindow(result);
45 } 53 }
46 54
47 void SyncConfirmationHandler::HandleGoToSettings(const base::ListValue* args) { 55 void SyncConfirmationHandler::HandleGoToSettings(const base::ListValue* args) {
48 CloseModalSigninWindow(LoginUIService::CONFIGURE_SYNC_FIRST); 56 bool open_activity_controls_url = false;
57 bool success = args->GetBoolean(0, &open_activity_controls_url);
58 DCHECK(success);
59 uint32_t result = LoginUIService::CONFIGURE_SYNC_FIRST;
60 if (open_activity_controls_url)
61 result |= LoginUIService::OPEN_ACTIVITY_CONTROLS_URL;
62 CloseModalSigninWindow(result);
49 } 63 }
50 64
51 void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) { 65 void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) {
52 content::RecordAction(base::UserMetricsAction("Signin_Undo_Signin")); 66 content::RecordAction(base::UserMetricsAction("Signin_Undo_Signin"));
53 Browser* browser = GetDesktopBrowser(); 67 Browser* browser = GetDesktopBrowser();
54 LoginUIServiceFactory::GetForProfile(browser->profile())-> 68 LoginUIServiceFactory::GetForProfile(browser->profile())->
55 SyncConfirmationUIClosed(LoginUIService::ABORT_SIGNIN); 69 SyncConfirmationUIClosed(LoginUIService::ABORT_SIGNIN);
56 SigninManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()))->SignOut( 70 SigninManagerFactory::GetForProfile(Profile::FromWebUI(web_ui()))->SignOut(
57 signin_metrics::ABORT_SIGNIN, 71 signin_metrics::ABORT_SIGNIN,
58 signin_metrics::SignoutDelete::IGNORE_METRIC); 72 signin_metrics::SignoutDelete::IGNORE_METRIC);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 111
98 Browser* SyncConfirmationHandler::GetDesktopBrowser() { 112 Browser* SyncConfirmationHandler::GetDesktopBrowser() {
99 Browser* browser = chrome::FindBrowserWithWebContents( 113 Browser* browser = chrome::FindBrowserWithWebContents(
100 web_ui()->GetWebContents()); 114 web_ui()->GetWebContents());
101 if (!browser) 115 if (!browser)
102 browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); 116 browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui()));
103 DCHECK(browser); 117 DCHECK(browser);
104 return browser; 118 return browser;
105 } 119 }
106 120
107 void SyncConfirmationHandler::CloseModalSigninWindow( 121 void SyncConfirmationHandler::CloseModalSigninWindow(uint32_t result) {
108 LoginUIService::SyncConfirmationUIClosedResults results) {
109 Browser* browser = GetDesktopBrowser(); 122 Browser* browser = GetDesktopBrowser();
110 LoginUIServiceFactory::GetForProfile(browser->profile())-> 123 LoginUIServiceFactory::GetForProfile(browser->profile())->
111 SyncConfirmationUIClosed(results); 124 SyncConfirmationUIClosed(result);
112 browser->CloseModalSigninWindow(); 125 browser->CloseModalSigninWindow();
113 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698