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/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 SendState(*it, reason); | 249 SendState(*it, reason); |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 // SigninScreenHandler implementation ------------------------------------------ | 253 // SigninScreenHandler implementation ------------------------------------------ |
254 | 254 |
255 SigninScreenHandler::SigninScreenHandler() | 255 SigninScreenHandler::SigninScreenHandler() |
256 : delegate_(NULL), | 256 : delegate_(NULL), |
257 show_on_init_(false), | 257 show_on_init_(false), |
258 oobe_ui_(false), | 258 oobe_ui_(false), |
259 is_first_webui_ready_(false), | 259 focus_stolen_(false), |
260 is_first_attempt_(true), | 260 gaia_silent_load_(false), |
261 dns_cleared_(false), | 261 dns_cleared_(false), |
262 dns_clear_task_running_(false), | 262 dns_clear_task_running_(false), |
263 cookies_cleared_(false), | 263 cookies_cleared_(false), |
264 cookie_remover_(NULL), | 264 cookie_remover_(NULL), |
265 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 265 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
266 key_event_listener_(NULL) { | 266 key_event_listener_(NULL) { |
267 CrosSettings::Get()->AddSettingsObserver(kAccountsPrefAllowNewUser, this); | 267 CrosSettings::Get()->AddSettingsObserver(kAccountsPrefAllowNewUser, this); |
268 CrosSettings::Get()->AddSettingsObserver(kAccountsPrefAllowGuest, this); | 268 CrosSettings::Get()->AddSettingsObserver(kAccountsPrefAllowGuest, this); |
269 } | 269 } |
270 | 270 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
546 dns_clear_task_running_ = false; | 546 dns_clear_task_running_ = false; |
547 dns_cleared_ = true; | 547 dns_cleared_ = true; |
548 ShowSigninScreenIfReady(); | 548 ShowSigninScreenIfReady(); |
549 } | 549 } |
550 | 550 |
551 void SigninScreenHandler::ShowSigninScreenIfReady() { | 551 void SigninScreenHandler::ShowSigninScreenIfReady() { |
552 if (!dns_cleared_ || !cookies_cleared_) | 552 if (!dns_cleared_ || !cookies_cleared_) |
553 return; | 553 return; |
554 | 554 |
555 LoadAuthExtension(!is_first_attempt_, false, false); | 555 LoadAuthExtension(!gaia_silent_load_, false, false); |
556 ShowScreen(kGaiaSigninScreen, NULL); | 556 ShowScreen(kGaiaSigninScreen, NULL); |
557 | 557 |
558 if (is_first_attempt_) { | 558 if (gaia_silent_load_) { |
559 is_first_attempt_ = false; | 559 // The variable is assigned to false because silently loaded Gaia page was |
560 if (is_first_webui_ready_) | 560 // used. |
| 561 gaia_silent_load_ = false; |
| 562 if (focus_stolen_) |
561 HandleLoginWebuiReady(NULL); | 563 HandleLoginWebuiReady(NULL); |
562 } | 564 } |
563 } | 565 } |
564 | 566 |
565 void SigninScreenHandler::LoadAuthExtension( | 567 void SigninScreenHandler::LoadAuthExtension( |
566 bool force, bool silent_load, bool offline) { | 568 bool force, bool silent_load, bool offline) { |
567 DictionaryValue params; | 569 DictionaryValue params; |
568 | 570 |
569 params.SetBoolean("forceReload", force); | 571 params.SetBoolean("forceReload", force); |
570 params.SetBoolean("silentLoad", silent_load); | 572 params.SetBoolean("silentLoad", silent_load); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 } | 719 } |
718 | 720 |
719 delegate_->RemoveUser(email); | 721 delegate_->RemoveUser(email); |
720 } | 722 } |
721 | 723 |
722 void SigninScreenHandler::HandleShowAddUser(const base::ListValue* args) { | 724 void SigninScreenHandler::HandleShowAddUser(const base::ListValue* args) { |
723 email_.clear(); | 725 email_.clear(); |
724 // |args| can be null if it's OOBE. | 726 // |args| can be null if it's OOBE. |
725 if (args) | 727 if (args) |
726 args->GetString(0, &email_); | 728 args->GetString(0, &email_); |
727 LOG(ERROR) << "HandleShowAddUser: email=" << email_ << ", first_attempt=" | 729 LOG(ERROR) << "HandleShowAddUser: email=" << email_ << ", gaia_sielnt_load=" |
728 << is_first_attempt_; | 730 << gaia_silent_load_; |
729 | 731 |
730 if (is_first_attempt_ && email_.empty()) { | 732 if (gaia_silent_load_ && email_.empty()) { |
731 dns_cleared_ = true; | 733 dns_cleared_ = true; |
732 cookies_cleared_ = true; | 734 cookies_cleared_ = true; |
733 ShowSigninScreenIfReady(); | 735 ShowSigninScreenIfReady(); |
734 } else { | 736 } else { |
735 StartClearingDnsCache(); | 737 StartClearingDnsCache(); |
736 StartClearingCookies(); | 738 StartClearingCookies(); |
737 } | 739 } |
738 } | 740 } |
739 | 741 |
740 void SigninScreenHandler::HandleToggleEnrollmentScreen( | 742 void SigninScreenHandler::HandleToggleEnrollmentScreen( |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 web_ui()->CallJavascriptFunction("login.AccountPickerScreen.loadUsers", | 822 web_ui()->CallJavascriptFunction("login.AccountPickerScreen.loadUsers", |
821 users_list, animated_value); | 823 users_list, animated_value); |
822 } | 824 } |
823 | 825 |
824 void SigninScreenHandler::HandleAccountPickerReady( | 826 void SigninScreenHandler::HandleAccountPickerReady( |
825 const base::ListValue* args) { | 827 const base::ListValue* args) { |
826 // Fetching of the extension is not started before account picker page is | 828 // Fetching of the extension is not started before account picker page is |
827 // loaded because it can affect the loading speed. | 829 // loaded because it can affect the loading speed. |
828 // Do not load the extension for the screen locker, see crosbug.com/25018. | 830 // Do not load the extension for the screen locker, see crosbug.com/25018. |
829 if (!ScreenLocker::default_screen_locker() && | 831 if (!ScreenLocker::default_screen_locker() && |
830 is_first_attempt_ && | 832 !gaia_silent_load_ && |
831 !cookie_remover_ && | 833 !cookie_remover_ && |
832 !dns_clear_task_running_) | 834 !dns_clear_task_running_) { |
| 835 gaia_silent_load_ = true; |
833 LoadAuthExtension(true, true, false); | 836 LoadAuthExtension(true, true, false); |
| 837 } |
834 | 838 |
835 if (ScreenLocker::default_screen_locker()) { | 839 if (ScreenLocker::default_screen_locker()) { |
836 content::NotificationService::current()->Notify( | 840 content::NotificationService::current()->Notify( |
837 chrome::NOTIFICATION_LOCK_WEBUI_READY, | 841 chrome::NOTIFICATION_LOCK_WEBUI_READY, |
838 content::NotificationService::AllSources(), | 842 content::NotificationService::AllSources(), |
839 content::NotificationService::NoDetails()); | 843 content::NotificationService::NoDetails()); |
840 } | 844 } |
841 } | 845 } |
842 | 846 |
843 void SigninScreenHandler::HandleLoginWebuiReady(const base::ListValue* args) { | 847 void SigninScreenHandler::HandleLoginWebuiReady(const base::ListValue* args) { |
844 // crosbug.com/26646. | 848 // crosbug.com/26646. |
845 LOG(ERROR) << "HandleLoginWebuiReady: first_webui_ready=" | 849 LOG(ERROR) << "HandleLoginWebuiReady: focus_stolen=" << focus_stolen_ |
846 << is_first_webui_ready_ | 850 << ", gaia_silent_load=" << gaia_silent_load_; |
847 << ", first_attempt=" << is_first_attempt_; | |
848 | 851 |
849 if (is_first_webui_ready_) { | 852 if (focus_stolen_) { |
850 // Set focus to the Gaia page. | 853 // Set focus to the Gaia page. |
851 // TODO(altimofeev): temporary solution, until focus parameters are | 854 // TODO(altimofeev): temporary solution, until focus parameters are |
852 // implemented on the Gaia side. | 855 // implemented on the Gaia side. |
853 // Do this only once. Any subsequent call would relod GAIA frame. | 856 // Do this only once. Any subsequent call would relod GAIA frame. |
854 is_first_webui_ready_ = false; | 857 focus_stolen_ = false; |
855 const char code[] = "gWindowOnLoad();"; | 858 const char code[] = "gWindowOnLoad();"; |
856 RenderViewHost* rvh = web_ui()->GetWebContents()->GetRenderViewHost(); | 859 RenderViewHost* rvh = web_ui()->GetWebContents()->GetRenderViewHost(); |
857 rvh->ExecuteJavascriptInWebFrame( | 860 rvh->ExecuteJavascriptInWebFrame( |
858 ASCIIToUTF16("//iframe[@id='signin-frame']\n//iframe"), | 861 ASCIIToUTF16("//iframe[@id='signin-frame']\n//iframe"), |
859 ASCIIToUTF16(code)); | 862 ASCIIToUTF16(code)); |
860 } | 863 } |
861 if (!is_first_attempt_) { | 864 if (!gaia_silent_load_) { |
862 content::NotificationService::current()->Notify( | 865 content::NotificationService::current()->Notify( |
863 chrome::NOTIFICATION_LOGIN_WEBUI_READY, | 866 chrome::NOTIFICATION_LOGIN_WEBUI_READY, |
864 content::NotificationService::AllSources(), | 867 content::NotificationService::AllSources(), |
865 content::NotificationService::NoDetails()); | 868 content::NotificationService::NoDetails()); |
866 } else { | 869 } else { |
867 is_first_webui_ready_ = true; | 870 focus_stolen_ = true; |
868 // Prevent focus stealing by the Gaia page. | 871 // Prevent focus stealing by the Gaia page. |
869 // TODO(altimofeev): temporary solution, until focus parameters are | 872 // TODO(altimofeev): temporary solution, until focus parameters are |
870 // implemented on the Gaia side. | 873 // implemented on the Gaia side. |
871 const char code[] = "var gWindowOnLoad = window.onload; " | 874 const char code[] = "var gWindowOnLoad = window.onload; " |
872 "window.onload=function() {};"; | 875 "window.onload=function() {};"; |
873 RenderViewHost* rvh = web_ui()->GetWebContents()->GetRenderViewHost(); | 876 RenderViewHost* rvh = web_ui()->GetWebContents()->GetRenderViewHost(); |
874 rvh->ExecuteJavascriptInWebFrame( | 877 rvh->ExecuteJavascriptInWebFrame( |
875 ASCIIToUTF16("//iframe[@id='signin-frame']\n//iframe"), | 878 ASCIIToUTF16("//iframe[@id='signin-frame']\n//iframe"), |
876 ASCIIToUTF16(code)); | 879 ASCIIToUTF16(code)); |
877 } | 880 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 | 960 |
958 cookie_remover_ = new BrowsingDataRemover( | 961 cookie_remover_ = new BrowsingDataRemover( |
959 Profile::FromWebUI(web_ui()), | 962 Profile::FromWebUI(web_ui()), |
960 BrowsingDataRemover::EVERYTHING, | 963 BrowsingDataRemover::EVERYTHING, |
961 base::Time()); | 964 base::Time()); |
962 cookie_remover_->AddObserver(this); | 965 cookie_remover_->AddObserver(this); |
963 cookie_remover_->Remove(BrowsingDataRemover::REMOVE_SITE_DATA); | 966 cookie_remover_->Remove(BrowsingDataRemover::REMOVE_SITE_DATA); |
964 } | 967 } |
965 | 968 |
966 } // namespace chromeos | 969 } // namespace chromeos |
OLD | NEW |