OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/gaia_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/browser_shutdown.h" | 12 #include "chrome/browser/browser_shutdown.h" |
13 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 13 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
14 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 14 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
15 #include "chrome/browser/chromeos/login/users/user_manager.h" | 15 #include "chrome/browser/chromeos/login/users/user_manager.h" |
16 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | |
17 #include "chrome/browser/chromeos/policy/consumer_management_service.h" | |
16 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
17 #include "chrome/browser/chromeos/settings/cros_settings.h" | 19 #include "chrome/browser/chromeos/settings/cros_settings.h" |
18 #include "chrome/browser/io_thread.h" | 20 #include "chrome/browser/io_thread.h" |
19 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 21 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
20 #include "chromeos/chromeos_switches.h" | 22 #include "chromeos/chromeos_switches.h" |
21 #include "chromeos/settings/cros_settings_names.h" | 23 #include "chromeos/settings/cros_settings_names.h" |
22 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
23 #include "content/public/browser/render_frame_host.h" | 25 #include "content/public/browser/render_frame_host.h" |
24 #include "google_apis/gaia/gaia_auth_util.h" | 26 #include "google_apis/gaia/gaia_auth_util.h" |
25 #include "google_apis/gaia/gaia_switches.h" | 27 #include "google_apis/gaia/gaia_switches.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 UserContext user_context(email); | 285 UserContext user_context(email); |
284 user_context.SetKey(Key(password)); | 286 user_context.SetKey(Key(password)); |
285 user_context.SetAuthCode(auth_code); | 287 user_context.SetAuthCode(auth_code); |
286 Delegate()->CompleteLogin(user_context); | 288 Delegate()->CompleteLogin(user_context); |
287 } | 289 } |
288 | 290 |
289 void GaiaScreenHandler::HandleCompleteLogin(const std::string& typed_email, | 291 void GaiaScreenHandler::HandleCompleteLogin(const std::string& typed_email, |
290 const std::string& password, | 292 const std::string& password, |
291 bool using_saml) { | 293 bool using_saml) { |
292 std::string owner_email = UserManager::Get()->GetOwnerEmail(); | 294 std::string owner_email = UserManager::Get()->GetOwnerEmail(); |
293 if (is_enrolling_consumer_management_ && typed_email != owner_email) { | 295 if (is_enrolling_consumer_management_) { |
294 // Show Gaia signin page again since we only allow the owner to sign in. | 296 if (typed_email == owner_email) { |
295 populated_email_ = owner_email; | 297 policy::BrowserPolicyConnectorChromeOS* connector = g_browser_process |
bartfab (slow)
2014/08/04 18:44:55
While I was working on another screen handler last
davidyu
2014/08/05 07:27:00
Done.
| |
296 ShowGaia(is_enrolling_consumer_management_); | 298 ->platform_part()->browser_policy_connector_chromeos(); |
bartfab (slow)
2014/08/04 18:44:55
Nit 1: Move the -> operator to the previous line.
davidyu
2014/08/05 07:27:00
Done.
| |
297 return; | 299 connector->GetConsumerManagementService()->SetOwner( |
300 owner_email, | |
301 base::Bind(&GaiaScreenHandler::OnSetOwnerDone, | |
bartfab (slow)
2014/08/04 18:44:56
Nit: #include "base/bind.h"
davidyu
2014/08/05 07:27:00
Done.
| |
302 weak_factory_.GetWeakPtr(), | |
303 typed_email, password, using_saml)); | |
bartfab (slow)
2014/08/04 18:44:55
Nit: Add a return statement after this. That way,
davidyu
2014/08/05 07:27:00
Done.
| |
304 } else { | |
305 // Show Gaia signin page again since we only allow the owner to sign in. | |
bartfab (slow)
2014/08/04 18:44:56
Nit: s/signin/sign-in/
davidyu
2014/08/05 07:27:00
Done.
| |
306 populated_email_ = owner_email; | |
307 ShowGaia(is_enrolling_consumer_management_); | |
308 return; | |
309 } | |
310 } else { | |
311 DoCompleteLogin(typed_email, password, using_saml); | |
298 } | 312 } |
313 } | |
299 | 314 |
315 void GaiaScreenHandler::OnSetOwnerDone(const std::string& typed_email, | |
316 const std::string& password, | |
317 bool using_saml, | |
318 bool result) { | |
bartfab (slow)
2014/08/04 18:44:55
Nit: |result| is unclear. Better call this |succes
davidyu
2014/08/05 07:27:00
Done.
| |
319 if (!result) { | |
320 LOG(ERROR) << "Failed to write owner email to boot lockbox."; | |
bartfab (slow)
2014/08/04 18:44:56
Nit: s/email/e-mail/
davidyu
2014/08/05 07:27:00
Done.
| |
321 policy::BrowserPolicyConnectorChromeOS* connector = g_browser_process | |
322 ->platform_part()->browser_policy_connector_chromeos(); | |
bartfab (slow)
2014/08/04 18:44:55
Nit: Move the -> operator to the previous line.
davidyu
2014/08/05 07:27:00
Done.
| |
323 connector->GetConsumerManagementService()->SetEnrollState( | |
324 policy::ConsumerManagementService::ENROLL_BOOT_LOCKBOX_FAILED); | |
325 } | |
326 DoCompleteLogin(typed_email, password, using_saml); | |
327 } | |
328 | |
329 void GaiaScreenHandler::DoCompleteLogin(const std::string& typed_email, | |
330 const std::string& password, | |
331 bool using_saml) { | |
300 if (!Delegate()) | 332 if (!Delegate()) |
301 return; | 333 return; |
302 | 334 |
303 if (using_saml && !using_saml_api_) | 335 if (using_saml && !using_saml_api_) |
304 RecordSAMLScrapingVerificationResultInHistogram(true); | 336 RecordSAMLScrapingVerificationResultInHistogram(true); |
305 | 337 |
306 const std::string sanitized_email = gaia::SanitizeEmail(typed_email); | 338 const std::string sanitized_email = gaia::SanitizeEmail(typed_email); |
307 Delegate()->SetDisplayEmail(sanitized_email); | 339 Delegate()->SetDisplayEmail(sanitized_email); |
308 UserContext user_context(sanitized_email); | 340 UserContext user_context(sanitized_email); |
309 user_context.SetKey(Key(password)); | 341 user_context.SetKey(Key(password)); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
561 | 593 |
562 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { | 594 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { |
563 DCHECK(signin_screen_handler_); | 595 DCHECK(signin_screen_handler_); |
564 return signin_screen_handler_->delegate_; | 596 return signin_screen_handler_->delegate_; |
565 } | 597 } |
566 | 598 |
567 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { | 599 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { |
568 signin_screen_handler_ = handler; | 600 signin_screen_handler_ = handler; |
569 } | 601 } |
570 } // namespace chromeos | 602 } // namespace chromeos |
OLD | NEW |