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/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "base/task.h" | 12 #include "base/task.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/browser_shutdown.h" | 15 #include "chrome/browser/browser_shutdown.h" |
16 #include "chrome/browser/chromeos/cros_settings.h" | |
16 #include "chrome/browser/chromeos/cros/cros_library.h" | 17 #include "chrome/browser/chromeos/cros/cros_library.h" |
17 #include "chrome/browser/chromeos/cros/network_library.h" | 18 #include "chrome/browser/chromeos/cros/network_library.h" |
18 #include "chrome/browser/chromeos/cros/power_library.h" | 19 #include "chrome/browser/chromeos/cros/power_library.h" |
19 #include "chrome/browser/chromeos/input_method/xkeyboard.h" | 20 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
20 #include "chrome/browser/chromeos/login/user_manager.h" | 21 #include "chrome/browser/chromeos/login/user_manager.h" |
21 #include "chrome/browser/chromeos/login/webui_login_display.h" | 22 #include "chrome/browser/chromeos/login/webui_login_display.h" |
22 #include "chrome/browser/chromeos/user_cros_settings_provider.h" | |
23 #include "chrome/browser/io_thread.h" | 23 #include "chrome/browser/io_thread.h" |
24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/common/net/gaia/gaia_urls.h" | 27 #include "chrome/common/net/gaia/gaia_urls.h" |
28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
29 #include "content/browser/tab_contents/tab_contents.h" | 29 #include "content/browser/tab_contents/tab_contents.h" |
30 #include "content/common/notification_observer.h" | 30 #include "content/common/notification_observer.h" |
31 #include "content/common/notification_registrar.h" | 31 #include "content/common/notification_registrar.h" |
32 #include "content/common/notification_service.h" | 32 #include "content/common/notification_service.h" |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
421 | 421 |
422 DictionaryValue params; | 422 DictionaryValue params; |
423 params.SetString("startUrl", kGaiaExtStartPage); | 423 params.SetString("startUrl", kGaiaExtStartPage); |
424 params.SetString("email", email_); | 424 params.SetString("email", email_); |
425 email_.clear(); | 425 email_.clear(); |
426 | 426 |
427 const std::string app_locale = g_browser_process->GetApplicationLocale(); | 427 const std::string app_locale = g_browser_process->GetApplicationLocale(); |
428 if (!app_locale.empty()) | 428 if (!app_locale.empty()) |
429 params.SetString("hl", app_locale); | 429 params.SetString("hl", app_locale); |
430 | 430 |
431 params.SetBoolean("createAccount", | 431 // TODO(pastarmovj): Observe for changes of this variables to update the UI |
432 UserCrosSettingsProvider::cached_allow_new_user()); | 432 // properly when the policy has been fetched on sign-on screen. |
433 params.SetBoolean("guestSignin", | 433 bool allow_new_user; |
434 UserCrosSettingsProvider::cached_allow_guest()); | 434 CrosSettings::Get()->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
435 params.SetBoolean("createAccount", allow_new_user); | |
436 bool allow_guest; | |
437 CrosSettings::Get()->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | |
438 params.SetBoolean("guestSignin", allow_guest); | |
435 params.SetString("gaiaOrigin", GaiaUrls::GetInstance()->gaia_origin_url()); | 439 params.SetString("gaiaOrigin", GaiaUrls::GetInstance()->gaia_origin_url()); |
436 | 440 |
Mattias Nissler (ping if slow)
2011/10/13 13:41:06
remove extra blank line.
pastarmovj
2011/10/26 15:43:19
Done.
| |
441 | |
437 // Test automation data: | 442 // Test automation data: |
438 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 443 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
439 if (command_line->HasSwitch(switches::kAuthExtensionPath)) { | 444 if (command_line->HasSwitch(switches::kAuthExtensionPath)) { |
440 if (!test_user_.empty()) { | 445 if (!test_user_.empty()) { |
441 params.SetString("test_email", test_user_); | 446 params.SetString("test_email", test_user_); |
442 test_user_.clear(); | 447 test_user_.clear(); |
443 } | 448 } |
444 if (!test_pass_.empty()) { | 449 if (!test_pass_.empty()) { |
445 params.SetString("test_password", test_pass_); | 450 params.SetString("test_password", test_pass_); |
446 test_pass_.clear(); | 451 test_pass_.clear(); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 size_t max_non_owner_users = show_guest ? kMaxUsers - 2 : kMaxUsers - 1; | 551 size_t max_non_owner_users = show_guest ? kMaxUsers - 2 : kMaxUsers - 1; |
547 size_t non_owner_count = 0; | 552 size_t non_owner_count = 0; |
548 | 553 |
549 ListValue users_list; | 554 ListValue users_list; |
550 UserVector users = WebUILoginDisplay::GetInstance()->users(); | 555 UserVector users = WebUILoginDisplay::GetInstance()->users(); |
551 | 556 |
552 bool single_user = users.size() == 1; | 557 bool single_user = users.size() == 1; |
553 for (UserVector::const_iterator it = users.begin(); | 558 for (UserVector::const_iterator it = users.begin(); |
554 it != users.end(); ++it) { | 559 it != users.end(); ++it) { |
555 const std::string& email = it->email(); | 560 const std::string& email = it->email(); |
556 bool is_owner = email == UserCrosSettingsProvider::cached_owner(); | 561 std::string owner; |
562 chromeos::CrosSettings::Get()->GetString(chromeos::kDeviceOwner, &owner); | |
563 bool is_owner = (email == owner); | |
557 | 564 |
558 if (non_owner_count < max_non_owner_users || is_owner) { | 565 if (non_owner_count < max_non_owner_users || is_owner) { |
559 DictionaryValue* user_dict = new DictionaryValue(); | 566 DictionaryValue* user_dict = new DictionaryValue(); |
560 user_dict->SetString(kKeyName, it->GetDisplayName()); | 567 user_dict->SetString(kKeyName, it->GetDisplayName()); |
561 user_dict->SetString(kKeyEmailAddress, email); | 568 user_dict->SetString(kKeyEmailAddress, email); |
562 user_dict->SetInteger(kKeyOauthTokenStatus, it->oauth_token_status()); | 569 user_dict->SetInteger(kKeyOauthTokenStatus, it->oauth_token_status()); |
563 | 570 |
564 // Single user check here is necessary because owner info might not be | 571 // Single user check here is necessary because owner info might not be |
565 // available when running into login screen on first boot. | 572 // available when running into login screen on first boot. |
566 // See http://crosbug.com/12723 | 573 // See http://crosbug.com/12723 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
672 | 679 |
673 cookie_remover_ = new BrowsingDataRemover( | 680 cookie_remover_ = new BrowsingDataRemover( |
674 Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context()), | 681 Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context()), |
675 BrowsingDataRemover::EVERYTHING, | 682 BrowsingDataRemover::EVERYTHING, |
676 base::Time()); | 683 base::Time()); |
677 cookie_remover_->AddObserver(this); | 684 cookie_remover_->AddObserver(this); |
678 cookie_remover_->Remove(BrowsingDataRemover::REMOVE_SITE_DATA); | 685 cookie_remover_->Remove(BrowsingDataRemover::REMOVE_SITE_DATA); |
679 } | 686 } |
680 | 687 |
681 } // namespace chromeos | 688 } // namespace chromeos |
OLD | NEW |