| 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" |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 void NetworkStateInformer::SendStateToObservers(const std::string& reason) { | 208 void NetworkStateInformer::SendStateToObservers(const std::string& reason) { |
| 209 for (base::hash_set<std::string>::iterator it = observers_.begin(); | 209 for (base::hash_set<std::string>::iterator it = observers_.begin(); |
| 210 it != observers_.end(); ++it) { | 210 it != observers_.end(); ++it) { |
| 211 SendState(*it, reason); | 211 SendState(*it, reason); |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 | 214 |
| 215 // SigninScreenHandler implementation ------------------------------------------ | 215 // SigninScreenHandler implementation ------------------------------------------ |
| 216 | 216 |
| 217 SigninScreenHandler::SigninScreenHandler() | 217 SigninScreenHandler::SigninScreenHandler() |
| 218 : delegate_(WebUILoginDisplay::GetInstance()), | 218 : delegate_(NULL), |
| 219 show_on_init_(false), | 219 show_on_init_(false), |
| 220 oobe_ui_(false), | 220 oobe_ui_(false), |
| 221 dns_cleared_(false), | 221 dns_cleared_(false), |
| 222 dns_clear_task_running_(false), | 222 dns_clear_task_running_(false), |
| 223 cookies_cleared_(false), | 223 cookies_cleared_(false), |
| 224 extension_driven_( | 224 extension_driven_( |
| 225 CommandLine::ForCurrentProcess()->HasSwitch( | 225 CommandLine::ForCurrentProcess()->HasSwitch( |
| 226 switches::kWebUILogin)), | 226 switches::kWebUILogin)), |
| 227 cookie_remover_(NULL), | 227 cookie_remover_(NULL), |
| 228 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 228 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
| 229 key_event_listener_(NULL) { | 229 key_event_listener_(NULL) { |
| 230 delegate_->SetWebUIHandler(this); | |
| 231 } | 230 } |
| 232 | 231 |
| 233 SigninScreenHandler::~SigninScreenHandler() { | 232 SigninScreenHandler::~SigninScreenHandler() { |
| 234 weak_factory_.InvalidateWeakPtrs(); | 233 weak_factory_.InvalidateWeakPtrs(); |
| 235 if (cookie_remover_) | 234 if (cookie_remover_) |
| 236 cookie_remover_->RemoveObserver(this); | 235 cookie_remover_->RemoveObserver(this); |
| 237 if (key_event_listener_) | 236 if (key_event_listener_) |
| 238 key_event_listener_->RemoveCapsLockObserver(this); | 237 key_event_listener_->RemoveCapsLockObserver(this); |
| 239 } | 238 } |
| 240 | 239 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 // figure out how to make it fast enough. | 302 // figure out how to make it fast enough. |
| 304 SendUserList(false); | 303 SendUserList(false); |
| 305 | 304 |
| 306 // Reset Caps Lock state when login screen is shown. | 305 // Reset Caps Lock state when login screen is shown. |
| 307 input_method::XKeyboard::SetCapsLockEnabled(false); | 306 input_method::XKeyboard::SetCapsLockEnabled(false); |
| 308 | 307 |
| 309 ShowScreen(kAccountPickerScreen, NULL); | 308 ShowScreen(kAccountPickerScreen, NULL); |
| 310 } | 309 } |
| 311 } | 310 } |
| 312 | 311 |
| 312 void SigninScreenHandler::SetDelegate(SigninScreenHandlerDelegate* delegate) { |
| 313 delegate_ = delegate; |
| 314 DCHECK(delegate_); |
| 315 delegate_->SetWebUIHandler(this); |
| 316 } |
| 317 |
| 313 // SigninScreenHandler, private: ----------------------------------------------- | 318 // SigninScreenHandler, private: ----------------------------------------------- |
| 314 | 319 |
| 315 void SigninScreenHandler::Initialize() { | 320 void SigninScreenHandler::Initialize() { |
| 316 // Register for Caps Lock state change notifications; | 321 // Register for Caps Lock state change notifications; |
| 317 key_event_listener_ = SystemKeyEventListener::GetInstance(); | 322 key_event_listener_ = SystemKeyEventListener::GetInstance(); |
| 318 if (key_event_listener_) | 323 if (key_event_listener_) |
| 319 key_event_listener_->AddCapsLockObserver(this); | 324 key_event_listener_->AddCapsLockObserver(this); |
| 320 | 325 |
| 321 if (show_on_init_) { | 326 if (show_on_init_) { |
| 322 show_on_init_ = false; | 327 show_on_init_ = false; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 } | 546 } |
| 542 | 547 |
| 543 void SigninScreenHandler::HandleLaunchHelpApp(const base::ListValue* args) { | 548 void SigninScreenHandler::HandleLaunchHelpApp(const base::ListValue* args) { |
| 544 double help_topic_id; // Javascript number is passed back as double. | 549 double help_topic_id; // Javascript number is passed back as double. |
| 545 if (!args->GetDouble(0, &help_topic_id)) { | 550 if (!args->GetDouble(0, &help_topic_id)) { |
| 546 NOTREACHED(); | 551 NOTREACHED(); |
| 547 return; | 552 return; |
| 548 } | 553 } |
| 549 | 554 |
| 550 if (!help_app_.get()) | 555 if (!help_app_.get()) |
| 551 help_app_ = new HelpAppLauncher( | 556 help_app_ = new HelpAppLauncher(GetNativeWindow()); |
| 552 WebUILoginDisplay::GetLoginWindow()->GetNativeWindow()); | |
| 553 help_app_->ShowHelpTopic( | 557 help_app_->ShowHelpTopic( |
| 554 static_cast<HelpAppLauncher::HelpTopic>(help_topic_id)); | 558 static_cast<HelpAppLauncher::HelpTopic>(help_topic_id)); |
| 555 } | 559 } |
| 556 | 560 |
| 557 void SigninScreenHandler::SendUserList(bool animated) { | 561 void SigninScreenHandler::SendUserList(bool animated) { |
| 558 bool show_guest = WebUILoginDisplay::GetInstance()->show_guest(); | 562 bool show_guest = delegate_->IsShowGuest(); |
| 559 | 563 |
| 560 size_t max_non_owner_users = show_guest ? kMaxUsers - 2 : kMaxUsers - 1; | 564 size_t max_non_owner_users = show_guest ? kMaxUsers - 2 : kMaxUsers - 1; |
| 561 size_t non_owner_count = 0; | 565 size_t non_owner_count = 0; |
| 562 | 566 |
| 563 ListValue users_list; | 567 ListValue users_list; |
| 564 UserVector users = WebUILoginDisplay::GetInstance()->users(); | 568 UserVector users = delegate_->GetUsers(); |
| 565 | 569 |
| 566 bool single_user = users.size() == 1; | 570 bool single_user = users.size() == 1; |
| 567 for (UserVector::const_iterator it = users.begin(); | 571 for (UserVector::const_iterator it = users.begin(); |
| 568 it != users.end(); ++it) { | 572 it != users.end(); ++it) { |
| 569 const std::string& email = it->email(); | 573 const std::string& email = it->email(); |
| 570 bool is_owner = email == UserCrosSettingsProvider::cached_owner(); | 574 bool is_owner = email == UserCrosSettingsProvider::cached_owner(); |
| 571 | 575 |
| 572 if (non_owner_count < max_non_owner_users || is_owner) { | 576 if (non_owner_count < max_non_owner_users || is_owner) { |
| 573 DictionaryValue* user_dict = new DictionaryValue(); | 577 DictionaryValue* user_dict = new DictionaryValue(); |
| 574 user_dict->SetString(kKeyName, it->GetDisplayName()); | 578 user_dict->SetString(kKeyName, it->GetDisplayName()); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 686 | 690 |
| 687 cookie_remover_ = new BrowsingDataRemover( | 691 cookie_remover_ = new BrowsingDataRemover( |
| 688 Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context()), | 692 Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context()), |
| 689 BrowsingDataRemover::EVERYTHING, | 693 BrowsingDataRemover::EVERYTHING, |
| 690 base::Time()); | 694 base::Time()); |
| 691 cookie_remover_->AddObserver(this); | 695 cookie_remover_->AddObserver(this); |
| 692 cookie_remover_->Remove(BrowsingDataRemover::REMOVE_SITE_DATA); | 696 cookie_remover_->Remove(BrowsingDataRemover::REMOVE_SITE_DATA); |
| 693 } | 697 } |
| 694 | 698 |
| 695 } // namespace chromeos | 699 } // namespace chromeos |
| OLD | NEW |