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

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: Rebase 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 =
563 parent_contents->GetController().GetPendingEntry();
564 ui::PageTransition transition = pending_entry->GetTransitionType();
565 // For non-user initiated navigations, auth dialog is displayed when the
566 // visible url points to the page that initiated the navigation and not the
567 // actual auth url. Update the pending entry in that case.
568 content::NavigationEntry* entry =
569 (transition & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR)
570 ? parent_contents->GetController().GetVisibleEntry()
571 : pending_entry;
meacer 2015/03/12 20:37:48 Not sure if this is the best way to check for rend
Charlie Reis 2015/03/13 18:19:37 This won't work for determining renderer-initiated
meacer 2015/03/17 17:30:44 I initally used is_renderer_initiated() but realiz
572 const content::SSLStatus& ssl_status = entry->GetSSL();
558 // This is owned by the interstitial it creates. It cancels any existing 573 // This is owned by the interstitial it creates. It cancels any existing
559 // interstitial. 574 // interstitial.
560 new LoginInterstitialDelegate(parent_contents, 575 new LoginInterstitialDelegate(parent_contents, request_url, ssl_status,
561 request_url,
562 callback); 576 callback);
563 } else { 577 } else {
564 ShowLoginPrompt(request_url, 578 ShowLoginPrompt(request_url,
565 auth_info, 579 auth_info,
566 handler); 580 handler);
567 } 581 }
568 } 582 }
569 583
570 // ---------------------------------------------------------------------------- 584 // ----------------------------------------------------------------------------
571 // Public API 585 // Public API
572 586
573 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, 587 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info,
574 net::URLRequest* request) { 588 net::URLRequest* request) {
575 bool is_main_frame = (request->load_flags() & net::LOAD_MAIN_FRAME) != 0; 589 bool is_main_frame = (request->load_flags() & net::LOAD_MAIN_FRAME) != 0;
576 LoginHandler* handler = LoginHandler::Create(auth_info, request); 590 LoginHandler* handler = LoginHandler::Create(auth_info, request);
577 BrowserThread::PostTask( 591 BrowserThread::PostTask(
578 BrowserThread::UI, FROM_HERE, 592 BrowserThread::UI, FROM_HERE,
579 base::Bind(&LoginDialogCallback, request->url(), 593 base::Bind(&LoginDialogCallback, request->url(),
580 make_scoped_refptr(auth_info), make_scoped_refptr(handler), 594 make_scoped_refptr(auth_info), make_scoped_refptr(handler),
581 is_main_frame)); 595 is_main_frame));
582 return handler; 596 return handler;
583 } 597 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/login/login_prompt.h ('k') | chrome/browser/ui/login/login_prompt_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698