| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // Avoid blocking same origin scripts, as they may be used to render main | 97 // Avoid blocking same origin scripts, as they may be used to render main |
| 98 // page content, whereas cross-origin scripts inserted via document.write | 98 // page content, whereas cross-origin scripts inserted via document.write |
| 99 // are likely to be third party content. | 99 // are likely to be third party content. |
| 100 if (request.url().host() == document.getSecurityOrigin()->domain()) | 100 if (request.url().host() == document.getSecurityOrigin()->domain()) |
| 101 return false; | 101 return false; |
| 102 | 102 |
| 103 // Do not block scripts if it is a page reload. This is to enable pages to | 103 // Do not block scripts if it is a page reload. This is to enable pages to |
| 104 // recover if blocking of a script is leading to a page break and the user | 104 // recover if blocking of a script is leading to a page break and the user |
| 105 // reloads the page. | 105 // reloads the page. |
| 106 const FrameLoadType loadType = document.frame()->loader().loadType(); | 106 const FrameLoadType loadType = document.frame()->loader().loadType(); |
| 107 const bool isReload = loadType == FrameLoadTypeReload || loadType == FrameLo
adTypeReloadBypassingCache || loadType == FrameLoadTypeSame; | 107 const bool isReload = loadType == FrameLoadTypeReload || loadType == FrameLo
adTypeReloadBypassingCache || loadType == FrameLoadTypeReloadMainResource; |
| 108 if (isReload) { | 108 if (isReload) { |
| 109 // Recording this metric since an increase in number of reloads for page
s | 109 // Recording this metric since an increase in number of reloads for page
s |
| 110 // where a script was blocked could be indicative of a page break. | 110 // where a script was blocked could be indicative of a page break. |
| 111 document.loader()->didObserveLoadingBehavior(WebLoadingBehaviorFlag::Web
LoadingBehaviorDocumentWriteBlockReload); | 111 document.loader()->didObserveLoadingBehavior(WebLoadingBehaviorFlag::Web
LoadingBehaviorDocumentWriteBlockReload); |
| 112 return false; | 112 return false; |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Add the metadata that this page has scripts inserted via document.write | 115 // Add the metadata that this page has scripts inserted via document.write |
| 116 // that are eligible for blocking. Note that if there are multiple scripts | 116 // that are eligible for blocking. Note that if there are multiple scripts |
| 117 // the flag will be conveyed to the browser process only once. | 117 // the flag will be conveyed to the browser process only once. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 228 |
| 229 WebCachePolicy FrameFetchContext::resourceRequestCachePolicy(const ResourceReque
st& request, Resource::Type type, FetchRequest::DeferOption defer) const | 229 WebCachePolicy FrameFetchContext::resourceRequestCachePolicy(const ResourceReque
st& request, Resource::Type type, FetchRequest::DeferOption defer) const |
| 230 { | 230 { |
| 231 ASSERT(frame()); | 231 ASSERT(frame()); |
| 232 if (type == Resource::MainResource) { | 232 if (type == Resource::MainResource) { |
| 233 FrameLoadType frameLoadType = frame()->loader().loadType(); | 233 FrameLoadType frameLoadType = frame()->loader().loadType(); |
| 234 if (request.httpMethod() == "POST" && frameLoadType == FrameLoadTypeBack
Forward) | 234 if (request.httpMethod() == "POST" && frameLoadType == FrameLoadTypeBack
Forward) |
| 235 return WebCachePolicy::ReturnCacheDataDontLoad; | 235 return WebCachePolicy::ReturnCacheDataDontLoad; |
| 236 if (!frame()->host()->overrideEncoding().isEmpty()) | 236 if (!frame()->host()->overrideEncoding().isEmpty()) |
| 237 return WebCachePolicy::ReturnCacheDataElseLoad; | 237 return WebCachePolicy::ReturnCacheDataElseLoad; |
| 238 if (frameLoadType == FrameLoadTypeSame || request.isConditional() || req
uest.httpMethod() == "POST") | 238 if (frameLoadType == FrameLoadTypeReloadMainResource || request.isCondit
ional() || request.httpMethod() == "POST") |
| 239 return WebCachePolicy::ValidatingCacheData; | 239 return WebCachePolicy::ValidatingCacheData; |
| 240 | 240 |
| 241 for (Frame* f = frame(); f; f = f->tree().parent()) { | 241 for (Frame* f = frame(); f; f = f->tree().parent()) { |
| 242 if (!f->isLocalFrame()) | 242 if (!f->isLocalFrame()) |
| 243 continue; | 243 continue; |
| 244 frameLoadType = toLocalFrame(f)->loader().loadType(); | 244 frameLoadType = toLocalFrame(f)->loader().loadType(); |
| 245 if (frameLoadType == FrameLoadTypeBackForward) | 245 if (frameLoadType == FrameLoadTypeBackForward) |
| 246 return WebCachePolicy::ReturnCacheDataElseLoad; | 246 return WebCachePolicy::ReturnCacheDataElseLoad; |
| 247 if (frameLoadType == FrameLoadTypeReloadBypassingCache) | 247 if (frameLoadType == FrameLoadTypeReloadBypassingCache) |
| 248 return WebCachePolicy::BypassingCache; | 248 return WebCachePolicy::BypassingCache; |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 } | 816 } |
| 817 | 817 |
| 818 DEFINE_TRACE(FrameFetchContext) | 818 DEFINE_TRACE(FrameFetchContext) |
| 819 { | 819 { |
| 820 visitor->trace(m_document); | 820 visitor->trace(m_document); |
| 821 visitor->trace(m_documentLoader); | 821 visitor->trace(m_documentLoader); |
| 822 FetchContext::trace(visitor); | 822 FetchContext::trace(visitor); |
| 823 } | 823 } |
| 824 | 824 |
| 825 } // namespace blink | 825 } // namespace blink |
| OLD | NEW |