| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 // figure out how to make it fast enough. | 300 // figure out how to make it fast enough. |
| 302 SendUserList(false); | 301 SendUserList(false); |
| 303 | 302 |
| 304 // Reset Caps Lock state when login screen is shown. | 303 // Reset Caps Lock state when login screen is shown. |
| 305 input_method::XKeyboard::SetCapsLockEnabled(false); | 304 input_method::XKeyboard::SetCapsLockEnabled(false); |
| 306 | 305 |
| 307 ShowScreen(kAccountPickerScreen, NULL); | 306 ShowScreen(kAccountPickerScreen, NULL); |
| 308 } | 307 } |
| 309 } | 308 } |
| 310 | 309 |
| 310 void SigninScreenHandler::SetDelegate(SigninScreenHandlerDelegate* delegate) { |
| 311 delegate_ = delegate; |
| 312 DCHECK(delegate_); |
| 313 delegate_->SetWebUIHandler(this); |
| 314 } |
| 315 |
| 311 // SigninScreenHandler, private: ----------------------------------------------- | 316 // SigninScreenHandler, private: ----------------------------------------------- |
| 312 | 317 |
| 313 void SigninScreenHandler::Initialize() { | 318 void SigninScreenHandler::Initialize() { |
| 314 // Register for Caps Lock state change notifications; | 319 // Register for Caps Lock state change notifications; |
| 315 key_event_listener_ = SystemKeyEventListener::GetInstance(); | 320 key_event_listener_ = SystemKeyEventListener::GetInstance(); |
| 316 if (key_event_listener_) | 321 if (key_event_listener_) |
| 317 key_event_listener_->AddCapsLockObserver(this); | 322 key_event_listener_->AddCapsLockObserver(this); |
| 318 | 323 |
| 319 if (show_on_init_) { | 324 if (show_on_init_) { |
| 320 show_on_init_ = false; | 325 show_on_init_ = false; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 } | 544 } |
| 540 | 545 |
| 541 void SigninScreenHandler::HandleLaunchHelpApp(const base::ListValue* args) { | 546 void SigninScreenHandler::HandleLaunchHelpApp(const base::ListValue* args) { |
| 542 double help_topic_id; // Javascript number is passed back as double. | 547 double help_topic_id; // Javascript number is passed back as double. |
| 543 if (!args->GetDouble(0, &help_topic_id)) { | 548 if (!args->GetDouble(0, &help_topic_id)) { |
| 544 NOTREACHED(); | 549 NOTREACHED(); |
| 545 return; | 550 return; |
| 546 } | 551 } |
| 547 | 552 |
| 548 if (!help_app_.get()) | 553 if (!help_app_.get()) |
| 549 help_app_ = new HelpAppLauncher( | 554 help_app_ = new HelpAppLauncher(GetNativeWindow()); |
| 550 WebUILoginDisplay::GetLoginWindow()->GetNativeWindow()); | |
| 551 help_app_->ShowHelpTopic( | 555 help_app_->ShowHelpTopic( |
| 552 static_cast<HelpAppLauncher::HelpTopic>(help_topic_id)); | 556 static_cast<HelpAppLauncher::HelpTopic>(help_topic_id)); |
| 553 } | 557 } |
| 554 | 558 |
| 555 void SigninScreenHandler::SendUserList(bool animated) { | 559 void SigninScreenHandler::SendUserList(bool animated) { |
| 556 bool show_guest = WebUILoginDisplay::GetInstance()->show_guest(); | 560 bool show_guest = delegate_->IsShowGuest(); |
| 557 | 561 |
| 558 size_t max_non_owner_users = show_guest ? kMaxUsers - 2 : kMaxUsers - 1; | 562 size_t max_non_owner_users = show_guest ? kMaxUsers - 2 : kMaxUsers - 1; |
| 559 size_t non_owner_count = 0; | 563 size_t non_owner_count = 0; |
| 560 | 564 |
| 561 ListValue users_list; | 565 ListValue users_list; |
| 562 UserVector users = WebUILoginDisplay::GetInstance()->users(); | 566 UserVector users = delegate_->GetUsers(); |
| 563 | 567 |
| 564 bool single_user = users.size() == 1; | 568 bool single_user = users.size() == 1; |
| 565 for (UserVector::const_iterator it = users.begin(); | 569 for (UserVector::const_iterator it = users.begin(); |
| 566 it != users.end(); ++it) { | 570 it != users.end(); ++it) { |
| 567 const std::string& email = it->email(); | 571 const std::string& email = it->email(); |
| 568 bool is_owner = email == UserCrosSettingsProvider::cached_owner(); | 572 bool is_owner = email == UserCrosSettingsProvider::cached_owner(); |
| 569 | 573 |
| 570 if (non_owner_count < max_non_owner_users || is_owner) { | 574 if (non_owner_count < max_non_owner_users || is_owner) { |
| 571 DictionaryValue* user_dict = new DictionaryValue(); | 575 DictionaryValue* user_dict = new DictionaryValue(); |
| 572 user_dict->SetString(kKeyName, it->GetDisplayName()); | 576 user_dict->SetString(kKeyName, it->GetDisplayName()); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 | 688 |
| 685 cookie_remover_ = new BrowsingDataRemover( | 689 cookie_remover_ = new BrowsingDataRemover( |
| 686 Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context()), | 690 Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context()), |
| 687 BrowsingDataRemover::EVERYTHING, | 691 BrowsingDataRemover::EVERYTHING, |
| 688 base::Time()); | 692 base::Time()); |
| 689 cookie_remover_->AddObserver(this); | 693 cookie_remover_->AddObserver(this); |
| 690 cookie_remover_->Remove(BrowsingDataRemover::REMOVE_SITE_DATA); | 694 cookie_remover_->Remove(BrowsingDataRemover::REMOVE_SITE_DATA); |
| 691 } | 695 } |
| 692 | 696 |
| 693 } // namespace chromeos | 697 } // namespace chromeos |
| OLD | NEW |