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/signin_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/main.html"; | 61 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/main.html"; |
| 62 // Same as above but offline version. | 62 // Same as above but offline version. |
| 63 const char kGaiaExtStartPageOffline[] = | 63 const char kGaiaExtStartPageOffline[] = |
| 64 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/offline.html"; | 64 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/offline.html"; |
| 65 | 65 |
| 66 // User dictionary keys. | 66 // User dictionary keys. |
| 67 const char kKeyUsername[] = "username"; | 67 const char kKeyUsername[] = "username"; |
| 68 const char kKeyDisplayName[] = "displayName"; | 68 const char kKeyDisplayName[] = "displayName"; |
| 69 const char kKeyEmailAddress[] = "emailAddress"; | 69 const char kKeyEmailAddress[] = "emailAddress"; |
| 70 const char kKeyNameTooltip[] = "nameTooltip"; | 70 const char kKeyNameTooltip[] = "nameTooltip"; |
| 71 const char kKeyPublicAccount[] = "publicAccount"; | |
| 71 const char kKeySignedIn[] = "signedIn"; | 72 const char kKeySignedIn[] = "signedIn"; |
| 72 const char kKeyCanRemove[] = "canRemove"; | 73 const char kKeyCanRemove[] = "canRemove"; |
| 73 const char kKeyOauthTokenStatus[] = "oauthTokenStatus"; | 74 const char kKeyOauthTokenStatus[] = "oauthTokenStatus"; |
| 74 | 75 |
| 75 // Max number of users to show. | 76 // Max number of users to show. |
| 76 const size_t kMaxUsers = 5; | 77 const size_t kMaxUsers = 5; |
| 77 | 78 |
| 78 // The Task posted to PostTaskAndReply in StartClearingDnsCache on the IO | 79 // The Task posted to PostTaskAndReply in StartClearingDnsCache on the IO |
| 79 // thread. | 80 // thread. |
| 80 void ClearDnsCache(IOThread* io_thread) { | 81 void ClearDnsCache(IOThread* io_thread) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 97 const CrosSettings* cros_settings) { | 98 const CrosSettings* cros_settings) { |
| 98 bool allow_new_user = true; | 99 bool allow_new_user = true; |
| 99 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 100 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
| 100 bool allow_guest = true; | 101 bool allow_guest = true; |
| 101 cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | 102 cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
| 102 // Account creation depends on Guest sign-in (http://crosbug.com/24570). | 103 // Account creation depends on Guest sign-in (http://crosbug.com/24570). |
| 103 params->SetBoolean("createAccount", allow_new_user && allow_guest); | 104 params->SetBoolean("createAccount", allow_new_user && allow_guest); |
| 104 params->SetBoolean("guestSignin", allow_guest); | 105 params->SetBoolean("guestSignin", allow_guest); |
| 105 } | 106 } |
| 106 | 107 |
| 107 } // namespace | 108 } // namespace |
|
bartfab (slow)
2012/11/28 15:18:33
Nit: We always have two spaces before |namespace|.
xiyuan
2012/12/01 00:24:19
Most of the file are having two spaces before "//"
| |
| 108 | 109 |
| 109 // SigninScreenHandler implementation ------------------------------------------ | 110 // SigninScreenHandler implementation ------------------------------------------ |
| 110 | 111 |
| 111 SigninScreenHandler::SigninScreenHandler( | 112 SigninScreenHandler::SigninScreenHandler( |
| 112 const scoped_refptr<NetworkStateInformer>& network_state_informer) | 113 const scoped_refptr<NetworkStateInformer>& network_state_informer) |
| 113 : delegate_(NULL), | 114 : delegate_(NULL), |
| 114 native_window_delegate_(NULL), | 115 native_window_delegate_(NULL), |
| 115 show_on_init_(false), | 116 show_on_init_(false), |
| 116 oobe_ui_(false), | 117 oobe_ui_(false), |
| 117 focus_stolen_(false), | 118 focus_stolen_(false), |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 localized_strings->SetString("offlineLogin", | 183 localized_strings->SetString("offlineLogin", |
| 183 l10n_util::GetStringUTF16(IDS_OFFLINE_LOGIN_HTML)); | 184 l10n_util::GetStringUTF16(IDS_OFFLINE_LOGIN_HTML)); |
| 184 localized_strings->SetString("removeUser", | 185 localized_strings->SetString("removeUser", |
| 185 l10n_util::GetStringUTF16(IDS_LOGIN_REMOVE)); | 186 l10n_util::GetStringUTF16(IDS_LOGIN_REMOVE)); |
| 186 localized_strings->SetString("errorTpmFailure", | 187 localized_strings->SetString("errorTpmFailure", |
| 187 l10n_util::GetStringUTF16(IDS_LOGIN_ERROR_TPM_FAILURE)); | 188 l10n_util::GetStringUTF16(IDS_LOGIN_ERROR_TPM_FAILURE)); |
| 188 localized_strings->SetString("errorTpmFailureReboot", | 189 localized_strings->SetString("errorTpmFailureReboot", |
| 189 l10n_util::GetStringFUTF16( | 190 l10n_util::GetStringFUTF16( |
| 190 IDS_LOGIN_ERROR_TPM_FAILURE_REBOOT, | 191 IDS_LOGIN_ERROR_TPM_FAILURE_REBOOT, |
| 191 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 192 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
| 193 | |
| 194 policy::BrowserPolicyConnector* policy_connector = | |
| 195 g_browser_process->browser_policy_connector(); | |
| 196 | |
| 192 localized_strings->SetString("disabledAddUserTooltip", | 197 localized_strings->SetString("disabledAddUserTooltip", |
| 193 l10n_util::GetStringUTF16( | 198 l10n_util::GetStringUTF16( |
| 194 g_browser_process->browser_policy_connector()->IsEnterpriseManaged() ? | 199 policy_connector->IsEnterpriseManaged() ? |
| 195 IDS_DISABLED_ADD_USER_TOOLTIP_ENTERPRISE : | 200 IDS_DISABLED_ADD_USER_TOOLTIP_ENTERPRISE : |
| 196 IDS_DISABLED_ADD_USER_TOOLTIP)); | 201 IDS_DISABLED_ADD_USER_TOOLTIP)); |
| 197 | 202 |
| 203 std::string enterprise_domain; | |
| 204 if (policy_connector->IsEnterpriseManaged()) | |
| 205 enterprise_domain = policy_connector->GetEnterpriseDomain(); | |
| 206 | |
| 207 if (enterprise_domain.empty()) { | |
|
bartfab (slow)
2012/11/28 15:18:33
This case would be an error - public accounts defi
Nikita (slow)
2012/11/28 18:57:34
Is this a possible situation:
Chromebook stays at
bartfab (slow)
2012/11/28 19:19:11
Yes, this is entirely possible. A policy refresh c
bartfab (slow)
2012/11/29 14:39:39
Nikita clarified what happens when the login scree
xiyuan
2012/12/01 00:24:19
In new patch, the domain name is sent as part of u
| |
| 208 localized_strings->SetString("publicAccountInfo", std::string()); | |
| 209 } else { | |
| 210 localized_strings->SetString("publicAccountInfo", | |
| 211 l10n_util::GetStringFUTF16(IDS_LOGIN_PUBLIC_ACCOUNT_INFO, | |
| 212 UTF8ToUTF16(enterprise_domain))); | |
| 213 } | |
| 214 | |
| 215 localized_strings->SetString("publicAccountHint", | |
| 216 l10n_util::GetStringUTF16(IDS_LOGIN_PUBLIC_ACCOUNT_HINT)); | |
| 217 localized_strings->SetString("publicAccountEnter", | |
| 218 l10n_util::GetStringUTF16(IDS_LOGIN_PUBLIC_ACCOUNT_ENTER)); | |
| 219 | |
| 198 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) { | 220 if (chromeos::KioskModeSettings::Get()->IsKioskModeEnabled()) { |
| 199 localized_strings->SetString("demoLoginMessage", | 221 localized_strings->SetString("demoLoginMessage", |
| 200 l10n_util::GetStringUTF16(IDS_KIOSK_MODE_LOGIN_MESSAGE)); | 222 l10n_util::GetStringUTF16(IDS_KIOSK_MODE_LOGIN_MESSAGE)); |
| 201 } | 223 } |
| 202 } | 224 } |
| 203 | 225 |
| 204 void SigninScreenHandler::Show(bool oobe_ui) { | 226 void SigninScreenHandler::Show(bool oobe_ui) { |
| 205 CHECK(delegate_); | 227 CHECK(delegate_); |
| 206 oobe_ui_ = oobe_ui; | 228 oobe_ui_ = oobe_ui; |
| 207 if (!page_is_ready()) { | 229 if (!page_is_ready()) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 base::Unretained(this))); | 303 base::Unretained(this))); |
| 282 web_ui()->RegisterMessageCallback("getUsers", | 304 web_ui()->RegisterMessageCallback("getUsers", |
| 283 base::Bind(&SigninScreenHandler::HandleGetUsers, | 305 base::Bind(&SigninScreenHandler::HandleGetUsers, |
| 284 base::Unretained(this))); | 306 base::Unretained(this))); |
| 285 web_ui()->RegisterMessageCallback("launchDemoUser", | 307 web_ui()->RegisterMessageCallback("launchDemoUser", |
| 286 base::Bind(&SigninScreenHandler::HandleLaunchDemoUser, | 308 base::Bind(&SigninScreenHandler::HandleLaunchDemoUser, |
| 287 base::Unretained(this))); | 309 base::Unretained(this))); |
| 288 web_ui()->RegisterMessageCallback("launchIncognito", | 310 web_ui()->RegisterMessageCallback("launchIncognito", |
| 289 base::Bind(&SigninScreenHandler::HandleLaunchIncognito, | 311 base::Bind(&SigninScreenHandler::HandleLaunchIncognito, |
| 290 base::Unretained(this))); | 312 base::Unretained(this))); |
| 313 web_ui()->RegisterMessageCallback("launchPublicAccount", | |
| 314 base::Bind(&SigninScreenHandler::HandleLaunchPublicAccount, | |
| 315 base::Unretained(this))); | |
| 291 web_ui()->RegisterMessageCallback("offlineLogin", | 316 web_ui()->RegisterMessageCallback("offlineLogin", |
| 292 base::Bind(&SigninScreenHandler::HandleOfflineLogin, | 317 base::Bind(&SigninScreenHandler::HandleOfflineLogin, |
| 293 base::Unretained(this))); | 318 base::Unretained(this))); |
| 294 web_ui()->RegisterMessageCallback("showAddUser", | 319 web_ui()->RegisterMessageCallback("showAddUser", |
| 295 base::Bind(&SigninScreenHandler::HandleShowAddUser, | 320 base::Bind(&SigninScreenHandler::HandleShowAddUser, |
| 296 base::Unretained(this))); | 321 base::Unretained(this))); |
| 297 web_ui()->RegisterMessageCallback("shutdownSystem", | 322 web_ui()->RegisterMessageCallback("shutdownSystem", |
| 298 base::Bind(&SigninScreenHandler::HandleShutdownSystem, | 323 base::Bind(&SigninScreenHandler::HandleShutdownSystem, |
| 299 base::Unretained(this))); | 324 base::Unretained(this))); |
| 300 web_ui()->RegisterMessageCallback("loadWallpaper", | 325 web_ui()->RegisterMessageCallback("loadWallpaper", |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 616 void SigninScreenHandler::HandleLaunchDemoUser(const base::ListValue* args) { | 641 void SigninScreenHandler::HandleLaunchDemoUser(const base::ListValue* args) { |
| 617 if (delegate_) | 642 if (delegate_) |
| 618 delegate_->LoginAsRetailModeUser(); | 643 delegate_->LoginAsRetailModeUser(); |
| 619 } | 644 } |
| 620 | 645 |
| 621 void SigninScreenHandler::HandleLaunchIncognito(const base::ListValue* args) { | 646 void SigninScreenHandler::HandleLaunchIncognito(const base::ListValue* args) { |
| 622 if (delegate_) | 647 if (delegate_) |
| 623 delegate_->LoginAsGuest(); | 648 delegate_->LoginAsGuest(); |
| 624 } | 649 } |
| 625 | 650 |
| 651 void SigninScreenHandler::HandleLaunchPublicAccount( | |
| 652 const base::ListValue* args) { | |
| 653 std::string email; | |
| 654 if (!args->GetString(0, &email)) { | |
| 655 NOTREACHED(); | |
| 656 return; | |
| 657 } | |
| 658 email = gaia::SanitizeEmail(email); | |
|
bartfab (slow)
2012/11/28 15:11:38
This is not used right now. Please remove. I will
xiyuan
2012/12/01 00:24:19
Removed
| |
| 659 | |
| 660 // TODO(xiyuan): Wire this with real public account signin. | |
|
bartfab (slow)
2012/11/28 15:11:38
Feel free to list me as the TODO owner here. I wil
xiyuan
2012/12/01 00:24:19
Done.
| |
| 661 if (delegate_) | |
| 662 delegate_->LoginAsGuest(); | |
| 663 } | |
| 664 | |
| 626 void SigninScreenHandler::HandleOfflineLogin(const base::ListValue* args) { | 665 void SigninScreenHandler::HandleOfflineLogin(const base::ListValue* args) { |
| 627 if (!delegate_ || delegate_->IsShowUsers()) { | 666 if (!delegate_ || delegate_->IsShowUsers()) { |
| 628 NOTREACHED(); | 667 NOTREACHED(); |
| 629 return; | 668 return; |
| 630 } | 669 } |
| 631 if (!args->GetString(0, &email_)) | 670 if (!args->GetString(0, &email_)) |
| 632 email_.clear(); | 671 email_.clear(); |
| 633 | 672 |
| 634 // Load auth extension. Parameters are: force reload, do not load extension in | 673 // Load auth extension. Parameters are: force reload, do not load extension in |
| 635 // background, use offline version. | 674 // background, use offline version. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 728 | 767 |
| 729 ListValue users_list; | 768 ListValue users_list; |
| 730 const UserList& users = delegate_->GetUsers(); | 769 const UserList& users = delegate_->GetUsers(); |
| 731 | 770 |
| 732 bool single_user = users.size() == 1; | 771 bool single_user = users.size() == 1; |
| 733 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { | 772 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { |
| 734 const std::string& email = (*it)->email(); | 773 const std::string& email = (*it)->email(); |
| 735 std::string owner; | 774 std::string owner; |
| 736 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); | 775 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); |
| 737 bool is_owner = (email == owner); | 776 bool is_owner = (email == owner); |
| 777 bool public_account = ((*it)->GetType() == User::USER_TYPE_PUBLIC_ACCOUNT); | |
| 738 bool signed_in = *it == UserManager::Get()->GetLoggedInUser(); | 778 bool signed_in = *it == UserManager::Get()->GetLoggedInUser(); |
| 739 | 779 |
| 740 if (non_owner_count < max_non_owner_users || is_owner) { | 780 if (non_owner_count < max_non_owner_users || is_owner) { |
| 741 DictionaryValue* user_dict = new DictionaryValue(); | 781 DictionaryValue* user_dict = new DictionaryValue(); |
| 742 user_dict->SetString(kKeyUsername, email); | 782 user_dict->SetString(kKeyUsername, email); |
| 743 user_dict->SetString(kKeyEmailAddress, (*it)->display_email()); | 783 user_dict->SetString(kKeyEmailAddress, (*it)->display_email()); |
| 744 user_dict->SetString(kKeyDisplayName, (*it)->GetDisplayName()); | 784 user_dict->SetString(kKeyDisplayName, (*it)->GetDisplayName()); |
| 745 user_dict->SetString(kKeyNameTooltip, (*it)->display_email()); | 785 user_dict->SetString(kKeyNameTooltip, (*it)->display_email()); |
| 786 user_dict->SetBoolean(kKeyPublicAccount, public_account); | |
| 746 user_dict->SetInteger(kKeyOauthTokenStatus, (*it)->oauth_token_status()); | 787 user_dict->SetInteger(kKeyOauthTokenStatus, (*it)->oauth_token_status()); |
| 747 user_dict->SetBoolean(kKeySignedIn, signed_in); | 788 user_dict->SetBoolean(kKeySignedIn, signed_in); |
| 748 | 789 |
| 749 // Single user check here is necessary because owner info might not be | 790 // Single user check here is necessary because owner info might not be |
| 750 // available when running into login screen on first boot. | 791 // available when running into login screen on first boot. |
| 751 // See http://crosbug.com/12723 | 792 // See http://crosbug.com/12723 |
| 752 user_dict->SetBoolean(kKeyCanRemove, | 793 user_dict->SetBoolean(kKeyCanRemove, |
| 753 !single_user && | 794 !single_user && |
| 754 !email.empty() && | 795 !email.empty() && |
| 755 !is_owner && | 796 !is_owner && |
| 797 !public_account && | |
| 756 !signed_in); | 798 !signed_in); |
| 757 | 799 |
| 758 users_list.Append(user_dict); | 800 users_list.Append(user_dict); |
| 759 if (!is_owner) | 801 if (!is_owner) |
| 760 ++non_owner_count; | 802 ++non_owner_count; |
| 761 } | 803 } |
| 762 } | 804 } |
| 763 | 805 |
| 764 base::FundamentalValue animated_value(animated); | 806 base::FundamentalValue animated_value(animated); |
| 765 base::FundamentalValue guest_value(delegate_->IsShowGuest()); | 807 base::FundamentalValue guest_value(delegate_->IsShowGuest()); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1000 ConnectionType last_network_type) { | 1042 ConnectionType last_network_type) { |
| 1001 base::FundamentalValue state_value(state); | 1043 base::FundamentalValue state_value(state); |
| 1002 base::StringValue network_value(network_name); | 1044 base::StringValue network_value(network_name); |
| 1003 base::StringValue reason_value(reason); | 1045 base::StringValue reason_value(reason); |
| 1004 base::FundamentalValue last_network_value(last_network_type); | 1046 base::FundamentalValue last_network_value(last_network_type); |
| 1005 web_ui()->CallJavascriptFunction(callback, | 1047 web_ui()->CallJavascriptFunction(callback, |
| 1006 state_value, network_value, reason_value, last_network_value); | 1048 state_value, network_value, reason_value, last_network_value); |
| 1007 } | 1049 } |
| 1008 | 1050 |
| 1009 } // namespace chromeos | 1051 } // namespace chromeos |
| OLD | NEW |