Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromeos/login/signin_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 // Timeout used to prevent infinite connecting to a flaky network. | 106 // Timeout used to prevent infinite connecting to a flaky network. |
| 107 const int kConnectingTimeoutSec = 60; | 107 const int kConnectingTimeoutSec = 60; |
| 108 | 108 |
| 109 // Max number of Gaia Reload to Show Proxy Auth Dialog. | 109 // Max number of Gaia Reload to Show Proxy Auth Dialog. |
| 110 const int kMaxGaiaReloadForProxyAuthDialog = 3; | 110 const int kMaxGaiaReloadForProxyAuthDialog = 3; |
| 111 | 111 |
| 112 // Type of the login screen UI that is currently presented to user. | 112 // Type of the login screen UI that is currently presented to user. |
| 113 const char kSourceGaiaSignin[] = "gaia-signin"; | 113 const char kSourceGaiaSignin[] = "gaia-signin"; |
| 114 const char kSourceAccountPicker[] = "account-picker"; | 114 const char kSourceAccountPicker[] = "account-picker"; |
| 115 | 115 |
| 116 base::LazyInstance<base::Closure> g_ui_shown_callback_for_testing_ = | |
| 117 LAZY_INSTANCE_INITIALIZER; | |
|
stevenjb
2016/10/14 17:31:55
No trailing _ in file local variables.
If this is
Primiano Tucci (use gerrit)
2016/10/14 17:42:56
I am not sure I follow, how do you expect the g_cl
| |
| 118 | |
| 116 static bool Contains(const std::vector<std::string>& container, | 119 static bool Contains(const std::vector<std::string>& container, |
| 117 const std::string& value) { | 120 const std::string& value) { |
| 118 return std::find(container.begin(), container.end(), value) != | 121 return std::find(container.begin(), container.end(), value) != |
| 119 container.end(); | 122 container.end(); |
| 120 } | 123 } |
| 121 | 124 |
| 122 class CallOnReturn { | 125 class CallOnReturn { |
| 123 public: | 126 public: |
| 124 explicit CallOnReturn(const base::Closure& callback) | 127 explicit CallOnReturn(const base::Closure& callback) |
| 125 : callback_(callback), call_scheduled_(false) {} | 128 : callback_(callback), call_scheduled_(false) {} |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 // thus others need to be switched to default locale. | 360 // thus others need to be switched to default locale. |
| 358 // Otherwise they will end up using another user's locale to log in. | 361 // Otherwise they will end up using another user's locale to log in. |
| 359 if (!succeed) { | 362 if (!succeed) { |
| 360 DVLOG(0) << "SetUserInputMethod('" << username | 363 DVLOG(0) << "SetUserInputMethod('" << username |
| 361 << "'): failed to set user layout. Switching to default."; | 364 << "'): failed to set user layout. Switching to default."; |
| 362 | 365 |
| 363 ime_state->SetInputMethodLoginDefault(); | 366 ime_state->SetInputMethodLoginDefault(); |
| 364 } | 367 } |
| 365 } | 368 } |
| 366 | 369 |
| 370 // static | |
| 371 void SigninScreenHandler::SetCallbackOnUiShownForTesting( | |
| 372 base::Closure callback) { | |
| 373 DCHECK(g_ui_shown_callback_for_testing_.Get().is_null()); | |
| 374 g_ui_shown_callback_for_testing_.Get() = callback; | |
| 375 } | |
| 376 | |
| 367 void SigninScreenHandler::DeclareLocalizedValues( | 377 void SigninScreenHandler::DeclareLocalizedValues( |
| 368 ::login::LocalizedValuesBuilder* builder) { | 378 ::login::LocalizedValuesBuilder* builder) { |
| 369 // Format numbers to be used on the pin keyboard. | 379 // Format numbers to be used on the pin keyboard. |
| 370 for (int j = 0; j <= 9; j++) { | 380 for (int j = 0; j <= 9; j++) { |
| 371 builder->Add("pinKeyboard" + base::IntToString(j), | 381 builder->Add("pinKeyboard" + base::IntToString(j), |
| 372 base::FormatNumber(int64_t{j})); | 382 base::FormatNumber(int64_t{j})); |
| 373 } | 383 } |
| 374 | 384 |
| 375 builder->Add("passwordHint", IDS_LOGIN_POD_EMPTY_PASSWORD_TEXT); | 385 builder->Add("passwordHint", IDS_LOGIN_POD_EMPTY_PASSWORD_TEXT); |
| 376 builder->Add("pinKeyboardPlaceholderPin", | 386 builder->Add("pinKeyboardPlaceholderPin", |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1249 << "webui_visible_: " << webui_visible_; | 1259 << "webui_visible_: " << webui_visible_; |
| 1250 if (!webui_visible_) { | 1260 if (!webui_visible_) { |
| 1251 // There might be multiple messages from OOBE UI so send notifications after | 1261 // There might be multiple messages from OOBE UI so send notifications after |
| 1252 // the first one only. | 1262 // the first one only. |
| 1253 content::NotificationService::current()->Notify( | 1263 content::NotificationService::current()->Notify( |
| 1254 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 1264 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
| 1255 content::NotificationService::AllSources(), | 1265 content::NotificationService::AllSources(), |
| 1256 content::NotificationService::NoDetails()); | 1266 content::NotificationService::NoDetails()); |
| 1257 TRACE_EVENT_ASYNC_END0( | 1267 TRACE_EVENT_ASYNC_END0( |
| 1258 "ui", "ShowLoginWebUI", LoginDisplayHostImpl::kShowLoginWebUIid); | 1268 "ui", "ShowLoginWebUI", LoginDisplayHostImpl::kShowLoginWebUIid); |
| 1269 if (!g_ui_shown_callback_for_testing_.Get().is_null()) | |
| 1270 g_ui_shown_callback_for_testing_.Get().Run(); | |
| 1259 } | 1271 } |
| 1260 webui_visible_ = true; | 1272 webui_visible_ = true; |
| 1261 if (preferences_changed_delayed_) | 1273 if (preferences_changed_delayed_) |
| 1262 OnPreferencesChanged(); | 1274 OnPreferencesChanged(); |
| 1263 } | 1275 } |
| 1264 | 1276 |
| 1265 void SigninScreenHandler::HandleCancelPasswordChangedFlow( | 1277 void SigninScreenHandler::HandleCancelPasswordChangedFlow( |
| 1266 const AccountId& account_id) { | 1278 const AccountId& account_id) { |
| 1267 if (account_id.is_valid()) { | 1279 if (account_id.is_valid()) { |
| 1268 RecordReauthReason(account_id, ReauthReason::PASSWORD_UPDATE_SKIPPED); | 1280 RecordReauthReason(account_id, ReauthReason::PASSWORD_UPDATE_SKIPPED); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1493 } | 1505 } |
| 1494 | 1506 |
| 1495 void SigninScreenHandler::OnFeedbackFinished() { | 1507 void SigninScreenHandler::OnFeedbackFinished() { |
| 1496 CallJS("login.UnrecoverableCryptohomeErrorScreen.resumeAfterFeedbackUI"); | 1508 CallJS("login.UnrecoverableCryptohomeErrorScreen.resumeAfterFeedbackUI"); |
| 1497 | 1509 |
| 1498 // Recreate user's cryptohome after the feedback is attempted. | 1510 // Recreate user's cryptohome after the feedback is attempted. |
| 1499 HandleResyncUserData(); | 1511 HandleResyncUserData(); |
| 1500 } | 1512 } |
| 1501 | 1513 |
| 1502 } // namespace chromeos | 1514 } // namespace chromeos |
| OLD | NEW |