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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
6 | 6 |
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 7 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 ResourceDispatcherHostLoginDelegate* | 654 ResourceDispatcherHostLoginDelegate* |
655 ResourceDispatcherHostImpl::CreateLoginDelegate( | 655 ResourceDispatcherHostImpl::CreateLoginDelegate( |
656 ResourceLoader* loader, | 656 ResourceLoader* loader, |
657 net::AuthChallengeInfo* auth_info) { | 657 net::AuthChallengeInfo* auth_info) { |
658 if (!delegate_) | 658 if (!delegate_) |
659 return NULL; | 659 return NULL; |
660 | 660 |
661 return delegate_->CreateLoginDelegate(auth_info, loader->request()); | 661 return delegate_->CreateLoginDelegate(auth_info, loader->request()); |
662 } | 662 } |
663 | 663 |
| 664 bool RequestHasRecentUserGesture(const net::URLRequest* request) { |
| 665 return (request->load_flags() & net::LOAD_MAYBE_USER_GESTURE) != 0; |
| 666 } |
| 667 |
664 bool ResourceDispatcherHostImpl::HandleExternalProtocol(ResourceLoader* loader, | 668 bool ResourceDispatcherHostImpl::HandleExternalProtocol(ResourceLoader* loader, |
665 const GURL& url) { | 669 const GURL& url) { |
666 if (!delegate_) | 670 if (!delegate_) |
667 return false; | 671 return false; |
668 | 672 |
669 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); | 673 ResourceRequestInfoImpl* info = loader->GetRequestInfo(); |
670 | 674 |
671 if (!ResourceType::IsFrame(info->GetResourceType())) | 675 if (!ResourceType::IsFrame(info->GetResourceType())) |
672 return false; | 676 return false; |
673 | 677 |
674 const net::URLRequestJobFactory* job_factory = | 678 const net::URLRequestJobFactory* job_factory = |
675 info->GetContext()->GetRequestContext()->job_factory(); | 679 info->GetContext()->GetRequestContext()->job_factory(); |
676 if (job_factory->IsHandledURL(url)) | 680 if (job_factory->IsHandledURL(url)) |
677 return false; | 681 return false; |
678 | 682 |
679 return delegate_->HandleExternalProtocol(url, info->GetChildID(), | 683 bool user_gesture = RequestHasRecentUserGesture(loader->request()); |
680 info->GetRouteID()); | 684 bool handled = delegate_->HandleExternalProtocol(url, info->GetChildID(), |
| 685 info->GetRouteID(), |
| 686 user_gesture); |
| 687 // Consume the user gesture if the external protocol dialog is shown. |
| 688 if (handled) |
| 689 last_user_gesture_time_ = base::TimeTicks(); |
| 690 return handled; |
681 } | 691 } |
682 | 692 |
683 void ResourceDispatcherHostImpl::DidStartRequest(ResourceLoader* loader) { | 693 void ResourceDispatcherHostImpl::DidStartRequest(ResourceLoader* loader) { |
684 // Make sure we have the load state monitor running | 694 // Make sure we have the load state monitor running |
685 if (!update_load_states_timer_->IsRunning()) { | 695 if (!update_load_states_timer_->IsRunning()) { |
686 update_load_states_timer_->Start(FROM_HERE, | 696 update_load_states_timer_->Start(FROM_HERE, |
687 TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec), | 697 TimeDelta::FromMilliseconds(kUpdateLoadStatesIntervalMsec), |
688 this, &ResourceDispatcherHostImpl::UpdateLoadStates); | 698 this, &ResourceDispatcherHostImpl::UpdateLoadStates); |
689 } | 699 } |
690 } | 700 } |
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1983 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) | 1993 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) |
1984 && !policy->CanReadRawCookies(child_id)) { | 1994 && !policy->CanReadRawCookies(child_id)) { |
1985 VLOG(1) << "Denied unauthorized request for raw headers"; | 1995 VLOG(1) << "Denied unauthorized request for raw headers"; |
1986 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; | 1996 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; |
1987 } | 1997 } |
1988 | 1998 |
1989 return load_flags; | 1999 return load_flags; |
1990 } | 2000 } |
1991 | 2001 |
1992 } // namespace content | 2002 } // namespace content |
OLD | NEW |