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

Side by Side Diff: chrome/browser/ui/login/login_prompt.cc

Issue 5814005: Minimize login prompts (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add browsertest Created 10 years 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/login/login_prompt.h" 5 #include "chrome/browser/ui/login/login_prompt.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 const NotificationSource& source, 189 const NotificationSource& source,
190 const NotificationDetails& details) { 190 const NotificationDetails& details) {
191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 191 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
192 DCHECK(type == NotificationType::AUTH_SUPPLIED || 192 DCHECK(type == NotificationType::AUTH_SUPPLIED ||
193 type == NotificationType::AUTH_CANCELLED); 193 type == NotificationType::AUTH_CANCELLED);
194 194
195 TabContents* requesting_contents = GetTabContentsForLogin(); 195 TabContents* requesting_contents = GetTabContentsForLogin();
196 if (!requesting_contents) 196 if (!requesting_contents)
197 return; 197 return;
198 198
199 NavigationController* this_controller = &requesting_contents->controller(); 199 // Break out early if we aren't interested in the notification.
200 NavigationController* that_controller = 200 if (WasAuthHandled(false))
cbentzel 2010/12/17 19:22:56 I know the code already existed like this, but I'm
asanka (google) 2010/12/17 21:35:35 I'll defer this for another CL. I agree with the
201 Source<NavigationController>(source).ptr();
202
203 // Only handle notifications from other handlers.
204 if (this_controller == that_controller)
205 return; 201 return;
206 202
207 LoginNotificationDetails* login_details = 203 LoginNotificationDetails* login_details =
208 Details<LoginNotificationDetails>(details).ptr(); 204 Details<LoginNotificationDetails>(details).ptr();
209 205
206 // WasAuthHandled(false) should always test positive before we
207 // publish AUTH_SUPPLIED or AUTH_CANCELLED notifications.
208 DCHECK(login_details->handler() != this);
209
210 // Only handle notification for the identical auth info. 210 // Only handle notification for the identical auth info.
211 if (*login_details->handler()->auth_info() != *auth_info()) 211 if (*login_details->handler()->auth_info() != *auth_info())
212 return; 212 return;
213 213
214 // Set or cancel the auth in this handler. 214 // Set or cancel the auth in this handler.
215 if (type == NotificationType::AUTH_SUPPLIED) { 215 if (type == NotificationType::AUTH_SUPPLIED) {
216 AuthSuppliedLoginNotificationDetails* supplied_details = 216 AuthSuppliedLoginNotificationDetails* supplied_details =
217 Details<AuthSuppliedLoginNotificationDetails>(details).ptr(); 217 Details<AuthSuppliedLoginNotificationDetails>(details).ptr();
218 SetAuth(supplied_details->username(), supplied_details->password()); 218 SetAuth(supplied_details->username(), supplied_details->password());
219 } else { 219 } else {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 // Public API 444 // Public API
445 445
446 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, 446 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info,
447 net::URLRequest* request) { 447 net::URLRequest* request) {
448 LoginHandler* handler = LoginHandler::Create(auth_info, request); 448 LoginHandler* handler = LoginHandler::Create(auth_info, request);
449 BrowserThread::PostTask( 449 BrowserThread::PostTask(
450 BrowserThread::UI, FROM_HERE, new LoginDialogTask( 450 BrowserThread::UI, FROM_HERE, new LoginDialogTask(
451 request->url(), auth_info, handler)); 451 request->url(), auth_info, handler));
452 return handler; 452 return handler;
453 } 453 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698