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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
248 SendState(*it, reason); | 248 SendState(*it, reason); |
249 } | 249 } |
250 } | 250 } |
251 | 251 |
252 // SigninScreenHandler implementation ------------------------------------------ | 252 // SigninScreenHandler implementation ------------------------------------------ |
253 | 253 |
254 SigninScreenHandler::SigninScreenHandler() | 254 SigninScreenHandler::SigninScreenHandler() |
255 : delegate_(NULL), | 255 : delegate_(NULL), |
256 show_on_init_(false), | 256 show_on_init_(false), |
257 oobe_ui_(false), | 257 oobe_ui_(false), |
258 is_first_webui_ready_(false), | 258 focus_is_stolen_(false), |
259 is_first_attempt_(true), | 259 gaia_is_preloaded_(false), |
260 dns_cleared_(false), | 260 dns_cleared_(false), |
261 dns_clear_task_running_(false), | 261 dns_clear_task_running_(false), |
262 cookies_cleared_(false), | 262 cookies_cleared_(false), |
263 cookie_remover_(NULL), | 263 cookie_remover_(NULL), |
264 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 264 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
265 key_event_listener_(NULL) { | 265 key_event_listener_(NULL) { |
266 CrosSettings::Get()->AddSettingsObserver(kAccountsPrefAllowNewUser, this); | 266 CrosSettings::Get()->AddSettingsObserver(kAccountsPrefAllowNewUser, this); |
267 CrosSettings::Get()->AddSettingsObserver(kAccountsPrefAllowGuest, this); | 267 CrosSettings::Get()->AddSettingsObserver(kAccountsPrefAllowGuest, this); |
268 } | 268 } |
269 | 269 |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 ShowSigninScreenIfReady(); | 545 ShowSigninScreenIfReady(); |
546 } | 546 } |
547 | 547 |
548 void SigninScreenHandler::ShowSigninScreenIfReady() { | 548 void SigninScreenHandler::ShowSigninScreenIfReady() { |
549 LOG(ERROR) << "ShowSigninScreenIfReady: dns=" << dns_cleared_ | 549 LOG(ERROR) << "ShowSigninScreenIfReady: dns=" << dns_cleared_ |
550 << ", cookie=" << cookies_cleared_; | 550 << ", cookie=" << cookies_cleared_; |
551 | 551 |
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_is_preloaded_, false, false); |
556 ShowScreen(kGaiaSigninScreen, NULL); | 556 ShowScreen(kGaiaSigninScreen, NULL); |
557 | 557 |
558 if (is_first_attempt_) { | 558 if (gaia_is_preloaded_) { |
559 is_first_attempt_ = false; | 559 gaia_is_preloaded_ = false; |
Daniel Erat
2012/03/06 15:23:47
could you add a comment about this? it seems a bi
altimofeev
2012/03/06 17:39:22
Done.
| |
560 if (is_first_webui_ready_) | 560 if (focus_is_stolen_) |
561 HandleLoginWebuiReady(NULL); | 561 HandleLoginWebuiReady(NULL); |
562 } | 562 } |
563 } | 563 } |
564 | 564 |
565 void SigninScreenHandler::LoadAuthExtension( | 565 void SigninScreenHandler::LoadAuthExtension( |
566 bool force, bool silent_load, bool offline) { | 566 bool force, bool silent_load, bool offline) { |
567 DictionaryValue params; | 567 DictionaryValue params; |
568 | 568 |
569 params.SetBoolean("forceReload", force); | 569 params.SetBoolean("forceReload", force); |
570 params.SetBoolean("silentLoad", silent_load); | 570 params.SetBoolean("silentLoad", silent_load); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
717 } | 717 } |
718 | 718 |
719 delegate_->RemoveUser(email); | 719 delegate_->RemoveUser(email); |
720 } | 720 } |
721 | 721 |
722 void SigninScreenHandler::HandleShowAddUser(const base::ListValue* args) { | 722 void SigninScreenHandler::HandleShowAddUser(const base::ListValue* args) { |
723 email_.clear(); | 723 email_.clear(); |
724 // |args| can be null if it's OOBE. | 724 // |args| can be null if it's OOBE. |
725 if (args) | 725 if (args) |
726 args->GetString(0, &email_); | 726 args->GetString(0, &email_); |
727 LOG(ERROR) << "HandleShowAddUser: email=" << email_ << ", first_attempt=" | 727 LOG(ERROR) << "HandleShowAddUser: email=" << email_ << ", first_attempt=" |
Nikita (slow)
2012/03/06 14:36:02
nit: update comment
altimofeev
2012/03/06 17:39:22
Done.
| |
728 << is_first_attempt_; | 728 << gaia_is_preloaded_; |
729 | 729 |
730 if (is_first_attempt_ && email_.empty()) { | 730 if (gaia_is_preloaded_ && email_.empty()) { |
731 dns_cleared_ = true; | 731 dns_cleared_ = true; |
732 cookies_cleared_ = true; | 732 cookies_cleared_ = true; |
733 ShowSigninScreenIfReady(); | 733 ShowSigninScreenIfReady(); |
734 } else { | 734 } else { |
735 StartClearingDnsCache(); | 735 StartClearingDnsCache(); |
736 StartClearingCookies(); | 736 StartClearingCookies(); |
737 } | 737 } |
738 } | 738 } |
739 | 739 |
740 void SigninScreenHandler::HandleToggleEnrollmentScreen( | 740 void SigninScreenHandler::HandleToggleEnrollmentScreen( |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
820 web_ui()->CallJavascriptFunction("login.AccountPickerScreen.loadUsers", | 820 web_ui()->CallJavascriptFunction("login.AccountPickerScreen.loadUsers", |
821 users_list, animated_value); | 821 users_list, animated_value); |
822 } | 822 } |
823 | 823 |
824 void SigninScreenHandler::HandleAccountPickerReady( | 824 void SigninScreenHandler::HandleAccountPickerReady( |
825 const base::ListValue* args) { | 825 const base::ListValue* args) { |
826 // Fetching of the extension is not started before account picker page is | 826 // Fetching of the extension is not started before account picker page is |
827 // loaded because it can affect the loading speed. | 827 // loaded because it can affect the loading speed. |
828 // Do not load the extension for the screen locker, see crosbug.com/25018. | 828 // Do not load the extension for the screen locker, see crosbug.com/25018. |
829 if (!ScreenLocker::default_screen_locker() && | 829 if (!ScreenLocker::default_screen_locker() && |
830 is_first_attempt_ && | 830 !gaia_is_preloaded_ && |
831 !cookie_remover_ && | 831 !cookie_remover_ && |
832 !dns_clear_task_running_) | 832 !dns_clear_task_running_) { |
833 gaia_is_preloaded_ = true; | |
Nikita (slow)
2012/03/06 14:36:02
GAIA is not preloaded at this point. So this varia
altimofeev
2012/03/06 17:39:22
Done.
| |
833 LoadAuthExtension(true, true, false); | 834 LoadAuthExtension(true, true, false); |
Nikita (slow)
2012/03/06 14:36:02
Should be LoadAuthExtension(gaia_is_preloaded_, tr
altimofeev
2012/03/06 17:39:22
it couldn't be substituted everywhere, so from my
| |
835 } | |
834 | 836 |
835 if (ScreenLocker::default_screen_locker()) { | 837 if (ScreenLocker::default_screen_locker()) { |
836 content::NotificationService::current()->Notify( | 838 content::NotificationService::current()->Notify( |
837 chrome::NOTIFICATION_LOCK_WEBUI_READY, | 839 chrome::NOTIFICATION_LOCK_WEBUI_READY, |
838 content::NotificationService::AllSources(), | 840 content::NotificationService::AllSources(), |
839 content::NotificationService::NoDetails()); | 841 content::NotificationService::NoDetails()); |
840 } | 842 } |
841 } | 843 } |
842 | 844 |
843 void SigninScreenHandler::HandleLoginWebuiReady(const base::ListValue* args) { | 845 void SigninScreenHandler::HandleLoginWebuiReady(const base::ListValue* args) { |
844 LOG(ERROR) << "HandleLoginWebuiReady: first_webui_ready=" | 846 DLOG(INFO) << "HandleLoginWebuiReady: focus_is_stolen=" << focus_is_stolen_ |
845 << is_first_webui_ready_ | 847 << ", gaia_is_preloaded=" << gaia_is_preloaded_; |
846 << ", first_attempt=" << is_first_attempt_; | |
847 | 848 |
848 if (is_first_webui_ready_) { | 849 if (focus_is_stolen_) { |
849 // Set focus to the Gaia page. | 850 // Set focus to the Gaia page. |
850 // TODO(altimofeev): temporary solution, until focus parameters are | 851 // TODO(altimofeev): temporary solution, until focus parameters are |
851 // implemented on the Gaia side. | 852 // implemented on the Gaia side. |
852 // Do this only once. Any subsequent call would relod GAIA frame. | 853 // Do this only once. Any subsequent call would relod GAIA frame. |
853 is_first_webui_ready_ = false; | 854 focus_is_stolen_ = false; |
854 const char code[] = "gWindowOnLoad();"; | 855 const char code[] = "gWindowOnLoad();"; |
855 RenderViewHost* rvh = web_ui()->GetWebContents()->GetRenderViewHost(); | 856 RenderViewHost* rvh = web_ui()->GetWebContents()->GetRenderViewHost(); |
856 rvh->ExecuteJavascriptInWebFrame( | 857 rvh->ExecuteJavascriptInWebFrame( |
857 ASCIIToUTF16("//iframe[@id='signin-frame']\n//iframe"), | 858 ASCIIToUTF16("//iframe[@id='signin-frame']\n//iframe"), |
858 ASCIIToUTF16(code)); | 859 ASCIIToUTF16(code)); |
859 } | 860 } |
860 if (!is_first_attempt_) { | 861 if (!gaia_is_preloaded_) { |
Daniel Erat
2012/03/06 15:23:47
is_first_attempt_ was initialized to true, but gai
altimofeev
2012/03/06 17:39:22
Yes, it is correct now. We should only grab the fo
| |
861 content::NotificationService::current()->Notify( | 862 content::NotificationService::current()->Notify( |
862 chrome::NOTIFICATION_LOGIN_WEBUI_READY, | 863 chrome::NOTIFICATION_LOGIN_WEBUI_READY, |
863 content::NotificationService::AllSources(), | 864 content::NotificationService::AllSources(), |
864 content::NotificationService::NoDetails()); | 865 content::NotificationService::NoDetails()); |
865 } else { | 866 } else { |
866 is_first_webui_ready_ = true; | 867 focus_is_stolen_ = true; |
867 // Prevent focus stealing by the Gaia page. | 868 // Prevent focus stealing by the Gaia page. |
868 // TODO(altimofeev): temporary solution, until focus parameters are | 869 // TODO(altimofeev): temporary solution, until focus parameters are |
869 // implemented on the Gaia side. | 870 // implemented on the Gaia side. |
870 const char code[] = "var gWindowOnLoad = window.onload; " | 871 const char code[] = "var gWindowOnLoad = window.onload; " |
871 "window.onload=function() {};"; | 872 "window.onload=function() {};"; |
872 RenderViewHost* rvh = web_ui()->GetWebContents()->GetRenderViewHost(); | 873 RenderViewHost* rvh = web_ui()->GetWebContents()->GetRenderViewHost(); |
873 rvh->ExecuteJavascriptInWebFrame( | 874 rvh->ExecuteJavascriptInWebFrame( |
874 ASCIIToUTF16("//iframe[@id='signin-frame']\n//iframe"), | 875 ASCIIToUTF16("//iframe[@id='signin-frame']\n//iframe"), |
875 ASCIIToUTF16(code)); | 876 ASCIIToUTF16(code)); |
876 } | 877 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
942 | 943 |
943 cookie_remover_ = new BrowsingDataRemover( | 944 cookie_remover_ = new BrowsingDataRemover( |
944 Profile::FromWebUI(web_ui()), | 945 Profile::FromWebUI(web_ui()), |
945 BrowsingDataRemover::EVERYTHING, | 946 BrowsingDataRemover::EVERYTHING, |
946 base::Time()); | 947 base::Time()); |
947 cookie_remover_->AddObserver(this); | 948 cookie_remover_->AddObserver(this); |
948 cookie_remover_->Remove(BrowsingDataRemover::REMOVE_SITE_DATA); | 949 cookie_remover_->Remove(BrowsingDataRemover::REMOVE_SITE_DATA); |
949 } | 950 } |
950 | 951 |
951 } // namespace chromeos | 952 } // namespace chromeos |
OLD | NEW |