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

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

Issue 397453002: Add test case to see if HTTP auth interstitials work nicely with other interstitials (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nasko comments Created 6 years, 5 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 | chrome/browser/ui/login/login_prompt_browsertest.cc » ('j') | 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/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 "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 DCHECK_CURRENTLY_ON(BrowserThread::UI); 502 DCHECK_CURRENTLY_ON(BrowserThread::UI);
503 WebContents* parent_contents = handler->GetWebContentsForLogin(); 503 WebContents* parent_contents = handler->GetWebContentsForLogin();
504 if (!parent_contents || handler->WasAuthHandled()) { 504 if (!parent_contents || handler->WasAuthHandled()) {
505 // The request may have been cancelled, or it may be for a renderer 505 // The request may have been cancelled, or it may be for a renderer
506 // not hosted by a tab (e.g. an extension). Cancel just in case 506 // not hosted by a tab (e.g. an extension). Cancel just in case
507 // (cancelling twice is a no-op). 507 // (cancelling twice is a no-op).
508 handler->CancelAuth(); 508 handler->CancelAuth();
509 return; 509 return;
510 } 510 }
511 511
512 // For main frame navigations, show a blank interstitial if this is a cross
513 // origin request or if there is an existing interstitial.
msw 2014/08/01 17:09:47 It sounds like this could clobber or hide the firs
meacer 2014/08/01 17:25:56 Ah, good point. The assumption at the time of writ
512 if (is_main_frame && 514 if (is_main_frame &&
513 parent_contents->GetVisibleURL().GetOrigin() != request_url.GetOrigin()) { 515 (parent_contents->GetInterstitialPage() ||
516 parent_contents->GetVisibleURL().GetOrigin() != request_url.GetOrigin())
517 ) {
514 // Show a blank interstitial for main-frame, cross origin requests 518 // Show a blank interstitial for main-frame, cross origin requests
515 // so that the correct URL is shown in the omnibox. 519 // so that the correct URL is shown in the omnibox.
516 base::Closure callback = base::Bind(&ShowLoginPrompt, 520 base::Closure callback = base::Bind(&ShowLoginPrompt,
517 request_url, 521 request_url,
518 make_scoped_refptr(auth_info), 522 make_scoped_refptr(auth_info),
519 make_scoped_refptr(handler)); 523 make_scoped_refptr(handler));
520 // This is owned by the interstitial it creates. 524
525 // This is owned by the interstitial it creates. The new interstitial will
526 // replace existing interstitial, if any.
521 new LoginInterstitialDelegate(parent_contents, 527 new LoginInterstitialDelegate(parent_contents,
522 request_url, 528 request_url,
523 callback); 529 callback);
524 } else { 530 } else {
525 ShowLoginPrompt(request_url, 531 ShowLoginPrompt(request_url,
526 auth_info, 532 auth_info,
527 handler); 533 handler);
528 } 534 }
529 } 535 }
530 536
531 // ---------------------------------------------------------------------------- 537 // ----------------------------------------------------------------------------
532 // Public API 538 // Public API
533 539
534 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, 540 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info,
535 net::URLRequest* request) { 541 net::URLRequest* request) {
536 bool is_main_frame = (request->load_flags() & net::LOAD_MAIN_FRAME) != 0; 542 bool is_main_frame = (request->load_flags() & net::LOAD_MAIN_FRAME) != 0;
537 LoginHandler* handler = LoginHandler::Create(auth_info, request); 543 LoginHandler* handler = LoginHandler::Create(auth_info, request);
538 BrowserThread::PostTask( 544 BrowserThread::PostTask(
539 BrowserThread::UI, FROM_HERE, 545 BrowserThread::UI, FROM_HERE,
540 base::Bind(&LoginDialogCallback, request->url(), 546 base::Bind(&LoginDialogCallback, request->url(),
541 make_scoped_refptr(auth_info), make_scoped_refptr(handler), 547 make_scoped_refptr(auth_info), make_scoped_refptr(handler),
542 is_main_frame)); 548 is_main_frame));
543 return handler; 549 return handler;
544 } 550 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/login/login_prompt_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698