diff options
19 files changed, 164 insertions, 99 deletions
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index 22d7bcb..9d608ec 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -373,13 +373,14 @@ void ResourceDispatcherHost::BeginRequest( process_id, route_id, request_id, - request_data.mixed_content, + request_data.frame_origin, + request_data.main_frame_origin, request_data.resource_type, upload_size); extra_info->allow_download = ResourceType::IsFrame(request_data.resource_type); request->set_user_data(extra_info); // takes pointer ownership - BeginRequestInternal(request, request_data.mixed_content); + BeginRequestInternal(request); } void ResourceDispatcherHost::OnDataReceivedACK(int request_id) { @@ -507,14 +508,15 @@ void ResourceDispatcherHost::BeginDownload(const GURL& url, process_id, route_id, request_id_, - false, // Downloads are not considered mixed-content + "null", // frame_origin + "null", // main_frame_origin ResourceType::SUB_RESOURCE, 0 /* upload_size */ ); extra_info->allow_download = true; extra_info->is_download = true; request->set_user_data(extra_info); // Takes pointer ownership. - BeginRequestInternal(request, false); + BeginRequestInternal(request); } // This function is only used for saving feature. @@ -560,7 +562,8 @@ void ResourceDispatcherHost::BeginSaveFile(const GURL& url, process_id, route_id, request_id_, - false, + "null", // frame_origin + "null", // main_frame_origin ResourceType::SUB_RESOURCE, 0 /* upload_size */); // Just saving some resources we need, disallow downloading. @@ -568,7 +571,7 @@ void ResourceDispatcherHost::BeginSaveFile(const GURL& url, extra_info->is_download = false; request->set_user_data(extra_info); // Takes pointer ownership. - BeginRequestInternal(request, false); + BeginRequestInternal(request); } void ResourceDispatcherHost::CancelRequest(int process_id, @@ -980,8 +983,7 @@ int ResourceDispatcherHost::CalculateApproximateMemoryCost( return kAvgBytesPerOutstandingRequest + strings_cost + upload_cost; } -void ResourceDispatcherHost::BeginRequestInternal(URLRequest* request, - bool mixed_content) { +void ResourceDispatcherHost::BeginRequestInternal(URLRequest* request) { DCHECK(!request->is_pending()); ExtraRequestInfo* info = ExtraInfoForRequest(request); @@ -1010,17 +1012,16 @@ void ResourceDispatcherHost::BeginRequestInternal(URLRequest* request, BlockedRequestMap::const_iterator iter = blocked_requests_map_.find(pair_id); if (iter != blocked_requests_map_.end()) { // The request should be blocked. - iter->second->push_back(BlockedRequest(request, mixed_content)); + iter->second->push_back(BlockedRequest(request)); return; } GlobalRequestID global_id(info->process_id, info->request_id); pending_requests_[global_id] = request; - if (mixed_content) { - // We don't start the request in that case. The SSLManager will potentially - // change the request (potentially to indicate its content should be - // filtered) and start it itself. - SSLManager::OnMixedContentRequest(this, request, ui_loop_); + if (!SSLManager::ShouldStartRequest(this, request, ui_loop_)) { + // The SSLManager has told us that we shouldn't start the request yet. The + // SSLManager will potentially change the request (potentially to indicate + // its content should be filtered) and start it itself. return; } request->Start(); @@ -1508,7 +1509,7 @@ void ResourceDispatcherHost::ProcessBlockedRequestsForRoute( if (cancel_requests) delete req_iter->url_request; else - BeginRequestInternal(req_iter->url_request, req_iter->mixed_content); + BeginRequestInternal(req_iter->url_request); } delete requests; diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.h b/chrome/browser/renderer_host/resource_dispatcher_host.h index 44703aa..4bc7837 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.h +++ b/chrome/browser/renderer_host/resource_dispatcher_host.h @@ -72,7 +72,8 @@ class ResourceDispatcherHost : public URLRequest::Delegate { int process_id, int route_id, int request_id, - bool mixed_content, + std::string frame_origin, + std::string main_frame_origin, ResourceType::Type resource_type, uint64 upload_size) : resource_handler(handler), @@ -85,7 +86,8 @@ class ResourceDispatcherHost : public URLRequest::Delegate { pending_data_count(0), is_download(false), pause_count(0), - mixed_content(mixed_content), + frame_origin(frame_origin), + main_frame_origin(main_frame_origin), resource_type(resource_type), filter_policy(FilterPolicy::DONT_FILTER), last_load_state(net::LOAD_STATE_IDLE), @@ -127,9 +129,12 @@ class ResourceDispatcherHost : public URLRequest::Delegate { // The number of clients that have called pause on this request. int pause_count; - // Whether this request is served over HTTP and the main page was served - // over HTTPS. - bool mixed_content; + // The security origin of the frame making this request. + std::string frame_origin; + + // The security origin of the main frame that contains the frame making + // this request. + std::string main_frame_origin; ResourceType::Type resource_type; @@ -366,13 +371,12 @@ class ResourceDispatcherHost : public URLRequest::Delegate { friend class ShutdownTask; + // TODO(abarth): We don't need this struct any more. Let's get rid of it. struct BlockedRequest { - BlockedRequest(URLRequest* url_request, bool mixed_content) - : url_request(url_request), - mixed_content(mixed_content) { + explicit BlockedRequest(URLRequest* url_request) + : url_request(url_request) { } URLRequest* url_request; - bool mixed_content; }; // A shutdown helper that runs on the IO thread. @@ -407,7 +411,7 @@ class ResourceDispatcherHost : public URLRequest::Delegate { bool allow_delete); // Helper function for regular and download requests. - void BeginRequestInternal(URLRequest* request, bool mixed_content); + void BeginRequestInternal(URLRequest* request); // Updates the "cost" of outstanding requests for |process_id|. // The "cost" approximates how many bytes are consumed by all the in-memory diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc index 9e359a7..1d30789 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc @@ -36,10 +36,11 @@ static ViewHostMsg_Resource_Request CreateResourceRequest(const char* method, request.url = url; request.policy_url = url; // bypass third-party cookie blocking // init the rest to default values to prevent getting UMR. + request.frame_origin = "null"; + request.main_frame_origin = "null"; request.load_flags = 0; request.origin_pid = 0; request.resource_type = ResourceType::SUB_RESOURCE; - request.mixed_content = false; return request; } diff --git a/chrome/browser/renderer_host/resource_request_details.h b/chrome/browser/renderer_host/resource_request_details.h index 0e36478..8c2b98a 100644 --- a/chrome/browser/renderer_host/resource_request_details.h +++ b/chrome/browser/renderer_host/resource_request_details.h @@ -42,6 +42,8 @@ class ResourceRequestDetails { ResourceDispatcherHost::ExtraInfoForRequest(request); DCHECK(info); resource_type_ = info->resource_type; + frame_origin_ = info->frame_origin; + main_frame_origin_ = info->main_frame_origin; } ~ResourceRequestDetails() { } @@ -50,6 +52,8 @@ class ResourceRequestDetails { const GURL& original_url() const { return original_url_; } const std::string& method() const { return method_; } const std::string& referrer() const { return referrer_; } + const std::string& frame_origin() const { return frame_origin_; } + const std::string& main_frame_origin() const { return main_frame_origin_; } bool has_upload() const { return has_upload_; } int load_flags() const { return load_flags_; } int origin_pid() const { return origin_pid_; } @@ -57,11 +61,14 @@ class ResourceRequestDetails { int ssl_cert_id() const { return ssl_cert_id_; } int ssl_cert_status() const { return ssl_cert_status_; } ResourceType::Type resource_type() const { return resource_type_; } + private: GURL url_; GURL original_url_; std::string method_; std::string referrer_; + std::string frame_origin_; + std::string main_frame_origin_; bool has_upload_; int load_flags_; int origin_pid_; diff --git a/chrome/browser/ssl/ssl_manager.cc b/chrome/browser/ssl/ssl_manager.cc index 2d6e8d2..42fc860 100644 --- a/chrome/browser/ssl/ssl_manager.cc +++ b/chrome/browser/ssl/ssl_manager.cc @@ -463,12 +463,25 @@ void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh, } // static -void SSLManager::OnMixedContentRequest(ResourceDispatcherHost* rdh, - URLRequest* request, - MessageLoop* ui_loop) { +bool SSLManager::ShouldStartRequest(ResourceDispatcherHost* rdh, + URLRequest* request, + MessageLoop* ui_loop) { + ResourceDispatcherHost::ExtraRequestInfo* info = + ResourceDispatcherHost::ExtraInfoForRequest(request); + DCHECK(info); + + // We cheat here and talk to the SSLPolicy on the IO thread because we need + // to respond synchronously to avoid delaying all network requests... + if (!SSLPolicy::IsMixedContent(request->url(), + info->resource_type, + info->main_frame_origin)) + return true; + + ui_loop->PostTask(FROM_HERE, NewRunnableMethod(new MixedContentHandler(rdh, request, ui_loop), &MixedContentHandler::Dispatch)); + return false; } void SSLManager::OnCertError(CertError* error) { diff --git a/chrome/browser/ssl/ssl_manager.h b/chrome/browser/ssl/ssl_manager.h index 63cfce4..28ebbaa 100644 --- a/chrome/browser/ssl/ssl_manager.h +++ b/chrome/browser/ssl/ssl_manager.h @@ -343,16 +343,17 @@ class SSLManager : public NotificationObserver { net::X509Certificate* cert, MessageLoop* ui_loop); - // Called when a mixed-content sub-resource request has been detected. The - // request is not started yet. The SSLManager will make a decision on whether - // to filter that request's content (with the filter_policy flag). + // Called before a URL request is about to be started. Returns false if the + // resource request should be delayed while we figure out what to do. We use + // this function as the entry point for our mixed content detection. + // // TODO(jcampan): Implement a way to just cancel the request. This is not // straight-forward as canceling a request that has not been started will // not remove from the pending_requests_ of the ResourceDispatcherHost. // Called on the IO thread. - static void OnMixedContentRequest(ResourceDispatcherHost* resource_dispatcher, - URLRequest* request, - MessageLoop* ui_loop); + static bool ShouldStartRequest(ResourceDispatcherHost* resource_dispatcher, + URLRequest* request, + MessageLoop* ui_loop); // Called by CertError::Dispatch to kick off processing of the cert error by // the SSL manager. The error originated from the ResourceDispatcherHost. diff --git a/chrome/browser/ssl/ssl_policy.cc b/chrome/browser/ssl/ssl_policy.cc index 1748639..6e627fb 100644 --- a/chrome/browser/ssl/ssl_policy.cc +++ b/chrome/browser/ssl/ssl_policy.cc @@ -442,6 +442,24 @@ SecurityStyle SSLPolicy::GetDefaultStyle(const GURL& url) { return SECURITY_STYLE_UNAUTHENTICATED; } +// static +bool SSLPolicy::IsMixedContent(const GURL& url, + ResourceType::Type resource_type, + const std::string& main_frame_origin) { + //////////////////////////////////////////////////////////////////////////// + // WARNING: This function is called from both the IO and UI threads. Do // + // not touch any non-thread-safe objects! You have been warned. // + //////////////////////////////////////////////////////////////////////////// + + // We can't possibly have mixed content when loading the main frame. + if (resource_type == ResourceType::MAIN_FRAME) + return false; + + // TODO(abarth): This is wrong, but it matches our current behavior. + // I'll fix this in a subsequent step. + return GURL(main_frame_origin).SchemeIsSecure() && !url.SchemeIsSecure(); +} + SSLErrorInfo SSLPolicy::GetSSLErrorInfo(SSLManager::CertError* error) { return SSLErrorInfo::CreateError( SSLErrorInfo::NetErrorToErrorType(error->cert_error()), diff --git a/chrome/browser/ssl/ssl_policy.h b/chrome/browser/ssl/ssl_policy.h index b61861d..9318143 100644 --- a/chrome/browser/ssl/ssl_policy.h +++ b/chrome/browser/ssl/ssl_policy.h @@ -41,6 +41,12 @@ class SSLPolicy : public SSLManager::Delegate, int ssl_cert_status); virtual SecurityStyle GetDefaultStyle(const GURL& url); + // This method is static because it is called from both the UI and the IO + // threads. + static bool IsMixedContent(const GURL& url, + ResourceType::Type resource_type, + const std::string& main_frame_origin); + // SSLBlockingPage::Delegate methods. virtual SSLErrorInfo GetSSLErrorInfo(SSLManager::CertError* error); virtual void OnDenyCertificate(SSLManager::CertError* error); diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 8ee6b9a..ebac85c 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -242,6 +242,14 @@ struct ViewHostMsg_Resource_Request { // The referrer to use (may be empty). GURL referrer; + // The origin of the frame that is associated with this request. This is used + // to update our mixed content state. + std::string frame_origin; + + // The origin of the main frame (top-level frame) that is associated with this + // request. This is used to update our mixed content state. + std::string main_frame_origin; + // Additional HTTP request headers. std::string headers; @@ -255,10 +263,6 @@ struct ViewHostMsg_Resource_Request { // object). ResourceType::Type resource_type; - // True if this request is for a resource loaded over HTTP when the main page - // was loaded over HTTPS. - bool mixed_content; - // Used by plugin->browser requests to get the correct URLRequestContext. uint32 request_context; @@ -1244,11 +1248,12 @@ struct ParamTraits<ViewHostMsg_Resource_Request> { WriteParam(m, p.url); WriteParam(m, p.policy_url); WriteParam(m, p.referrer); + WriteParam(m, p.frame_origin); + WriteParam(m, p.main_frame_origin); WriteParam(m, p.headers); WriteParam(m, p.load_flags); WriteParam(m, p.origin_pid); WriteParam(m, p.resource_type); - WriteParam(m, p.mixed_content); WriteParam(m, p.request_context); WriteParam(m, p.upload_content); } @@ -1258,11 +1263,12 @@ struct ParamTraits<ViewHostMsg_Resource_Request> { ReadParam(m, iter, &r->url) && ReadParam(m, iter, &r->policy_url) && ReadParam(m, iter, &r->referrer) && + ReadParam(m, iter, &r->frame_origin) && + ReadParam(m, iter, &r->main_frame_origin) && ReadParam(m, iter, &r->headers) && ReadParam(m, iter, &r->load_flags) && ReadParam(m, iter, &r->origin_pid) && ReadParam(m, iter, &r->resource_type) && - ReadParam(m, iter, &r->mixed_content) && ReadParam(m, iter, &r->request_context) && ReadParam(m, iter, &r->upload_content); } @@ -1274,14 +1280,16 @@ struct ParamTraits<ViewHostMsg_Resource_Request> { l->append(L", "); LogParam(p.referrer, l); l->append(L", "); + LogParam(p.frame_origin, l); + l->append(L", "); + LogParam(p.main_frame_origin, l); + l->append(L", "); LogParam(p.load_flags, l); l->append(L", "); LogParam(p.origin_pid, l); l->append(L", "); LogParam(p.resource_type, l); l->append(L", "); - LogParam(p.mixed_content, l); - l->append(L", "); LogParam(p.request_context, l); l->append(L")"); } diff --git a/chrome/common/resource_dispatcher.cc b/chrome/common/resource_dispatcher.cc index f29fa24..e5c398b 100644 --- a/chrome/common/resource_dispatcher.cc +++ b/chrome/common/resource_dispatcher.cc @@ -47,11 +47,12 @@ class IPCResourceLoaderBridge : public ResourceLoaderBridge { const GURL& url, const GURL& policy_url, const GURL& referrer, + const std::string& frame_origin, + const std::string& main_frame_origin, const std::string& headers, int load_flags, int origin_pid, ResourceType::Type resource_type, - bool mixed_content, uint32 request_context, int route_id); virtual ~IPCResourceLoaderBridge(); @@ -98,11 +99,12 @@ IPCResourceLoaderBridge::IPCResourceLoaderBridge( const GURL& url, const GURL& policy_url, const GURL& referrer, + const std::string& frame_origin, + const std::string& main_frame_origin, const std::string& headers, int load_flags, int origin_pid, ResourceType::Type resource_type, - bool mixed_content, uint32 request_context, int route_id) : peer_(NULL), @@ -114,11 +116,12 @@ IPCResourceLoaderBridge::IPCResourceLoaderBridge( request_.url = url; request_.policy_url = policy_url; request_.referrer = referrer; + request_.frame_origin = frame_origin; + request_.main_frame_origin = main_frame_origin; request_.headers = headers; request_.load_flags = load_flags; request_.origin_pid = origin_pid; request_.resource_type = resource_type; - request_.mixed_content = mixed_content; request_.request_context = request_context; #ifdef LOG_RESOURCE_REQUESTS @@ -168,8 +171,7 @@ bool IPCResourceLoaderBridge::Start(Peer* peer) { peer_ = peer; // generate the request ID, and append it to the message - request_id_ = dispatcher_->AddPendingRequest(peer_, request_.resource_type, - request_.mixed_content); + request_id_ = dispatcher_->AddPendingRequest(peer_, request_.resource_type); return dispatcher_->message_sender()->Send( new ViewHostMsg_RequestResource(route_id_, request_id_, request_)); @@ -439,12 +441,10 @@ void ResourceDispatcher::OnRequestComplete(int request_id, int ResourceDispatcher::AddPendingRequest( webkit_glue::ResourceLoaderBridge::Peer* callback, - ResourceType::Type resource_type, - bool mixed_content) { + ResourceType::Type resource_type) { // Compute a unique request_id for this renderer process. int id = MakeRequestID(); - pending_requests_[id] = PendingRequestInfo(callback, resource_type, - mixed_content); + pending_requests_[id] = PendingRequestInfo(callback, resource_type); return id; } @@ -508,19 +508,20 @@ webkit_glue::ResourceLoaderBridge* ResourceDispatcher::CreateBridge( const GURL& url, const GURL& policy_url, const GURL& referrer, + const std::string& frame_origin, + const std::string& main_frame_origin, const std::string& headers, int flags, int origin_pid, ResourceType::Type resource_type, - bool mixed_content, uint32 request_context, int route_id) { return new webkit_glue::IPCResourceLoaderBridge(this, method, url, policy_url, - referrer, headers, flags, - origin_pid, resource_type, - mixed_content, - request_context, - route_id); + referrer, frame_origin, + main_frame_origin, headers, + flags, origin_pid, + resource_type, + request_context, route_id); } bool ResourceDispatcher::IsResourceDispatcherMessage( diff --git a/chrome/common/resource_dispatcher.h b/chrome/common/resource_dispatcher.h index 53fc665..1374577 100644 --- a/chrome/common/resource_dispatcher.h +++ b/chrome/common/resource_dispatcher.h @@ -39,19 +39,19 @@ class ResourceDispatcher { const GURL& url, const GURL& policy_url, const GURL& referrer, + const std::string& frame_origin, + const std::string& main_frame_origin, const std::string& headers, int load_flags, int origin_pid, ResourceType::Type resource_type, - bool mixed_content, uint32 request_context /* used for plugin->browser requests */, int route_id); // Adds a request from the pending_requests_ list, returning the new // requests' ID int AddPendingRequest(webkit_glue::ResourceLoaderBridge::Peer* callback, - ResourceType::Type resource_type, - bool mixed_content); + ResourceType::Type resource_type); // Removes a request from the pending_requests_ list, returning true if the // request was found and removed. @@ -71,12 +71,10 @@ class ResourceDispatcher { struct PendingRequestInfo { PendingRequestInfo() { } PendingRequestInfo(webkit_glue::ResourceLoaderBridge::Peer* peer, - ResourceType::Type resource_type, - bool mixed_content) + ResourceType::Type resource_type) : peer(peer), resource_type(resource_type), filter_policy(FilterPolicy::DONT_FILTER), - mixed_content(mixed_content), is_deferred(false) { } ~PendingRequestInfo() { } @@ -84,7 +82,6 @@ class ResourceDispatcher { ResourceType::Type resource_type; FilterPolicy::Type filter_policy; MessageQueue deferred_message_queue; - bool mixed_content; bool is_deferred; }; typedef base::hash_map<int, PendingRequestInfo> PendingRequestList; diff --git a/chrome/common/resource_dispatcher_unittest.cc b/chrome/common/resource_dispatcher_unittest.cc index b473893..c830bde 100644 --- a/chrome/common/resource_dispatcher_unittest.cc +++ b/chrome/common/resource_dispatcher_unittest.cc @@ -155,8 +155,8 @@ TEST_F(ResourceDispatcherTest, RoundTrip) { TestRequestCallback callback; ResourceLoaderBridge* bridge = dispatcher_->CreateBridge("GET", GURL(test_page_url), GURL(test_page_url), - GURL(), std::string(), 0, 0, - ResourceType::SUB_RESOURCE, false, 0, + GURL(), "null", "null", std::string(), 0, 0, + ResourceType::SUB_RESOURCE, 0, MSG_ROUTING_CONTROL); bridge->Start(&callback); diff --git a/chrome/plugin/chrome_plugin_host.cc b/chrome/plugin/chrome_plugin_host.cc index 0401987..8ac50f2 100644 --- a/chrome/plugin/chrome_plugin_host.cc +++ b/chrome/plugin/chrome_plugin_host.cc @@ -144,11 +144,12 @@ class PluginRequestHandlerProxy GURL(cprequest_->url), GURL(cprequest_->url), // TODO(jackson): policy url? GURL(), // TODO(mpcomplete): referrer? + "null", // frame_origin + "null", // main_frame_origin extra_headers_, load_flags_, GetCurrentProcessId(), ResourceType::OBJECT, - false, // TODO (jcampan): mixed-content? cprequest_->context, MSG_ROUTING_CONTROL)); if (!bridge_.get()) diff --git a/chrome/renderer/media/data_source_impl.cc b/chrome/renderer/media/data_source_impl.cc index 9993352..e084413 100644 --- a/chrome/renderer/media/data_source_impl.cc +++ b/chrome/renderer/media/data_source_impl.cc @@ -216,13 +216,14 @@ void DataSourceImpl::OnInitialize(std::string uri) { GURL(uri), GURL(uri), GURL(), // TODO(hclam): provide referer here. + "null", // TODO(abarth): provide frame_origin + "null", // TODO(abarth): provide main_frame_origin std::string(), // Provide no header. // Prefer to load from cache, also enable downloading the file, the // resource will be saved to a single response data file if it's possible. net::LOAD_PREFERRING_CACHE | net::LOAD_ENABLE_DOWNLOAD_FILE, base::GetCurrentProcId(), ResourceType::MEDIA, - false, 0, delegate_->view()->routing_id()); // Start the resource loading. diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index f741ffd..6ed28a0 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -233,16 +233,18 @@ ResourceLoaderBridge* ResourceLoaderBridge::Create( const GURL& url, const GURL& policy_url, const GURL& referrer, + const std::string& frame_origin, + const std::string& main_frame_origin, const std::string& headers, int load_flags, int origin_pid, ResourceType::Type resource_type, - bool mixed_content, int routing_id) { ResourceDispatcher* dispatch = RenderThread::current()->resource_dispatcher(); - return dispatch->CreateBridge(method, url, policy_url, referrer, headers, + return dispatch->CreateBridge(method, url, policy_url, referrer, + frame_origin, main_frame_origin, headers, load_flags, origin_pid, resource_type, - mixed_content, 0, routing_id); + 0, routing_id); } void NotifyCacheStats() { diff --git a/webkit/glue/resource_handle_impl.cc b/webkit/glue/resource_handle_impl.cc index be5704c..99290d3 100644 --- a/webkit/glue/resource_handle_impl.cc +++ b/webkit/glue/resource_handle_impl.cc @@ -387,10 +387,6 @@ bool ResourceHandleInternal::Start( if (requestor_pid == 0) requestor_pid = base::GetCurrentProcId(); - bool mixed_content = - webkit_glue::KURLToGURL(request_.mainDocumentURL()).SchemeIsSecure() && - !url.SchemeIsSecure(); - if (url.SchemeIs("data")) { if (sync_load_response) { // This is a sync load. Do the work now. @@ -410,6 +406,13 @@ bool ResourceHandleInternal::Start( return true; } + // TODO(abarth): These are wrong! I need to figure out how to get the right + // strings here. See: http://crbug.com/8706 + std::string frame_origin = + webkit_glue::StringToStdString(request_.mainDocumentURL().string()); + std::string main_frame_origin = + webkit_glue::StringToStdString(request_.mainDocumentURL().string()); + // TODO(darin): is latin1 really correct here? It is if the strings are // already ASCII (i.e., if they are already escaped properly). // TODO(brettw) this should take parameter encoding into account when @@ -419,11 +422,12 @@ bool ResourceHandleInternal::Start( url, webkit_glue::KURLToGURL(request_.policyURL()), referrer, + frame_origin, + main_frame_origin, webkit_glue::CStringToStdString(headerBuf.latin1()), load_flags_, requestor_pid, FromTargetType(request_.targetType()), - mixed_content, request_.requestorID())); if (!bridge_.get()) return false; diff --git a/webkit/glue/resource_loader_bridge.h b/webkit/glue/resource_loader_bridge.h index 2061a3b..161c237 100644 --- a/webkit/glue/resource_loader_bridge.h +++ b/webkit/glue/resource_loader_bridge.h @@ -17,10 +17,10 @@ #ifndef RESOURCE_LOADER_BRIDGE_H_ #define RESOURCE_LOADER_BRIDGE_H_ -#include "build/build_config.h"
-#if defined(OS_POSIX)
-#include "base/file_descriptor_posix.h"
-#endif
+#include "build/build_config.h" +#if defined(OS_POSIX) +#include "base/file_descriptor_posix.h" +#endif #include "base/platform_file.h" #include "base/ref_counted.h" #include "base/time.h" @@ -67,18 +67,18 @@ class ResourceLoaderBridge { // Content length if available. -1 if not available int64 content_length; - // A platform specific handle for a file that carries response data. This
- // entry is used if the resource request is of type ResourceType::MEDIA and
- // the underlying cache layer keeps the response data in a standalone file.
-#if defined(OS_POSIX)
- // If the response data file is available, the file handle is stored in
- // response_data_file.fd, its value is base::kInvalidPlatformFileValue
- // otherwise.
- base::FileDescriptor response_data_file;
-#elif defined(OS_WIN)
- // An asynchronous file handle to the response data file, its value is
- // base::kInvalidPlatformFileValue if the file is not available.
- base::PlatformFile response_data_file;
+ // A platform specific handle for a file that carries response data. This + // entry is used if the resource request is of type ResourceType::MEDIA and + // the underlying cache layer keeps the response data in a standalone file. +#if defined(OS_POSIX) + // If the response data file is available, the file handle is stored in + // response_data_file.fd, its value is base::kInvalidPlatformFileValue + // otherwise. + base::FileDescriptor response_data_file; +#elif defined(OS_WIN) + // An asynchronous file handle to the response data file, its value is + // base::kInvalidPlatformFileValue if the file is not available. + base::PlatformFile response_data_file; #endif }; @@ -168,9 +168,6 @@ class ResourceLoaderBridge { // // load_flags is composed of the values defined in url_request_load_flags.h // - // mixed_content when true indicates that the resource associated with this - // request is over HTTP when the main page was loaded over HTTPS. - // // request_type indicates if the current request is the main frame load, a // sub-frame load, or a sub objects load. // @@ -180,11 +177,12 @@ class ResourceLoaderBridge { const GURL& url, const GURL& policy_url, const GURL& referrer, + const std::string& frame_origin, + const std::string& main_frame_origin, const std::string& headers, int load_flags, int requestor_pid, ResourceType::Type request_type, - bool mixed_content, int routing_id); // Call this method before calling Start() to append a chunk of binary data diff --git a/webkit/glue/unittest_test_server.h b/webkit/glue/unittest_test_server.h index 9476ab5..32d9646 100644 --- a/webkit/glue/unittest_test_server.h +++ b/webkit/glue/unittest_test_server.h @@ -43,10 +43,11 @@ class UnittestTestServer : public HTTPTestServer { url, // policy_url GURL(), // no referrer std::string(), // no extra headers + "null", // frame_origin + "null", // main_frame_origin net::LOAD_NORMAL, 0, ResourceType::SUB_RESOURCE, - false, 0)); EXPECT_TRUE(loader.get()); diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.cc b/webkit/tools/test_shell/simple_resource_loader_bridge.cc index 0763246..657e97b 100644 --- a/webkit/tools/test_shell/simple_resource_loader_bridge.cc +++ b/webkit/tools/test_shell/simple_resource_loader_bridge.cc @@ -548,11 +548,12 @@ ResourceLoaderBridge* ResourceLoaderBridge::Create( const GURL& url, const GURL& policy_url, const GURL& referrer, + const std::string& frame_origin, + const std::string& main_frame_origin, const std::string& headers, int load_flags, int requestor_pid, ResourceType::Type request_type, - bool mixed_contents, int routing_id) { return new ResourceLoaderBridgeImpl(method, url, policy_url, referrer, headers, load_flags); |