Chromium Code Reviews| Index: content/browser/content_resource_dispatcher_host_delegate.cc |
| diff --git a/content/browser/content_resource_dispatcher_host_delegate.cc b/content/browser/content_resource_dispatcher_host_delegate.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2d3b3e197a7710ca58c6558a3e4d599192c7f862 |
| --- /dev/null |
| +++ b/content/browser/content_resource_dispatcher_host_delegate.cc |
| @@ -0,0 +1,144 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/content_resource_dispatcher_host_delegate.h" |
| + |
| +#include "content/browser/host_zoom_map_impl.h" |
| +#include "content/browser/loader/resource_message_filter.h" |
| +#include "content/browser/loader/resource_request_info_impl.h" |
| +#include "content/common/view_messages.h" |
| +#include "content/public/browser/stream_info.h" |
| +#include "net/url_request/url_request.h" |
| + |
| +namespace content { |
| + |
| +ContentResourceDispatcherHostDelegate::ContentResourceDispatcherHostDelegate() { |
| +} |
| + |
| +ContentResourceDispatcherHostDelegate:: |
| + ~ContentResourceDispatcherHostDelegate() {} |
| + |
| +void ContentResourceDispatcherHostDelegate::SetChild( |
| + ResourceDispatcherHostDelegate* child) { |
| + child_ = child; |
| +} |
| + |
| +bool ContentResourceDispatcherHostDelegate::ShouldBeginRequest( |
| + const std::string& method, |
| + const GURL& url, |
| + content::ResourceType resource_type, |
| + content::ResourceContext* resource_context) { |
| + return child_->ShouldBeginRequest(method, url, resource_type, |
| + resource_context); |
| +} |
| + |
| +void ContentResourceDispatcherHostDelegate::RequestBeginning( |
| + net::URLRequest* request, |
| + content::ResourceContext* resource_context, |
| + content::AppCacheService* appcache_service, |
| + content::ResourceType resource_type, |
| + ScopedVector<content::ResourceThrottle>* throttles) { |
| + child_->RequestBeginning(request, resource_context, appcache_service, |
| + resource_type, throttles); |
| +} |
| + |
| +void ContentResourceDispatcherHostDelegate::DownloadStarting( |
| + net::URLRequest* request, |
| + content::ResourceContext* resource_context, |
| + int child_id, |
| + int route_id, |
| + int request_id, |
| + bool is_content_initiated, |
| + bool must_download, |
| + ScopedVector<content::ResourceThrottle>* throttles) { |
| + child_->DownloadStarting(request, resource_context, child_id, route_id, |
| + request_id, is_content_initiated, must_download, |
| + throttles); |
| +} |
| + |
| +content::ResourceDispatcherHostLoginDelegate* |
| +ContentResourceDispatcherHostDelegate::CreateLoginDelegate( |
| + net::AuthChallengeInfo* auth_info, |
| + net::URLRequest* request) { |
| + return child_->CreateLoginDelegate(auth_info, request); |
| +} |
| + |
| +bool ContentResourceDispatcherHostDelegate::HandleExternalProtocol( |
| + const GURL& url, |
| + int child_id, |
| + const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
| + bool is_main_frame, |
| + ui::PageTransition page_transition, |
| + bool has_user_gesture) { |
| + return child_->HandleExternalProtocol(url, child_id, web_contents_getter, |
| + is_main_frame, page_transition, |
| + has_user_gesture); |
| +} |
| + |
| +bool ContentResourceDispatcherHostDelegate::ShouldForceDownloadResource( |
| + const GURL& url, |
| + const std::string& mime_type) { |
| + return child_->ShouldForceDownloadResource(url, mime_type); |
| +} |
| + |
| +bool ContentResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream( |
| + net::URLRequest* request, |
| + const base::FilePath& plugin_path, |
| + const std::string& mime_type, |
| + GURL* origin, |
| + std::string* payload) { |
| + return child_->ShouldInterceptResourceAsStream(request, plugin_path, |
| + mime_type, origin, payload); |
| +} |
| + |
| +void ContentResourceDispatcherHostDelegate::OnStreamCreated( |
| + net::URLRequest* request, |
| + std::unique_ptr<content::StreamInfo> stream) { |
| + child_->OnStreamCreated(request, std::move(stream)); |
| +} |
| + |
| +void ContentResourceDispatcherHostDelegate::OnResponseStarted( |
| + net::URLRequest* request, |
| + content::ResourceContext* resource_context, |
| + content::ResourceResponse* response, |
| + IPC::Sender* sender) { |
| + child_->OnResponseStarted(request, resource_context, response, sender); |
| + |
| + const ResourceRequestInfoImpl* info = |
|
scottmg
2016/05/06 21:52:15
Moving this block of code out of AsyncResourceHand
|
| + ResourceRequestInfoImpl::ForRequest(request); |
| + const HostZoomMapImpl* host_zoom_map = |
| + static_cast<const HostZoomMapImpl*>(info->filter()->GetHostZoomMap()); |
| + |
| + if (info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME && host_zoom_map) { |
| + const GURL& request_url = request->url(); |
| + int render_process_id = info->GetChildID(); |
| + int render_view_id = info->GetRouteID(); |
| + |
| + double zoom_level = host_zoom_map->GetZoomLevelForView( |
| + request_url, render_process_id, render_view_id); |
| + |
| + info->filter()->Send(new ViewMsg_SetZoomLevelForLoadingURL( |
| + render_view_id, request_url, zoom_level)); |
| + } |
| +} |
| + |
| +void ContentResourceDispatcherHostDelegate::OnRequestRedirected( |
| + const GURL& redirect_url, |
| + net::URLRequest* request, |
| + content::ResourceContext* resource_context, |
| + content::ResourceResponse* response) { |
| + child_->OnRequestRedirected(redirect_url, request, resource_context, |
| + response); |
| +} |
| + |
| +void ContentResourceDispatcherHostDelegate::RequestComplete( |
| + net::URLRequest* url_request) {} |
| + |
| +bool ContentResourceDispatcherHostDelegate::ShouldEnableLoFiMode( |
| + const net::URLRequest& url_request, |
| + content::ResourceContext* resource_context) { |
| + return child_->ShouldEnableLoFiMode(url_request, resource_context); |
| +} |
| + |
| +} // namespace content |