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> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 if (browser_ == browser) | 49 if (browser_ == browser) |
50 browser_ = nullptr; | 50 browser_ = nullptr; |
51 } | 51 } |
52 | 52 |
53 void SyncConfirmationHandler::RegisterMessages() { | 53 void SyncConfirmationHandler::RegisterMessages() { |
54 web_ui()->RegisterMessageCallback("confirm", | 54 web_ui()->RegisterMessageCallback("confirm", |
55 base::Bind(&SyncConfirmationHandler::HandleConfirm, | 55 base::Bind(&SyncConfirmationHandler::HandleConfirm, |
56 base::Unretained(this))); | 56 base::Unretained(this))); |
57 web_ui()->RegisterMessageCallback("undo", | 57 web_ui()->RegisterMessageCallback("undo", |
58 base::Bind(&SyncConfirmationHandler::HandleUndo, base::Unretained(this))); | 58 base::Bind(&SyncConfirmationHandler::HandleUndo, base::Unretained(this))); |
59 web_ui()->RegisterMessageCallback("goToSettings", | |
60 base::Bind(&SyncConfirmationHandler::HandleGoToSettings, | |
61 base::Unretained(this))); | |
62 web_ui()->RegisterMessageCallback("initializedWithSize", | 59 web_ui()->RegisterMessageCallback("initializedWithSize", |
63 base::Bind(&SyncConfirmationHandler::HandleInitializedWithSize, | 60 base::Bind(&SyncConfirmationHandler::HandleInitializedWithSize, |
64 base::Unretained(this))); | 61 base::Unretained(this))); |
65 } | 62 } |
66 | 63 |
67 void SyncConfirmationHandler::HandleConfirm(const base::ListValue* args) { | 64 void SyncConfirmationHandler::HandleConfirm(const base::ListValue* args) { |
68 did_user_explicitly_interact = true; | 65 did_user_explicitly_interact = true; |
69 CloseModalSigninWindow(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS); | 66 bool configure_sync_first = false; |
70 } | 67 CHECK(args->GetBoolean(0, &configure_sync_first)); |
71 | 68 CloseModalSigninWindow(configure_sync_first |
72 void SyncConfirmationHandler::HandleGoToSettings(const base::ListValue* args) { | 69 ? LoginUIService::CONFIGURE_SYNC_FIRST |
73 did_user_explicitly_interact = true; | 70 : LoginUIService::SYNC_WITH_DEFAULT_SETTINGS); |
74 CloseModalSigninWindow(LoginUIService::CONFIGURE_SYNC_FIRST); | |
75 } | 71 } |
76 | 72 |
77 void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) { | 73 void SyncConfirmationHandler::HandleUndo(const base::ListValue* args) { |
78 did_user_explicitly_interact = true; | 74 did_user_explicitly_interact = true; |
79 base::RecordAction(base::UserMetricsAction("Signin_Undo_Signin")); | 75 base::RecordAction(base::UserMetricsAction("Signin_Undo_Signin")); |
80 LoginUIServiceFactory::GetForProfile(profile_)->SyncConfirmationUIClosed( | 76 LoginUIServiceFactory::GetForProfile(profile_)->SyncConfirmationUIClosed( |
81 LoginUIService::ABORT_SIGNIN); | 77 LoginUIService::ABORT_SIGNIN); |
82 SigninManagerFactory::GetForProfile(profile_)->SignOut( | 78 SigninManagerFactory::GetForProfile(profile_)->SignOut( |
83 signin_metrics::ABORT_SIGNIN, | 79 signin_metrics::ABORT_SIGNIN, |
84 signin_metrics::SignoutDelete::IGNORE_METRIC); | 80 signin_metrics::SignoutDelete::IGNORE_METRIC); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 144 |
149 signin::SetInitializedModalHeight(browser_, web_ui(), args); | 145 signin::SetInitializedModalHeight(browser_, web_ui(), args); |
150 | 146 |
151 // After the dialog is shown, some platforms might have an element focused. | 147 // After the dialog is shown, some platforms might have an element focused. |
152 // To be consistent, clear the focused element on all platforms. | 148 // To be consistent, clear the focused element on all platforms. |
153 // TODO(anthonyvd): Figure out why this is needed on Mac and not other | 149 // TODO(anthonyvd): Figure out why this is needed on Mac and not other |
154 // platforms and if there's a way to start unfocused while avoiding this | 150 // platforms and if there's a way to start unfocused while avoiding this |
155 // workaround. | 151 // workaround. |
156 web_ui()->CallJavascriptFunctionUnsafe("sync.confirmation.clearFocus"); | 152 web_ui()->CallJavascriptFunctionUnsafe("sync.confirmation.clearFocus"); |
157 } | 153 } |
OLD | NEW |