| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/stringprintf.h" | |
| 13 #include "base/task.h" | 12 #include "base/task.h" |
| 14 #include "base/values.h" | 13 #include "base/values.h" |
| 15 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/browser_shutdown.h" | 15 #include "chrome/browser/browser_shutdown.h" |
| 17 #include "chrome/browser/chromeos/cros/cros_library.h" | 16 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 18 #include "chrome/browser/chromeos/cros/network_library.h" | 17 #include "chrome/browser/chromeos/cros/network_library.h" |
| 19 #include "chrome/browser/chromeos/cros/power_library.h" | 18 #include "chrome/browser/chromeos/cros/power_library.h" |
| 20 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 19 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 21 #include "chrome/browser/chromeos/input_method/xkeyboard.h" | 20 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
| 22 #include "chrome/browser/chromeos/login/screen_locker.h" | 21 #include "chrome/browser/chromeos/login/screen_locker.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 49 const char kGaiaSigninScreen[] = "gaia-signin"; | 48 const char kGaiaSigninScreen[] = "gaia-signin"; |
| 50 // Start page of GAIA authentication extension. | 49 // Start page of GAIA authentication extension. |
| 51 const char kGaiaExtStartPage[] = | 50 const char kGaiaExtStartPage[] = |
| 52 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/main.html"; | 51 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/main.html"; |
| 53 | 52 |
| 54 // User dictionary keys. | 53 // User dictionary keys. |
| 55 const char kKeyName[] = "name"; | 54 const char kKeyName[] = "name"; |
| 56 const char kKeyEmailAddress[] = "emailAddress"; | 55 const char kKeyEmailAddress[] = "emailAddress"; |
| 57 const char kKeySignedIn[] = "signedIn"; | 56 const char kKeySignedIn[] = "signedIn"; |
| 58 const char kKeyCanRemove[] = "canRemove"; | 57 const char kKeyCanRemove[] = "canRemove"; |
| 59 const char kKeyImageUrl[] = "imageUrl"; | |
| 60 const char kKeyOauthTokenStatus[] = "oauthTokenStatus"; | 58 const char kKeyOauthTokenStatus[] = "oauthTokenStatus"; |
| 61 | 59 |
| 62 // Max number of users to show. | 60 // Max number of users to show. |
| 63 const int kMaxUsers = 5; | 61 const int kMaxUsers = 5; |
| 64 | 62 |
| 65 const char kReasonNetworkChanged[] = "network changed"; | 63 const char kReasonNetworkChanged[] = "network changed"; |
| 66 const char kReasonProxyChanged[] = "proxy changed"; | 64 const char kReasonProxyChanged[] = "proxy changed"; |
| 67 | 65 |
| 68 // Sanitize emails. Currently, it only ensures all emails have a domain. | 66 // Sanitize emails. Currently, it only ensures all emails have a domain. |
| 69 std::string SanitizeEmail(const std::string& email) { | 67 std::string SanitizeEmail(const std::string& email) { |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 397 |
| 400 void SigninScreenHandler::OnLoginSuccess(const std::string& username) { | 398 void SigninScreenHandler::OnLoginSuccess(const std::string& username) { |
| 401 base::StringValue username_value(username); | 399 base::StringValue username_value(username); |
| 402 web_ui_->CallJavascriptFunction("cr.ui.Oobe.onLoginSuccess", username_value); | 400 web_ui_->CallJavascriptFunction("cr.ui.Oobe.onLoginSuccess", username_value); |
| 403 } | 401 } |
| 404 | 402 |
| 405 void SigninScreenHandler::OnUserRemoved(const std::string& username) { | 403 void SigninScreenHandler::OnUserRemoved(const std::string& username) { |
| 406 SendUserList(false); | 404 SendUserList(false); |
| 407 } | 405 } |
| 408 | 406 |
| 407 void SigninScreenHandler::OnUserImageChanged(const User& user) { |
| 408 base::StringValue user_email(user.email()); |
| 409 web_ui_->CallJavascriptFunction( |
| 410 "login.AccountPickerScreen.updateUserImage", user_email); |
| 411 } |
| 412 |
| 409 void SigninScreenHandler::ShowError(int login_attempts, | 413 void SigninScreenHandler::ShowError(int login_attempts, |
| 410 const std::string& error_text, | 414 const std::string& error_text, |
| 411 const std::string& help_link_text, | 415 const std::string& help_link_text, |
| 412 HelpAppLauncher::HelpTopic help_topic_id) { | 416 HelpAppLauncher::HelpTopic help_topic_id) { |
| 413 base::FundamentalValue login_attempts_value(login_attempts); | 417 base::FundamentalValue login_attempts_value(login_attempts); |
| 414 base::StringValue error_message(error_text); | 418 base::StringValue error_message(error_text); |
| 415 base::StringValue help_link(help_link_text); | 419 base::StringValue help_link(help_link_text); |
| 416 base::FundamentalValue help_id(static_cast<int>(help_topic_id)); | 420 base::FundamentalValue help_id(static_cast<int>(help_topic_id)); |
| 417 web_ui_->CallJavascriptFunction("cr.ui.Oobe.showSignInError", | 421 web_ui_->CallJavascriptFunction("cr.ui.Oobe.showSignInError", |
| 418 login_attempts_value, | 422 login_attempts_value, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 | 614 |
| 611 // Single user check here is necessary because owner info might not be | 615 // Single user check here is necessary because owner info might not be |
| 612 // available when running into login screen on first boot. | 616 // available when running into login screen on first boot. |
| 613 // See http://crosbug.com/12723 | 617 // See http://crosbug.com/12723 |
| 614 user_dict->SetBoolean(kKeyCanRemove, | 618 user_dict->SetBoolean(kKeyCanRemove, |
| 615 !single_user && | 619 !single_user && |
| 616 !email.empty() && | 620 !email.empty() && |
| 617 !is_owner && | 621 !is_owner && |
| 618 !signed_in); | 622 !signed_in); |
| 619 | 623 |
| 620 if (!email.empty()) { | |
| 621 long long timestamp = base::TimeTicks::Now().ToInternalValue(); | |
| 622 std::string image_url( | |
| 623 StringPrintf("%s%s?id=%lld", | |
| 624 chrome::kChromeUIUserImageURL, | |
| 625 email.c_str(), | |
| 626 timestamp)); | |
| 627 user_dict->SetString(kKeyImageUrl, image_url); | |
| 628 } else { | |
| 629 std::string image_url(std::string(chrome::kChromeUIScheme) + "://" + | |
| 630 std::string(chrome::kChromeUIThemePath) + | |
| 631 "/IDR_LOGIN_DEFAULT_USER"); | |
| 632 user_dict->SetString(kKeyImageUrl, image_url); | |
| 633 } | |
| 634 | |
| 635 users_list.Append(user_dict); | 624 users_list.Append(user_dict); |
| 636 if (!is_owner) | 625 if (!is_owner) |
| 637 ++non_owner_count; | 626 ++non_owner_count; |
| 638 } | 627 } |
| 639 } | 628 } |
| 640 | 629 |
| 641 if (show_guest) { | 630 if (show_guest) { |
| 642 // Add the Guest to the user list. | 631 // Add the Guest to the user list. |
| 643 DictionaryValue* guest_dict = new DictionaryValue(); | 632 DictionaryValue* guest_dict = new DictionaryValue(); |
| 644 guest_dict->SetString(kKeyName, l10n_util::GetStringUTF16(IDS_GUEST)); | 633 guest_dict->SetString(kKeyName, l10n_util::GetStringUTF16(IDS_GUEST)); |
| 645 guest_dict->SetString(kKeyEmailAddress, ""); | 634 guest_dict->SetString(kKeyEmailAddress, ""); |
| 646 guest_dict->SetBoolean(kKeyCanRemove, false); | 635 guest_dict->SetBoolean(kKeyCanRemove, false); |
| 647 guest_dict->SetInteger(kKeyOauthTokenStatus, | 636 guest_dict->SetInteger(kKeyOauthTokenStatus, |
| 648 User::OAUTH_TOKEN_STATUS_UNKNOWN); | 637 User::OAUTH_TOKEN_STATUS_UNKNOWN); |
| 649 std::string image_url(std::string(chrome::kChromeUIScheme) + "://" + | |
| 650 std::string(chrome::kChromeUIThemePath) + "/IDR_LOGIN_GUEST"); | |
| 651 guest_dict->SetString(kKeyImageUrl, image_url); | |
| 652 users_list.Append(guest_dict); | 638 users_list.Append(guest_dict); |
| 653 } | 639 } |
| 654 | 640 |
| 655 // Call the Javascript callback | 641 // Call the Javascript callback |
| 656 base::FundamentalValue animated_value(animated); | 642 base::FundamentalValue animated_value(animated); |
| 657 web_ui_->CallJavascriptFunction("login.AccountPickerScreen.loadUsers", | 643 web_ui_->CallJavascriptFunction("login.AccountPickerScreen.loadUsers", |
| 658 users_list, animated_value); | 644 users_list, animated_value); |
| 659 } | 645 } |
| 660 | 646 |
| 661 void SigninScreenHandler::HandleAccountPickerReady( | 647 void SigninScreenHandler::HandleAccountPickerReady( |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 | 724 |
| 739 cookie_remover_ = new BrowsingDataRemover( | 725 cookie_remover_ = new BrowsingDataRemover( |
| 740 Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context()), | 726 Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context()), |
| 741 BrowsingDataRemover::EVERYTHING, | 727 BrowsingDataRemover::EVERYTHING, |
| 742 base::Time()); | 728 base::Time()); |
| 743 cookie_remover_->AddObserver(this); | 729 cookie_remover_->AddObserver(this); |
| 744 cookie_remover_->Remove(BrowsingDataRemover::REMOVE_SITE_DATA); | 730 cookie_remover_->Remove(BrowsingDataRemover::REMOVE_SITE_DATA); |
| 745 } | 731 } |
| 746 | 732 |
| 747 } // namespace chromeos | 733 } // namespace chromeos |
| OLD | NEW |