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/chromeos/login/login_utils.h" | 5 #include "chrome/browser/chromeos/login/login_utils.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/chromeos/chromeos_version.h" | 10 #include "base/chromeos/chromeos_version.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "base/task_runner_util.h" | 25 #include "base/task_runner_util.h" |
26 #include "base/threading/worker_pool.h" | 26 #include "base/threading/worker_pool.h" |
27 #include "base/time.h" | 27 #include "base/time.h" |
28 #include "base/utf_string_conversions.h" | 28 #include "base/utf_string_conversions.h" |
29 #include "chrome/browser/about_flags.h" | 29 #include "chrome/browser/about_flags.h" |
30 #include "chrome/browser/browser_process.h" | 30 #include "chrome/browser/browser_process.h" |
31 #include "chrome/browser/browser_shutdown.h" | 31 #include "chrome/browser/browser_shutdown.h" |
32 #include "chrome/browser/chromeos/boot_times_loader.h" | 32 #include "chrome/browser/chromeos/boot_times_loader.h" |
33 #include "chrome/browser/chromeos/cros/cros_library.h" | 33 #include "chrome/browser/chromeos/cros/cros_library.h" |
34 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 34 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
35 #include "chrome/browser/chromeos/cros/network_library.h" | |
36 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" | 35 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" |
37 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 36 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
38 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 37 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
39 #include "chrome/browser/chromeos/login/chrome_restart_request.h" | 38 #include "chrome/browser/chromeos/login/chrome_restart_request.h" |
40 #include "chrome/browser/chromeos/login/language_switch_menu.h" | 39 #include "chrome/browser/chromeos/login/language_switch_menu.h" |
41 #include "chrome/browser/chromeos/login/login_display_host.h" | 40 #include "chrome/browser/chromeos/login/login_display_host.h" |
42 #include "chrome/browser/chromeos/login/oauth_login_manager.h" | 41 #include "chrome/browser/chromeos/login/oauth_login_manager.h" |
43 #include "chrome/browser/chromeos/login/parallel_authenticator.h" | 42 #include "chrome/browser/chromeos/login/parallel_authenticator.h" |
44 #include "chrome/browser/chromeos/login/profile_auth_data.h" | 43 #include "chrome/browser/chromeos/login/profile_auth_data.h" |
45 #include "chrome/browser/chromeos/login/screen_locker.h" | 44 #include "chrome/browser/chromeos/login/screen_locker.h" |
46 #include "chrome/browser/chromeos/login/user_manager.h" | 45 #include "chrome/browser/chromeos/login/user_manager.h" |
47 #include "chrome/browser/chromeos/net/connectivity_state_helper.h" | 46 #include "chrome/browser/chromeos/net/connectivity_state_helper.h" |
| 47 #include "chrome/browser/chromeos/net/connectivity_state_helper_observer.h" |
48 #include "chrome/browser/chromeos/policy/network_configuration_updater.h" | 48 #include "chrome/browser/chromeos/policy/network_configuration_updater.h" |
49 #include "chrome/browser/chromeos/settings/cros_settings.h" | 49 #include "chrome/browser/chromeos/settings/cros_settings.h" |
50 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 50 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
51 #include "chrome/browser/extensions/extension_service.h" | 51 #include "chrome/browser/extensions/extension_service.h" |
52 #include "chrome/browser/first_run/first_run.h" | 52 #include "chrome/browser/first_run/first_run.h" |
53 #include "chrome/browser/google/google_util_chromeos.h" | 53 #include "chrome/browser/google/google_util_chromeos.h" |
54 #include "chrome/browser/managed_mode/managed_mode.h" | 54 #include "chrome/browser/managed_mode/managed_mode.h" |
55 #include "chrome/browser/net/chrome_url_request_context.h" | 55 #include "chrome/browser/net/chrome_url_request_context.h" |
56 #include "chrome/browser/net/preconnect.h" | 56 #include "chrome/browser/net/preconnect.h" |
57 #include "chrome/browser/policy/browser_policy_connector.h" | 57 #include "chrome/browser/policy/browser_policy_connector.h" |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 } else { | 712 } else { |
713 // TODO(nkostylev): Fix this hack by improving Authenticator dependencies. | 713 // TODO(nkostylev): Fix this hack by improving Authenticator dependencies. |
714 authenticator_->SetConsumer(consumer); | 714 authenticator_->SetConsumer(consumer); |
715 } | 715 } |
716 return authenticator_; | 716 return authenticator_; |
717 } | 717 } |
718 | 718 |
719 // We use a special class for this so that it can be safely leaked if we | 719 // We use a special class for this so that it can be safely leaked if we |
720 // never connect. At shutdown the order is not well defined, and it's possible | 720 // never connect. At shutdown the order is not well defined, and it's possible |
721 // for the infrastructure needed to unregister might be unstable and crash. | 721 // for the infrastructure needed to unregister might be unstable and crash. |
722 class WarmingObserver : public NetworkLibrary::NetworkManagerObserver, | 722 class WarmingObserver : public ConnectivityStateHelperObserver, |
723 public content::NotificationObserver { | 723 public content::NotificationObserver { |
724 public: | 724 public: |
725 WarmingObserver() | 725 WarmingObserver() |
726 : url_request_context_getter_(NULL) { | 726 : url_request_context_getter_(NULL) { |
727 NetworkLibrary* netlib = CrosLibrary::Get()->GetNetworkLibrary(); | 727 ConnectivityStateHelper::Get()->AddNetworkManagerObserver(this); |
728 netlib->AddNetworkManagerObserver(this); | |
729 // During tests, the browser_process may not be initialized yet causing | 728 // During tests, the browser_process may not be initialized yet causing |
730 // this to fail. | 729 // this to fail. |
731 if (g_browser_process) { | 730 if (g_browser_process) { |
732 registrar_.Add( | 731 registrar_.Add( |
733 this, | 732 this, |
734 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, | 733 chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED, |
735 content::Source<Profile>(ProfileManager::GetDefaultProfile())); | 734 content::Source<Profile>(ProfileManager::GetDefaultProfile())); |
736 } | 735 } |
737 } | 736 } |
738 | 737 |
739 virtual ~WarmingObserver() {} | 738 virtual ~WarmingObserver() {} |
740 | 739 |
741 // If we're now connected, prewarm the auth url. | 740 // If we're now connected, prewarm the auth url. |
742 virtual void OnNetworkManagerChanged(NetworkLibrary* netlib) OVERRIDE { | 741 virtual void NetworkManagerChanged() OVERRIDE { |
743 if (netlib->Connected()) { | 742 ConnectivityStateHelper* csh = ConnectivityStateHelper::Get(); |
| 743 if (csh->IsConnected()) { |
744 const int kConnectionsNeeded = 1; | 744 const int kConnectionsNeeded = 1; |
745 chrome_browser_net::PreconnectOnUIThread( | 745 chrome_browser_net::PreconnectOnUIThread( |
746 GURL(GaiaUrls::GetInstance()->client_login_url()), | 746 GURL(GaiaUrls::GetInstance()->client_login_url()), |
747 chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, | 747 chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, |
748 kConnectionsNeeded, | 748 kConnectionsNeeded, |
749 url_request_context_getter_); | 749 url_request_context_getter_); |
750 netlib->RemoveNetworkManagerObserver(this); | 750 csh->RemoveNetworkManagerObserver(this); |
751 delete this; | 751 delete this; |
752 } | 752 } |
753 } | 753 } |
754 | 754 |
755 // content::NotificationObserver overrides. | 755 // content::NotificationObserver overrides. |
756 virtual void Observe(int type, | 756 virtual void Observe(int type, |
757 const content::NotificationSource& source, | 757 const content::NotificationSource& source, |
758 const content::NotificationDetails& details) OVERRIDE { | 758 const content::NotificationDetails& details) OVERRIDE { |
759 switch (type) { | 759 switch (type) { |
760 case chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED: { | 760 case chrome::NOTIFICATION_PROFILE_URL_REQUEST_CONTEXT_GETTER_INITIALIZED: { |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 bool LoginUtils::IsWhitelisted(const std::string& username) { | 890 bool LoginUtils::IsWhitelisted(const std::string& username) { |
891 CrosSettings* cros_settings = CrosSettings::Get(); | 891 CrosSettings* cros_settings = CrosSettings::Get(); |
892 bool allow_new_user = false; | 892 bool allow_new_user = false; |
893 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 893 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
894 if (allow_new_user) | 894 if (allow_new_user) |
895 return true; | 895 return true; |
896 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); | 896 return cros_settings->FindEmailInList(kAccountsPrefUsers, username); |
897 } | 897 } |
898 | 898 |
899 } // namespace chromeos | 899 } // namespace chromeos |
OLD | NEW |