Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/content_resource_dispatcher_host_delegate.h" | |
| 6 | |
| 7 #include "content/browser/host_zoom_map_impl.h" | |
| 8 #include "content/browser/loader/resource_message_filter.h" | |
| 9 #include "content/browser/loader/resource_request_info_impl.h" | |
| 10 #include "content/common/view_messages.h" | |
| 11 #include "content/public/browser/stream_info.h" | |
| 12 #include "net/url_request/url_request.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 ContentResourceDispatcherHostDelegate::ContentResourceDispatcherHostDelegate() { | |
| 17 } | |
| 18 | |
| 19 ContentResourceDispatcherHostDelegate:: | |
| 20 ~ContentResourceDispatcherHostDelegate() {} | |
| 21 | |
| 22 void ContentResourceDispatcherHostDelegate::SetChild( | |
| 23 ResourceDispatcherHostDelegate* child) { | |
| 24 child_ = child; | |
| 25 } | |
| 26 | |
| 27 bool ContentResourceDispatcherHostDelegate::ShouldBeginRequest( | |
| 28 const std::string& method, | |
| 29 const GURL& url, | |
| 30 content::ResourceType resource_type, | |
| 31 content::ResourceContext* resource_context) { | |
| 32 return child_->ShouldBeginRequest(method, url, resource_type, | |
| 33 resource_context); | |
| 34 } | |
| 35 | |
| 36 void ContentResourceDispatcherHostDelegate::RequestBeginning( | |
| 37 net::URLRequest* request, | |
| 38 content::ResourceContext* resource_context, | |
| 39 content::AppCacheService* appcache_service, | |
| 40 content::ResourceType resource_type, | |
| 41 ScopedVector<content::ResourceThrottle>* throttles) { | |
| 42 child_->RequestBeginning(request, resource_context, appcache_service, | |
| 43 resource_type, throttles); | |
| 44 } | |
| 45 | |
| 46 void ContentResourceDispatcherHostDelegate::DownloadStarting( | |
| 47 net::URLRequest* request, | |
| 48 content::ResourceContext* resource_context, | |
| 49 int child_id, | |
| 50 int route_id, | |
| 51 int request_id, | |
| 52 bool is_content_initiated, | |
| 53 bool must_download, | |
| 54 ScopedVector<content::ResourceThrottle>* throttles) { | |
| 55 child_->DownloadStarting(request, resource_context, child_id, route_id, | |
| 56 request_id, is_content_initiated, must_download, | |
| 57 throttles); | |
| 58 } | |
| 59 | |
| 60 content::ResourceDispatcherHostLoginDelegate* | |
| 61 ContentResourceDispatcherHostDelegate::CreateLoginDelegate( | |
| 62 net::AuthChallengeInfo* auth_info, | |
| 63 net::URLRequest* request) { | |
| 64 return child_->CreateLoginDelegate(auth_info, request); | |
| 65 } | |
| 66 | |
| 67 bool ContentResourceDispatcherHostDelegate::HandleExternalProtocol( | |
| 68 const GURL& url, | |
| 69 int child_id, | |
| 70 const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, | |
| 71 bool is_main_frame, | |
| 72 ui::PageTransition page_transition, | |
| 73 bool has_user_gesture) { | |
| 74 return child_->HandleExternalProtocol(url, child_id, web_contents_getter, | |
| 75 is_main_frame, page_transition, | |
| 76 has_user_gesture); | |
| 77 } | |
| 78 | |
| 79 bool ContentResourceDispatcherHostDelegate::ShouldForceDownloadResource( | |
| 80 const GURL& url, | |
| 81 const std::string& mime_type) { | |
| 82 return child_->ShouldForceDownloadResource(url, mime_type); | |
| 83 } | |
| 84 | |
| 85 bool ContentResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream( | |
| 86 net::URLRequest* request, | |
| 87 const base::FilePath& plugin_path, | |
| 88 const std::string& mime_type, | |
| 89 GURL* origin, | |
| 90 std::string* payload) { | |
| 91 return child_->ShouldInterceptResourceAsStream(request, plugin_path, | |
| 92 mime_type, origin, payload); | |
| 93 } | |
| 94 | |
| 95 void ContentResourceDispatcherHostDelegate::OnStreamCreated( | |
| 96 net::URLRequest* request, | |
| 97 std::unique_ptr<content::StreamInfo> stream) { | |
| 98 child_->OnStreamCreated(request, std::move(stream)); | |
| 99 } | |
| 100 | |
| 101 void ContentResourceDispatcherHostDelegate::OnResponseStarted( | |
| 102 net::URLRequest* request, | |
| 103 content::ResourceContext* resource_context, | |
| 104 content::ResourceResponse* response, | |
| 105 IPC::Sender* sender) { | |
| 106 child_->OnResponseStarted(request, resource_context, response, sender); | |
| 107 | |
| 108 const ResourceRequestInfoImpl* info = | |
|
scottmg
2016/05/06 21:52:15
Moving this block of code out of AsyncResourceHand
| |
| 109 ResourceRequestInfoImpl::ForRequest(request); | |
| 110 const HostZoomMapImpl* host_zoom_map = | |
| 111 static_cast<const HostZoomMapImpl*>(info->filter()->GetHostZoomMap()); | |
| 112 | |
| 113 if (info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME && host_zoom_map) { | |
| 114 const GURL& request_url = request->url(); | |
| 115 int render_process_id = info->GetChildID(); | |
| 116 int render_view_id = info->GetRouteID(); | |
| 117 | |
| 118 double zoom_level = host_zoom_map->GetZoomLevelForView( | |
| 119 request_url, render_process_id, render_view_id); | |
| 120 | |
| 121 info->filter()->Send(new ViewMsg_SetZoomLevelForLoadingURL( | |
| 122 render_view_id, request_url, zoom_level)); | |
| 123 } | |
| 124 } | |
| 125 | |
| 126 void ContentResourceDispatcherHostDelegate::OnRequestRedirected( | |
| 127 const GURL& redirect_url, | |
| 128 net::URLRequest* request, | |
| 129 content::ResourceContext* resource_context, | |
| 130 content::ResourceResponse* response) { | |
| 131 child_->OnRequestRedirected(redirect_url, request, resource_context, | |
| 132 response); | |
| 133 } | |
| 134 | |
| 135 void ContentResourceDispatcherHostDelegate::RequestComplete( | |
| 136 net::URLRequest* url_request) {} | |
| 137 | |
| 138 bool ContentResourceDispatcherHostDelegate::ShouldEnableLoFiMode( | |
| 139 const net::URLRequest& url_request, | |
| 140 content::ResourceContext* resource_context) { | |
| 141 return child_->ShouldEnableLoFiMode(url_request, resource_context); | |
| 142 } | |
| 143 | |
| 144 } // namespace content | |
| OLD | NEW |