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

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

Issue 403933002: Set SSL info when an HTTP auth dialog is triggered by direct navigation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Just use pending navigation entry for everything Created 5 years, 9 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
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"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/synchronization/lock.h" 13 #include "base/synchronization/lock.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 15 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
16 #include "chrome/browser/prerender/prerender_contents.h" 16 #include "chrome/browser/prerender/prerender_contents.h"
17 #include "chrome/browser/tab_contents/tab_util.h" 17 #include "chrome/browser/tab_contents/tab_util.h"
18 #include "chrome/browser/ui/login/login_interstitial_delegate.h" 18 #include "chrome/browser/ui/login/login_interstitial_delegate.h"
19 #include "chrome/grit/generated_resources.h" 19 #include "chrome/grit/generated_resources.h"
20 #include "components/password_manager/content/browser/content_password_manager_d river.h" 20 #include "components/password_manager/content/browser/content_password_manager_d river.h"
21 #include "components/password_manager/core/browser/browser_save_password_progres s_logger.h" 21 #include "components/password_manager/core/browser/browser_save_password_progres s_logger.h"
22 #include "components/password_manager/core/browser/password_manager.h" 22 #include "components/password_manager/core/browser/password_manager.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/navigation_entry.h"
24 #include "content/public/browser/notification_registrar.h" 25 #include "content/public/browser/notification_registrar.h"
25 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/render_frame_host.h" 27 #include "content/public/browser/render_frame_host.h"
27 #include "content/public/browser/resource_dispatcher_host.h" 28 #include "content/public/browser/resource_dispatcher_host.h"
28 #include "content/public/browser/resource_request_info.h" 29 #include "content/public/browser/resource_request_info.h"
29 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
31 #include "content/public/common/ssl_status.h"
32 #include "grit/generated_resources.h"
30 #include "net/base/auth.h" 33 #include "net/base/auth.h"
31 #include "net/base/load_flags.h" 34 #include "net/base/load_flags.h"
32 #include "net/base/net_util.h" 35 #include "net/base/net_util.h"
33 #include "net/http/http_transaction_factory.h" 36 #include "net/http/http_transaction_factory.h"
37 #include "net/ssl/ssl_info.h"
34 #include "net/url_request/url_request.h" 38 #include "net/url_request/url_request.h"
35 #include "net/url_request/url_request_context.h" 39 #include "net/url_request/url_request_context.h"
36 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
37 #include "ui/gfx/text_elider.h" 41 #include "ui/gfx/text_elider.h"
38 42
39 using autofill::PasswordForm; 43 using autofill::PasswordForm;
40 using content::BrowserThread; 44 using content::BrowserThread;
41 using content::NavigationController; 45 using content::NavigationController;
42 using content::RenderViewHost; 46 using content::RenderViewHost;
43 using content::RenderViewHostDelegate; 47 using content::RenderViewHostDelegate;
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 // closed, so that interstitial should only be a login interstitial. 552 // closed, so that interstitial should only be a login interstitial.
549 if (is_main_frame && (parent_contents->ShowingInterstitialPage() || 553 if (is_main_frame && (parent_contents->ShowingInterstitialPage() ||
550 parent_contents->GetLastCommittedURL().GetOrigin() != 554 parent_contents->GetLastCommittedURL().GetOrigin() !=
551 request_url.GetOrigin())) { 555 request_url.GetOrigin())) {
552 // Show a blank interstitial for main-frame, cross origin requests 556 // Show a blank interstitial for main-frame, cross origin requests
553 // so that the correct URL is shown in the omnibox. 557 // so that the correct URL is shown in the omnibox.
554 base::Closure callback = base::Bind(&ShowLoginPrompt, 558 base::Closure callback = base::Bind(&ShowLoginPrompt,
555 request_url, 559 request_url,
556 make_scoped_refptr(auth_info), 560 make_scoped_refptr(auth_info),
557 make_scoped_refptr(handler)); 561 make_scoped_refptr(handler));
562 content::NavigationEntry* pending_entry =
Charlie Reis 2015/03/18 17:46:38 Let's put a comment about why it's correct to use
palmer 2015/09/29 00:03:33 I'm following up with this at https://codereview.c
563 parent_contents->GetController().GetPendingEntry();
564 const content::SSLStatus& ssl_status = pending_entry->GetSSL();
558 // This is owned by the interstitial it creates. It cancels any existing 565 // This is owned by the interstitial it creates. It cancels any existing
559 // interstitial. 566 // interstitial.
560 new LoginInterstitialDelegate(parent_contents, 567 new LoginInterstitialDelegate(parent_contents, request_url, ssl_status,
561 request_url,
562 callback); 568 callback);
563 } else { 569 } else {
564 ShowLoginPrompt(request_url, 570 ShowLoginPrompt(request_url,
565 auth_info, 571 auth_info,
566 handler); 572 handler);
567 } 573 }
568 } 574 }
569 575
570 // ---------------------------------------------------------------------------- 576 // ----------------------------------------------------------------------------
571 // Public API 577 // Public API
572 578
573 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, 579 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info,
574 net::URLRequest* request) { 580 net::URLRequest* request) {
575 bool is_main_frame = (request->load_flags() & net::LOAD_MAIN_FRAME) != 0; 581 bool is_main_frame = (request->load_flags() & net::LOAD_MAIN_FRAME) != 0;
576 LoginHandler* handler = LoginHandler::Create(auth_info, request); 582 LoginHandler* handler = LoginHandler::Create(auth_info, request);
577 BrowserThread::PostTask( 583 BrowserThread::PostTask(
578 BrowserThread::UI, FROM_HERE, 584 BrowserThread::UI, FROM_HERE,
579 base::Bind(&LoginDialogCallback, request->url(), 585 base::Bind(&LoginDialogCallback, request->url(),
580 make_scoped_refptr(auth_info), make_scoped_refptr(handler), 586 make_scoped_refptr(auth_info), make_scoped_refptr(handler),
581 is_main_frame)); 587 is_main_frame));
582 return handler; 588 return handler;
583 } 589 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698