Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: chrome/browser/chromeos/login/existing_user_controller.cc

Issue 9186039: Make the login WebUI listen NOTIFICATION_AUTH_SUPPLIED and update the system request context. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed variable. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 // Delay for transferring the auth cache to the system profile.
84 const long int kAuthCacheTransferDelayMs = 2000;
85
86 // Makes a call to the policy subsystem to reload the policy when we detect
87 // authentication change.
88 void RefreshPoliciesOnUIThread() {
89 if (g_browser_process->browser_policy_connector())
90 g_browser_process->browser_policy_connector()->RefreshPolicies();
91 }
92
93 // Copies any authentication details that were entered in the login profile in
94 // the mail profile to make sure all subsystems of Chrome can access the network
95 // with the provided authentication which are possibly for a proxy server.
96 void TransferContextAuthenticationsOnIOThread(
97 net::URLRequestContextGetter* default_profile_context_getter,
98 net::URLRequestContextGetter* browser_process_context_getter) {
99 net::HttpAuthCache* new_cache =
100 browser_process_context_getter->GetURLRequestContext()->
101 http_transaction_factory()->GetSession()->http_auth_cache();
102 net::HttpAuthCache* old_cache =
103 default_profile_context_getter->GetURLRequestContext()->
104 http_transaction_factory()->GetSession()->http_auth_cache();
105 new_cache->UpdateAllFrom(*old_cache);
106 VLOG(1) << "Main request context populated with authentication data.";
107 // Last but not least tell the policy subsystem to refresh now as it might
108 // have been stuck until now too.
109 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
110 base::Bind(&RefreshPoliciesOnUIThread));
111 }
112
76 } // namespace 113 } // namespace
77 114
78 // static 115 // static
79 ExistingUserController* ExistingUserController::current_controller_ = NULL; 116 ExistingUserController* ExistingUserController::current_controller_ = NULL;
80 117
81 //////////////////////////////////////////////////////////////////////////////// 118 ////////////////////////////////////////////////////////////////////////////////
82 // ExistingUserController, public: 119 // ExistingUserController, public:
83 120
84 ExistingUserController::ExistingUserController(LoginDisplayHost* host) 121 ExistingUserController::ExistingUserController(LoginDisplayHost* host)
85 : login_status_consumer_(NULL), 122 : login_status_consumer_(NULL),
86 host_(host), 123 host_(host),
87 login_display_(host_->CreateLoginDisplay(this)), 124 login_display_(host_->CreateLoginDisplay(this)),
88 num_login_attempts_(0), 125 num_login_attempts_(0),
89 cros_settings_(CrosSettings::Get()), 126 cros_settings_(CrosSettings::Get()),
90 weak_factory_(this), 127 weak_factory_(this),
91 is_owner_login_(false), 128 is_owner_login_(false),
92 do_auto_enrollment_(false) { 129 do_auto_enrollment_(false) {
93 DCHECK(current_controller_ == NULL); 130 DCHECK(current_controller_ == NULL);
94 current_controller_ = this; 131 current_controller_ = this;
95 132
96 registrar_.Add(this, 133 registrar_.Add(this,
97 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 134 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
98 content::NotificationService::AllSources()); 135 content::NotificationService::AllSources());
136 registrar_.Add(this,
137 chrome::NOTIFICATION_AUTH_SUPPLIED,
138 content::NotificationService::AllSources());
99 cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this); 139 cros_settings_->AddSettingsObserver(kAccountsPrefShowUserNamesOnSignIn, this);
100 cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this); 140 cros_settings_->AddSettingsObserver(kAccountsPrefAllowNewUser, this);
101 cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this); 141 cros_settings_->AddSettingsObserver(kAccountsPrefAllowGuest, this);
102 cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this); 142 cros_settings_->AddSettingsObserver(kAccountsPrefUsers, this);
103 } 143 }
104 144
105 void ExistingUserController::Init(const UserList& users) { 145 void ExistingUserController::Init(const UserList& users) {
106 UpdateLoginDisplay(users, true); 146 UpdateLoginDisplay(users, true);
107 147
108 LoginUtils::Get()->PrewarmAuthentication(); 148 LoginUtils::Get()->PrewarmAuthentication();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 void ExistingUserController::Observe( 198 void ExistingUserController::Observe(
159 int type, 199 int type,
160 const content::NotificationSource& source, 200 const content::NotificationSource& source,
161 const content::NotificationDetails& details) { 201 const content::NotificationDetails& details) {
162 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) { 202 if (type == chrome::NOTIFICATION_SYSTEM_SETTING_CHANGED) {
163 // Signed settings changed notify views and update them. 203 // Signed settings changed notify views and update them.
164 const chromeos::UserList& users = chromeos::UserManager::Get()->GetUsers(); 204 const chromeos::UserList& users = chromeos::UserManager::Get()->GetUsers();
165 UpdateLoginDisplay(users, false); 205 UpdateLoginDisplay(users, false);
166 return; 206 return;
167 } 207 }
208 if (type == chrome::NOTIFICATION_AUTH_SUPPLIED) {
209 // Possibly the user has authenticated against a proxy server and we might
210 // need the credentials for enrollment and other system requests from the
211 // main |g_browser_process| request context (see bug
212 // http://crosbug.com/24861). So we transfer any credentials to the global
213 // request context here.
214 // The issue we have here is that the NOTIFICATION_AUTH_SUPPLIED is sent
215 // just after the UI is closed but before the new credentials were stored
216 // in the profile. Therefore we have to give it some time to make sure it
217 // has been updated before we copy it.
218 LOG(INFO) << "Authentication was entered manually, possibly for proxyauth.";
219 scoped_refptr<net::URLRequestContextGetter> browser_process_context_getter =
220 g_browser_process->system_request_context();
221 Profile* default_profile = ProfileManager::GetDefaultProfile();
222 scoped_refptr<net::URLRequestContextGetter> default_profile_context_getter =
223 default_profile->GetRequestContext();
224 DCHECK(browser_process_context_getter.get());
225 DCHECK(default_profile_context_getter.get());
226 content::BrowserThread::PostDelayedTask(
227 content::BrowserThread::IO, FROM_HERE,
228 base::Bind(&TransferContextAuthenticationsOnIOThread,
229 default_profile_context_getter,
230 browser_process_context_getter),
231 kAuthCacheTransferDelayMs);
232 }
168 if (type != chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED) 233 if (type != chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED)
169 return; 234 return;
170 login_display_->OnUserImageChanged(*content::Details<User>(details).ptr()); 235 login_display_->OnUserImageChanged(*content::Details<User>(details).ptr());
171 } 236 }
172 237
173 //////////////////////////////////////////////////////////////////////////////// 238 ////////////////////////////////////////////////////////////////////////////////
174 // ExistingUserController, private: 239 // ExistingUserController, private:
175 240
176 ExistingUserController::~ExistingUserController() { 241 ExistingUserController::~ExistingUserController() {
177 LoginUtils::Get()->DelegateDeleted(this); 242 LoginUtils::Get()->DelegateDeleted(this);
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 std::string owner; 738 std::string owner;
674 cros_settings_->GetString(kDeviceOwner, &owner); 739 cros_settings_->GetString(kDeviceOwner, &owner);
675 cryptohomed->AsyncSetOwnerUser(owner, NULL); 740 cryptohomed->AsyncSetOwnerUser(owner, NULL);
676 741
677 // Do not invoke AsyncDoAutomaticFreeDiskSpaceControl(NULL) here 742 // Do not invoke AsyncDoAutomaticFreeDiskSpaceControl(NULL) here
678 // so it does not delay the following mount. Cleanup will be 743 // so it does not delay the following mount. Cleanup will be
679 // started in Cryptohomed by timer. 744 // started in Cryptohomed by timer.
680 } 745 }
681 746
682 } // namespace chromeos 747 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698