OLD | NEW |
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_handler.h" | 5 #include "chrome/browser/ui/login/login_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "components/password_manager/core/browser/password_manager.h" | 24 #include "components/password_manager/core/browser/password_manager.h" |
25 #include "components/strings/grit/components_strings.h" | 25 #include "components/strings/grit/components_strings.h" |
26 #include "components/url_formatter/elide_url.h" | 26 #include "components/url_formatter/elide_url.h" |
27 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/browser/notification_registrar.h" | 28 #include "content/public/browser/notification_registrar.h" |
29 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
30 #include "content/public/browser/render_frame_host.h" | 30 #include "content/public/browser/render_frame_host.h" |
31 #include "content/public/browser/resource_dispatcher_host.h" | 31 #include "content/public/browser/resource_dispatcher_host.h" |
32 #include "content/public/browser/resource_request_info.h" | 32 #include "content/public/browser/resource_request_info.h" |
33 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
| 34 #include "content/public/browser/web_contents_delegate.h" |
34 #include "content/public/common/origin_util.h" | 35 #include "content/public/common/origin_util.h" |
35 #include "extensions/features/features.h" | 36 #include "extensions/features/features.h" |
36 #include "net/base/auth.h" | 37 #include "net/base/auth.h" |
37 #include "net/base/host_port_pair.h" | 38 #include "net/base/host_port_pair.h" |
38 #include "net/base/load_flags.h" | 39 #include "net/base/load_flags.h" |
39 #include "net/http/http_auth_scheme.h" | 40 #include "net/http/http_auth_scheme.h" |
40 #include "net/http/http_transaction_factory.h" | 41 #include "net/http/http_transaction_factory.h" |
41 #include "net/url_request/url_request.h" | 42 #include "net/url_request/url_request.h" |
42 #include "net/url_request/url_request_context.h" | 43 #include "net/url_request/url_request_context.h" |
43 #include "ui/base/l10n/l10n_util.h" | 44 #include "ui/base/l10n/l10n_util.h" |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 // hosted by a tab (e.g. an extension). Cancel just in case (canceling twice | 590 // hosted by a tab (e.g. an extension). Cancel just in case (canceling twice |
590 // is a no-op). | 591 // is a no-op). |
591 handler->CancelAuth(); | 592 handler->CancelAuth(); |
592 return; | 593 return; |
593 } | 594 } |
594 | 595 |
595 // Check if this is a main frame navigation and | 596 // Check if this is a main frame navigation and |
596 // (a) if the request is cross origin or | 597 // (a) if the request is cross origin or |
597 // (b) if an interstitial is already being shown or | 598 // (b) if an interstitial is already being shown or |
598 // (c) the prompt is for proxy authentication | 599 // (c) the prompt is for proxy authentication |
| 600 // (d) we're not displaying a standalone app |
599 // | 601 // |
600 // For (a), there are two different ways the navigation can occur: | 602 // For (a), there are two different ways the navigation can occur: |
601 // 1- The user enters the resource URL in the omnibox. | 603 // 1- The user enters the resource URL in the omnibox. |
602 // 2- The page redirects to the resource. | 604 // 2- The page redirects to the resource. |
603 // In both cases, the last committed URL is different than the resource URL, | 605 // In both cases, the last committed URL is different than the resource URL, |
604 // so checking it is sufficient. | 606 // so checking it is sufficient. |
605 // Note that (1) will not be true once site isolation is enabled, as any | 607 // Note that (1) will not be true once site isolation is enabled, as any |
606 // navigation could cause a cross-process swap, including link clicks. | 608 // navigation could cause a cross-process swap, including link clicks. |
607 // | 609 // |
608 // For (b), the login interstitial should always replace an existing | 610 // For (b), the login interstitial should always replace an existing |
609 // interstitial. This is because |LoginHandler::CloseContentsDeferred| tries | 611 // interstitial. This is because |LoginHandler::CloseContentsDeferred| tries |
610 // to proceed whatever interstitial is being shown when the login dialog is | 612 // to proceed whatever interstitial is being shown when the login dialog is |
611 // closed, so that interstitial should only be a login interstitial. | 613 // closed, so that interstitial should only be a login interstitial. |
612 // | 614 // |
613 // For (c), the authority information in the omnibox will be (and should be) | 615 // For (c), the authority information in the omnibox will be (and should be) |
614 // different from the authority information in the authentication prompt. An | 616 // different from the authority information in the authentication prompt. An |
615 // interstitial with an empty URL clears the omnibox and reduces the possible | 617 // interstitial with an empty URL clears the omnibox and reduces the possible |
616 // user confusion that may result from the different authority information | 618 // user confusion that may result from the different authority information |
617 // being displayed simultaneously. This is specially important when the proxy | 619 // being displayed simultaneously. This is specially important when the proxy |
618 // is accessed via an open connection while the target server is considered | 620 // is accessed via an open connection while the target server is considered |
619 // secure. | 621 // secure. |
620 const bool is_cross_origin_request = | 622 const bool is_cross_origin_request = |
621 parent_contents->GetLastCommittedURL().GetOrigin() != | 623 parent_contents->GetLastCommittedURL().GetOrigin() != |
622 request_url.GetOrigin(); | 624 request_url.GetOrigin(); |
623 if (is_main_frame && | 625 if (is_main_frame && |
624 (is_cross_origin_request || parent_contents->ShowingInterstitialPage() || | 626 (is_cross_origin_request || parent_contents->ShowingInterstitialPage() || |
625 auth_info->is_proxy)) { | 627 auth_info->is_proxy) && |
| 628 parent_contents->GetDelegate()->GetDisplayMode(parent_contents) != |
| 629 blink::WebDisplayModeStandalone) { |
626 RecordHttpAuthPromptType(AUTH_PROMPT_TYPE_WITH_INTERSTITIAL); | 630 RecordHttpAuthPromptType(AUTH_PROMPT_TYPE_WITH_INTERSTITIAL); |
627 | 631 |
628 // Show a blank interstitial for main-frame, cross origin requests | 632 // Show a blank interstitial for main-frame, cross origin requests |
629 // so that the correct URL is shown in the omnibox. | 633 // so that the correct URL is shown in the omnibox. |
630 base::Closure callback = | 634 base::Closure callback = |
631 base::Bind(&LoginHandler::ShowLoginPrompt, request_url, | 635 base::Bind(&LoginHandler::ShowLoginPrompt, request_url, |
632 base::RetainedRef(auth_info), base::RetainedRef(handler)); | 636 base::RetainedRef(auth_info), base::RetainedRef(handler)); |
633 // The interstitial delegate is owned by the interstitial that it creates. | 637 // The interstitial delegate is owned by the interstitial that it creates. |
634 // This cancels any existing interstitial. | 638 // This cancels any existing interstitial. |
635 handler->SetInterstitialDelegate( | 639 handler->SetInterstitialDelegate( |
(...skipping 22 matching lines...) Expand all Loading... |
658 bool is_main_frame = | 662 bool is_main_frame = |
659 (request->load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) != 0; | 663 (request->load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) != 0; |
660 LoginHandler* handler = LoginHandler::Create(auth_info, request); | 664 LoginHandler* handler = LoginHandler::Create(auth_info, request); |
661 BrowserThread::PostTask( | 665 BrowserThread::PostTask( |
662 BrowserThread::UI, FROM_HERE, | 666 BrowserThread::UI, FROM_HERE, |
663 base::Bind(&LoginHandler::LoginDialogCallback, request->url(), | 667 base::Bind(&LoginHandler::LoginDialogCallback, request->url(), |
664 base::RetainedRef(auth_info), base::RetainedRef(handler), | 668 base::RetainedRef(auth_info), base::RetainedRef(handler), |
665 is_main_frame)); | 669 is_main_frame)); |
666 return handler; | 670 return handler; |
667 } | 671 } |
OLD | NEW |