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

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

Issue 2552473002: Display error message when user try to open a locked supervised user profile when force-sign-in is … (Closed)
Patch Set: sky's comments Created 4 years 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
« no previous file with comments | « chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/signin/user_manager_screen_handler.h" 5 #include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 25 matching lines...) Expand all
36 #include "chrome/browser/ui/app_list/app_list_service.h" 36 #include "chrome/browser/ui/app_list/app_list_service.h"
37 #include "chrome/browser/ui/browser_commands.h" 37 #include "chrome/browser/ui/browser_commands.h"
38 #include "chrome/browser/ui/browser_dialogs.h" 38 #include "chrome/browser/ui/browser_dialogs.h"
39 #include "chrome/browser/ui/browser_finder.h" 39 #include "chrome/browser/ui/browser_finder.h"
40 #include "chrome/browser/ui/browser_list.h" 40 #include "chrome/browser/ui/browser_list.h"
41 #include "chrome/browser/ui/browser_list_observer.h" 41 #include "chrome/browser/ui/browser_list_observer.h"
42 #include "chrome/browser/ui/chrome_pages.h" 42 #include "chrome/browser/ui/chrome_pages.h"
43 #include "chrome/browser/ui/singleton_tabs.h" 43 #include "chrome/browser/ui/singleton_tabs.h"
44 #include "chrome/browser/ui/user_manager.h" 44 #include "chrome/browser/ui/user_manager.h"
45 #include "chrome/browser/ui/webui/profile_helper.h" 45 #include "chrome/browser/ui/webui/profile_helper.h"
46 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
47 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
46 #include "chrome/common/chrome_features.h" 48 #include "chrome/common/chrome_features.h"
47 #include "chrome/common/pref_names.h" 49 #include "chrome/common/pref_names.h"
48 #include "chrome/common/url_constants.h" 50 #include "chrome/common/url_constants.h"
49 #include "chrome/grit/chromium_strings.h" 51 #include "chrome/grit/chromium_strings.h"
50 #include "chrome/grit/generated_resources.h" 52 #include "chrome/grit/generated_resources.h"
51 #include "components/prefs/pref_service.h" 53 #include "components/prefs/pref_service.h"
52 #include "components/proximity_auth/screenlock_bridge.h" 54 #include "components/proximity_auth/screenlock_bridge.h"
53 #include "components/signin/core/account_id/account_id.h" 55 #include "components/signin/core/account_id/account_id.h"
54 #include "components/signin/core/common/profile_management_switches.h" 56 #include "components/signin/core/common/profile_management_switches.h"
55 #include "components/strings/grit/components_strings.h" 57 #include "components/strings/grit/components_strings.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 return; 457 return;
456 } 458 }
457 } 459 }
458 460
459 content::BrowserContext* browser_context = 461 content::BrowserContext* browser_context =
460 web_ui()->GetWebContents()->GetBrowserContext(); 462 web_ui()->GetWebContents()->GetBrowserContext();
461 463
462 if (!email_address_.empty()) { 464 if (!email_address_.empty()) {
463 // In order to support the upgrade case where we have a local hash but no 465 // In order to support the upgrade case where we have a local hash but no
464 // password token, the user must perform a full online reauth. 466 // password token, the user must perform a full online reauth.
465 UserManager::ShowReauthDialog(browser_context, email_address_, 467 UserManagerProfileDialog::ShowReauthDialog(
466 signin_metrics::Reason::REASON_UNLOCK); 468 browser_context, email_address_, signin_metrics::Reason::REASON_UNLOCK);
469 } else if (entry->IsSigninRequired() && entry->IsSupervised()) {
470 // Supervised profile will only be locked when force-sign-in is enabled
471 // and it shouldn't be unlocked. Display the error message directly via
472 // the system profile to avoid profile creation.
473 LoginUIServiceFactory::GetForProfile(
474 Profile::FromWebUI(web_ui())->GetOriginalProfile())
475 ->DisplayLoginResult(nullptr,
476 l10n_util::GetStringUTF16(
477 IDS_SUPERVISED_USER_NOT_ALLOWED_BY_POLICY),
478 base::string16());
479 UserManagerProfileDialog::ShowDialogAndDisplayErrorMessage(browser_context);
467 } else { 480 } else {
468 // Fresh sign in via user manager without existing email address. 481 // Fresh sign in via user manager without existing email address.
469 UserManager::ShowSigninDialog(browser_context, profile_path); 482 UserManagerProfileDialog::ShowSigninDialog(browser_context, profile_path);
470 } 483 }
471 } 484 }
472 485
473 void UserManagerScreenHandler::HandleRemoveUser(const base::ListValue* args) { 486 void UserManagerScreenHandler::HandleRemoveUser(const base::ListValue* args) {
474 DCHECK(args); 487 DCHECK(args);
475 const base::Value* profile_path_value; 488 const base::Value* profile_path_value;
476 if (!args->Get(0, &profile_path_value)) { 489 if (!args->Get(0, &profile_path_value)) {
477 NOTREACHED(); 490 NOTREACHED();
478 return; 491 return;
479 } 492 }
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 void UserManagerScreenHandler::OnGetTokenInfoResponse( 697 void UserManagerScreenHandler::OnGetTokenInfoResponse(
685 std::unique_ptr<base::DictionaryValue> token_info) { 698 std::unique_ptr<base::DictionaryValue> token_info) {
686 // Password is unchanged so user just mistyped it. Ask again. 699 // Password is unchanged so user just mistyped it. Ask again.
687 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED); 700 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED);
688 } 701 }
689 702
690 void UserManagerScreenHandler::OnOAuthError() { 703 void UserManagerScreenHandler::OnOAuthError() {
691 // Password has changed. Go through online signin flow. 704 // Password has changed. Go through online signin flow.
692 DCHECK(!email_address_.empty()); 705 DCHECK(!email_address_.empty());
693 oauth_client_.reset(); 706 oauth_client_.reset();
694 UserManager::ShowReauthDialog(web_ui()->GetWebContents()->GetBrowserContext(), 707 UserManagerProfileDialog::ShowReauthDialog(
695 email_address_, 708 web_ui()->GetWebContents()->GetBrowserContext(), email_address_,
696 signin_metrics::Reason::REASON_UNLOCK); 709 signin_metrics::Reason::REASON_UNLOCK);
697 } 710 }
698 711
699 void UserManagerScreenHandler::OnNetworkError(int response_code) { 712 void UserManagerScreenHandler::OnNetworkError(int response_code) {
700 // Inconclusive but can't do real signin without being online anyway. 713 // Inconclusive but can't do real signin without being online anyway.
701 oauth_client_.reset(); 714 oauth_client_.reset();
702 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED_OFFLINE); 715 ReportAuthenticationResult(false, ProfileMetrics::AUTH_FAILED_OFFLINE);
703 } 716 }
704 717
705 void UserManagerScreenHandler::RegisterMessages() { 718 void UserManagerScreenHandler::RegisterMessages() {
706 web_ui()->RegisterMessageCallback(kJsApiUserManagerInitialize, 719 web_ui()->RegisterMessageCallback(kJsApiUserManagerInitialize,
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 Profile* profile, Profile::CreateStatus profile_create_status) { 1054 Profile* profile, Profile::CreateStatus profile_create_status) {
1042 Browser* browser = chrome::FindAnyBrowser(profile, false); 1055 Browser* browser = chrome::FindAnyBrowser(profile, false);
1043 if (browser && browser->window()) { 1056 if (browser && browser->window()) {
1044 OnBrowserWindowReady(browser); 1057 OnBrowserWindowReady(browser);
1045 } else { 1058 } else {
1046 registrar_.Add(this, 1059 registrar_.Add(this,
1047 chrome::NOTIFICATION_BROWSER_WINDOW_READY, 1060 chrome::NOTIFICATION_BROWSER_WINDOW_READY,
1048 content::NotificationService::AllSources()); 1061 content::NotificationService::AllSources());
1049 } 1062 }
1050 } 1063 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/signin/signin_supervised_user_import_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698