Chromium Code Reviews| 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/existing_user_controller.h" | 5 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 #include "chrome/browser/chromeos/customization_document.h" | 24 #include "chrome/browser/chromeos/customization_document.h" |
| 25 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 25 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
| 26 #include "chrome/browser/chromeos/dbus/session_manager_client.h" | 26 #include "chrome/browser/chromeos/dbus/session_manager_client.h" |
| 27 #include "chrome/browser/chromeos/login/helper.h" | 27 #include "chrome/browser/chromeos/login/helper.h" |
| 28 #include "chrome/browser/chromeos/login/login_display_host.h" | 28 #include "chrome/browser/chromeos/login/login_display_host.h" |
| 29 #include "chrome/browser/chromeos/login/login_utils.h" | 29 #include "chrome/browser/chromeos/login/login_utils.h" |
| 30 #include "chrome/browser/chromeos/login/user_manager.h" | 30 #include "chrome/browser/chromeos/login/user_manager.h" |
| 31 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" | 31 #include "chrome/browser/chromeos/login/wizard_accessibility_helper.h" |
| 32 #include "chrome/browser/chromeos/login/wizard_controller.h" | 32 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 33 #include "chrome/browser/google/google_util.h" | 33 #include "chrome/browser/google/google_util.h" |
| 34 #include "chrome/browser/policy/browser_policy_connector.h" | |
| 34 #include "chrome/browser/prefs/pref_service.h" | 35 #include "chrome/browser/prefs/pref_service.h" |
| 35 #include "chrome/browser/prefs/session_startup_pref.h" | 36 #include "chrome/browser/prefs/session_startup_pref.h" |
| 36 #include "chrome/browser/profiles/profile_manager.h" | 37 #include "chrome/browser/profiles/profile_manager.h" |
| 37 #include "chrome/browser/ui/dialog_style.h" | 38 #include "chrome/browser/ui/dialog_style.h" |
| 38 #include "chrome/browser/ui/views/window.h" | 39 #include "chrome/browser/ui/views/window.h" |
| 39 #include "chrome/common/chrome_notification_types.h" | 40 #include "chrome/common/chrome_notification_types.h" |
| 40 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
| 41 #include "chrome/common/net/gaia/google_service_auth_error.h" | 42 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 42 #include "chrome/common/pref_names.h" | 43 #include "chrome/common/pref_names.h" |
| 44 #include "content/public/browser/browser_thread.h" | |
| 43 #include "content/public/browser/notification_service.h" | 45 #include "content/public/browser/notification_service.h" |
| 44 #include "content/public/browser/notification_types.h" | 46 #include "content/public/browser/notification_types.h" |
| 45 #include "grit/generated_resources.h" | 47 #include "grit/generated_resources.h" |
| 48 #include "net/http/http_auth_cache.h" | |
| 49 #include "net/http/http_network_session.h" | |
| 50 #include "net/http/http_transaction_factory.h" | |
| 51 #include "net/url_request/url_request_context.h" | |
| 52 #include "net/url_request/url_request_context_getter.h" | |
| 46 #include "ui/base/l10n/l10n_util.h" | 53 #include "ui/base/l10n/l10n_util.h" |
| 47 #include "ui/views/widget/widget.h" | 54 #include "ui/views/widget/widget.h" |
| 48 | 55 |
| 49 namespace chromeos { | 56 namespace chromeos { |
| 50 | 57 |
| 51 namespace { | 58 namespace { |
| 52 | 59 |
| 53 // Url for setting up sync authentication. | 60 // Url for setting up sync authentication. |
| 54 const char kSettingsSyncLoginURL[] = "chrome://settings/personal"; | 61 const char kSettingsSyncLoginURL[] = "chrome://settings/personal"; |
| 55 | 62 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 66 "https://www.google.com/accounts/NewAccount?service=mail"; | 73 "https://www.google.com/accounts/NewAccount?service=mail"; |
| 67 | 74 |
| 68 // ChromeVox tutorial URL. | 75 // ChromeVox tutorial URL. |
| 69 const char kChromeVoxTutorialURL[] = | 76 const char kChromeVoxTutorialURL[] = |
| 70 "http://google-axs-chrome.googlecode.com/" | 77 "http://google-axs-chrome.googlecode.com/" |
| 71 "svn/trunk/chromevox_tutorial/interactive_tutorial_start.html"; | 78 "svn/trunk/chromevox_tutorial/interactive_tutorial_start.html"; |
| 72 | 79 |
| 73 // Landing URL when launching Guest mode to fix captive portal. | 80 // Landing URL when launching Guest mode to fix captive portal. |
| 74 const char kCaptivePortalLaunchURL[] = "http://www.google.com/"; | 81 const char kCaptivePortalLaunchURL[] = "http://www.google.com/"; |
| 75 | 82 |
| 83 // Makes a call to the policy subsystem to reload the policy when we detect | |
| 84 // authentication change. | |
| 85 void RefreshPoliciesOnUIThread() { | |
| 86 if (g_browser_process->browser_policy_connector()) | |
| 87 g_browser_process->browser_policy_connector()->RefreshPolicies(); | |
| 88 } | |
| 89 | |
| 90 // Copies any authentication details that were entered in the login profile in | |
| 91 // the mail profile to make sure all subsystems of Chrome can access the network | |
| 92 // with the provided authentication which are possibly for a proxy server. | |
| 93 void TransferContextAuthenticationsOnIOThread( | |
| 94 net::URLRequestContextGetter* browser_process_context_getter, | |
| 95 Profile* default_profile) { | |
| 96 DCHECK(browser_process_context_getter); | |
| 97 DCHECK(default_profile); | |
| 98 net::HttpAuthCache* new_cache = | |
| 99 browser_process_context_getter->GetURLRequestContext()-> | |
| 100 http_transaction_factory()->GetSession()->http_auth_cache(); | |
| 101 new_cache->UpdateAllFrom( | |
| 102 *default_profile->GetRequestContext()->GetURLRequestContext()-> | |
| 103 http_transaction_factory()->GetSession()->http_auth_cache()); | |
| 104 LOG(INFO) << "Main request context populated with authentication data."; | |
|
Ivan Korotkov
2012/01/12 19:37:16
Should it really be an INFO log? Probably more app
pastarmovj
2012/01/13 10:15:47
Yes you are right I only wanted at least one piece
| |
| 105 // At last tell the policy subsystem to refresh now as it might have been | |
| 106 // stuck until now too. | |
| 107 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | |
| 108 base::Bind(&RefreshPoliciesOnUIThread)); | |
| 109 } | |
| 110 | |
| 76 } // namespace | 111 } // namespace |
| 77 | 112 |
| 78 // static | 113 // static |
| 79 ExistingUserController* ExistingUserController::current_controller_ = NULL; | 114 ExistingUserController* ExistingUserController::current_controller_ = NULL; |
| 80 | 115 |
| 81 //////////////////////////////////////////////////////////////////////////////// | 116 //////////////////////////////////////////////////////////////////////////////// |
| 82 // ExistingUserController, public: | 117 // ExistingUserController, public: |
| 83 | 118 |
| 84 ExistingUserController::ExistingUserController(LoginDisplayHost* host) | 119 ExistingUserController::ExistingUserController(LoginDisplayHost* host) |
| 85 : login_status_consumer_(NULL), | 120 : login_status_consumer_(NULL), |
| 86 host_(host), | 121 host_(host), |
| 87 login_display_(host_->CreateLoginDisplay(this)), | 122 login_display_(host_->CreateLoginDisplay(this)), |
| 88 num_login_attempts_(0), | 123 num_login_attempts_(0), |
| 89 cros_settings_(CrosSettings::Get()), | 124 cros_settings_(CrosSettings::Get()), |
| 90 weak_factory_(this), | 125 weak_factory_(this), |
| 91 is_owner_login_(false), | 126 is_owner_login_(false), |
| 92 do_auto_enrollment_(false) { | 127 do_auto_enrollment_(false) { |
| 93 DCHECK(current_controller_ == NULL); | 128 DCHECK(current_controller_ == NULL); |
| 94 current_controller_ = this; | 129 current_controller_ = this; |
| 95 | 130 |
| 96 registrar_.Add(this, | 131 registrar_.Add(this, |
| 97 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, | 132 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, |
| 98 content::NotificationService::AllSources()); | 133 content::NotificationService::AllSources()); |
| 134 registrar_.Add(this, | |
| 135 chrome::NOTIFICATION_AUTH_SUPPLIED, | |
| 136 content::NotificationService::AllSources()); | |
| 99 cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this); | 137 cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this); |
| 100 cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this); | 138 cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this); |
| 101 cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this); | 139 cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this); |
| 102 cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this); | 140 cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this); |
| 103 } | 141 } |
| 104 | 142 |
| 105 void ExistingUserController::Init(const UserList& users) { | 143 void ExistingUserController::Init(const UserList& users) { |
| 106 UpdateLoginDisplay(users, true); | 144 UpdateLoginDisplay(users, true); |
| 107 | 145 |
| 108 LoginUtils::Get()->PrewarmAuthentication(); | 146 LoginUtils::Get()->PrewarmAuthentication(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 void ExistingUserController::Observe( | 196 void ExistingUserController::Observe( |
| 159 int type, | 197 int type, |
| 160 const content::NotificationSource& source, | 198 const content::NotificationSource& source, |
| 161 const content::NotificationDetails& details) { | 199 const content::NotificationDetails& details) { |
| 162 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) { | 200 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) { |
| 163 // Signed settings changed notify views and update them. | 201 // Signed settings changed notify views and update them. |
| 164 const chromeos::UserList& users = chromeos::UserManager::Get()->GetUsers(); | 202 const chromeos::UserList& users = chromeos::UserManager::Get()->GetUsers(); |
| 165 UpdateLoginDisplay(users, false); | 203 UpdateLoginDisplay(users, false); |
| 166 return; | 204 return; |
| 167 } | 205 } |
| 206 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) { | |
| 207 // Possibly the user has authenticated against a proxy server and we might | |
| 208 // need the credentials for enrollment and other system requests from the | |
| 209 // main |g_browser_process| request context (see bug | |
| 210 // http://crosbug.com/24861). So we transfer any credentials to the global | |
| 211 // request context here. | |
| 212 // The issue we have here is that the NOTIFICATION_AUTH_SUPPLIED is sent | |
| 213 // just after the UI is closed but before the new credentials were stored | |
| 214 // in the profile. Therefore we have to give it some time to make sure it | |
| 215 // has been updated before we copy it. | |
| 216 LOG(INFO) << "Authentication was entered manually, possbly for proxy-auth."; | |
| 217 net::URLRequestContextGetter* browser_process_context_getter = | |
| 218 g_browser_process->system_request_context(); | |
| 219 Profile* default_profile = ProfileManager::GetDefaultProfile(); | |
| 220 content::BrowserThread::PostDelayedTask( | |
| 221 content::BrowserThread::IO, FROM_HERE, | |
| 222 base::Bind(&TransferContextAuthenticationsOnIOThread, | |
| 223 base::Unretained(browser_process_context_getter), | |
| 224 base::Unretained(default_profile)), | |
|
Ivan Korotkov
2012/01/12 19:37:16
I've been told that it's deeply wrong to pass Prof
pastarmovj
2012/01/13 10:15:47
Good advice, thanks! Done as suggested and now I p
| |
| 225 2000); | |
|
Ivan Korotkov
2012/01/12 19:37:16
Define a const for 2000, please :)
pastarmovj
2012/01/13 10:15:47
Done.
| |
| 226 | |
| 227 } | |
| 168 if (type != chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED) | 228 if (type != chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED) |
| 169 return; | 229 return; |
| 170 login_display_->OnUserImageChanged(*content::Details<User>(details).ptr()); | 230 login_display_->OnUserImageChanged(*content::Details<User>(details).ptr()); |
| 171 } | 231 } |
| 172 | 232 |
| 173 //////////////////////////////////////////////////////////////////////////////// | 233 //////////////////////////////////////////////////////////////////////////////// |
| 174 // ExistingUserController, private: | 234 // ExistingUserController, private: |
| 175 | 235 |
| 176 ExistingUserController::~ExistingUserController() { | 236 ExistingUserController::~ExistingUserController() { |
| 177 LoginUtils::Get()->DelegateDeleted(this); | 237 LoginUtils::Get()->DelegateDeleted(this); |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 673 std::string owner; | 733 std::string owner; |
| 674 cros_settings_->GetString(kDeviceOwner, &owner); | 734 cros_settings_->GetString(kDeviceOwner, &owner); |
| 675 cryptohomed->AsyncSetOwnerUser(owner, NULL); | 735 cryptohomed->AsyncSetOwnerUser(owner, NULL); |
| 676 | 736 |
| 677 // Do not invoke AsyncDoAutomaticFreeDiskSpaceControl(NULL) here | 737 // Do not invoke AsyncDoAutomaticFreeDiskSpaceControl(NULL) here |
| 678 // so it does not delay the following mount. Cleanup will be | 738 // so it does not delay the following mount. Cleanup will be |
| 679 // started in Cryptohomed by timer. | 739 // started in Cryptohomed by timer. |
| 680 } | 740 } |
| 681 | 741 |
| 682 } // namespace chromeos | 742 } // namespace chromeos |
| OLD | NEW |