Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/enrollment_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | |
|
bartfab (slow)
2014/10/21 14:47:47
Nit: This is still used in EnrollmentScreenHandler
Roger Tawa OOO till Jul 10th
2014/10/21 19:15:31
Done.
| |
| 11 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 11 #include "base/macros.h" |
| 13 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 14 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 15 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 16 #include "base/values.h" | 15 #include "base/values.h" |
| 17 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 17 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 19 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 18 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 20 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 19 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 21 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" | 20 #include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h" |
| 22 #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h" | 21 #include "chrome/browser/extensions/signin/gaia_auth_extension_loader.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/ui/webui/chromeos/login/authenticated_user_email_retrie ver.h" | |
| 25 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 23 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 26 #include "chrome/grit/generated_resources.h" | 24 #include "chrome/grit/generated_resources.h" |
| 27 #include "chromeos/network/network_state.h" | 25 #include "chromeos/network/network_state.h" |
| 28 #include "chromeos/network/network_state_handler.h" | 26 #include "chromeos/network/network_state_handler.h" |
| 29 #include "components/policy/core/browser/cloud/message_util.h" | 27 #include "components/policy/core/browser/cloud/message_util.h" |
| 30 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 31 #include "google_apis/gaia/gaia_auth_fetcher.h" | 29 #include "google_apis/gaia/gaia_auth_fetcher.h" |
| 32 #include "google_apis/gaia/gaia_auth_util.h" | 30 #include "google_apis/gaia/gaia_auth_util.h" |
| 33 #include "google_apis/gaia/gaia_constants.h" | 31 #include "google_apis/gaia/gaia_constants.h" |
| 34 #include "google_apis/gaia/gaia_urls.h" | 32 #include "google_apis/gaia/gaia_urls.h" |
| 35 #include "google_apis/gaia/google_service_auth_error.h" | 33 #include "google_apis/gaia/google_service_auth_error.h" |
| 36 #include "net/url_request/url_request_context_getter.h" | |
|
bartfab (slow)
2014/10/21 14:47:47
Nit: This is still used in EnrollmentScreenHandler
Roger Tawa OOO till Jul 10th
2014/10/21 19:15:31
Done.
| |
| 37 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| 38 | 35 |
| 39 namespace chromeos { | 36 namespace chromeos { |
| 40 namespace { | 37 namespace { |
| 41 | 38 |
| 42 const char kJsScreenPath[] = "login.OAuthEnrollmentScreen"; | 39 const char kJsScreenPath[] = "login.OAuthEnrollmentScreen"; |
| 43 | 40 |
| 44 // Enrollment step names. | 41 // Enrollment step names. |
| 45 const char kEnrollmentStepSignin[] = "signin"; | 42 const char kEnrollmentStepSignin[] = "signin"; |
| 46 const char kEnrollmentStepSuccess[] = "success"; | 43 const char kEnrollmentStepSuccess[] = "success"; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 chromeos::WebUILoginView* login_view = | 136 chromeos::WebUILoginView* login_view = |
| 140 chromeos::LoginDisplayHostImpl::default_host()->GetWebUILoginView(); | 137 chromeos::LoginDisplayHostImpl::default_host()->GetWebUILoginView(); |
| 141 if (login_view) | 138 if (login_view) |
| 142 login_view->RemoveFrameObserver(this); | 139 login_view->RemoveFrameObserver(this); |
| 143 } | 140 } |
| 144 } | 141 } |
| 145 | 142 |
| 146 // EnrollmentScreenHandler, WebUIMessageHandler implementation -- | 143 // EnrollmentScreenHandler, WebUIMessageHandler implementation -- |
| 147 | 144 |
| 148 void EnrollmentScreenHandler::RegisterMessages() { | 145 void EnrollmentScreenHandler::RegisterMessages() { |
| 149 AddCallback("oauthEnrollRetrieveAuthenticatedUserEmail", | |
| 150 &EnrollmentScreenHandler::HandleRetrieveAuthenticatedUserEmail); | |
| 151 AddCallback("oauthEnrollClose", | 146 AddCallback("oauthEnrollClose", |
| 152 &EnrollmentScreenHandler::HandleClose); | 147 &EnrollmentScreenHandler::HandleClose); |
| 153 AddCallback("oauthEnrollCompleteLogin", | 148 AddCallback("oauthEnrollCompleteLogin", |
| 154 &EnrollmentScreenHandler::HandleCompleteLogin); | 149 &EnrollmentScreenHandler::HandleCompleteLogin); |
| 155 AddCallback("oauthEnrollRetry", | 150 AddCallback("oauthEnrollRetry", |
| 156 &EnrollmentScreenHandler::HandleRetry); | 151 &EnrollmentScreenHandler::HandleRetry); |
| 157 AddCallback("frameLoadingCompleted", | 152 AddCallback("frameLoadingCompleted", |
| 158 &EnrollmentScreenHandler::HandleFrameLoadingCompleted); | 153 &EnrollmentScreenHandler::HandleFrameLoadingCompleted); |
| 159 } | 154 } |
| 160 | 155 |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 } | 503 } |
| 509 | 504 |
| 510 void EnrollmentScreenHandler::OnFrameError( | 505 void EnrollmentScreenHandler::OnFrameError( |
| 511 const std::string& frame_unique_name) { | 506 const std::string& frame_unique_name) { |
| 512 if (frame_unique_name == "oauth-enroll-signin-frame") { | 507 if (frame_unique_name == "oauth-enroll-signin-frame") { |
| 513 HandleFrameLoadingCompleted(net::ERR_FAILED); | 508 HandleFrameLoadingCompleted(net::ERR_FAILED); |
| 514 } | 509 } |
| 515 } | 510 } |
| 516 // EnrollmentScreenHandler, private ----------------------------- | 511 // EnrollmentScreenHandler, private ----------------------------- |
| 517 | 512 |
| 518 void EnrollmentScreenHandler::HandleRetrieveAuthenticatedUserEmail( | |
| 519 double attempt_token) { | |
| 520 email_retriever_.reset(new AuthenticatedUserEmailRetriever( | |
| 521 base::Bind(&EnrollmentScreenHandler::CallJS<double, std::string>, | |
| 522 base::Unretained(this), | |
| 523 "setAuthenticatedUserEmail", | |
| 524 attempt_token), | |
| 525 Profile::FromWebUI(web_ui())->GetRequestContext())); | |
| 526 } | |
| 527 | |
| 528 void EnrollmentScreenHandler::HandleClose(const std::string& reason) { | 513 void EnrollmentScreenHandler::HandleClose(const std::string& reason) { |
| 529 DCHECK(controller_); | 514 DCHECK(controller_); |
| 530 | 515 |
| 531 if (reason == "cancel" || reason == "autocancel") | 516 if (reason == "cancel" || reason == "autocancel") |
| 532 controller_->OnCancel(); | 517 controller_->OnCancel(); |
| 533 else if (reason == "done") | 518 else if (reason == "done") |
| 534 controller_->OnConfirmationClosed(); | 519 controller_->OnConfirmationClosed(); |
| 535 else | 520 else |
| 536 NOTREACHED(); | 521 NOTREACHED(); |
| 537 } | 522 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 base::StringPrintf("%s/main.html", extensions::kGaiaAuthExtensionOrigin)); | 579 base::StringPrintf("%s/main.html", extensions::kGaiaAuthExtensionOrigin)); |
| 595 screen_data.SetString("gaiaUrl", GaiaUrls::GetInstance()->gaia_url().spec()); | 580 screen_data.SetString("gaiaUrl", GaiaUrls::GetInstance()->gaia_url().spec()); |
| 596 screen_data.SetString("enrollment_mode", | 581 screen_data.SetString("enrollment_mode", |
| 597 EnrollmentModeToString(enrollment_mode_)); | 582 EnrollmentModeToString(enrollment_mode_)); |
| 598 screen_data.SetString("management_domain", management_domain_); | 583 screen_data.SetString("management_domain", management_domain_); |
| 599 | 584 |
| 600 ShowScreen(OobeUI::kScreenOobeEnrollment, &screen_data); | 585 ShowScreen(OobeUI::kScreenOobeEnrollment, &screen_data); |
| 601 } | 586 } |
| 602 | 587 |
| 603 } // namespace chromeos | 588 } // namespace chromeos |
| OLD | NEW |