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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // are likely to be third party content. | 112 // are likely to be third party content. |
113 if (request.url().host() == document.getSecurityOrigin()->domain()) | 113 if (request.url().host() == document.getSecurityOrigin()->domain()) |
114 return false; | 114 return false; |
115 | 115 |
116 emitWarningForDocWriteScripts(request.url().getString(), document); | 116 emitWarningForDocWriteScripts(request.url().getString(), document); |
117 | 117 |
118 // Do not block scripts if it is a page reload. This is to enable pages to | 118 // Do not block scripts if it is a page reload. This is to enable pages to |
119 // recover if blocking of a script is leading to a page break and the user | 119 // recover if blocking of a script is leading to a page break and the user |
120 // reloads the page. | 120 // reloads the page. |
121 const FrameLoadType loadType = document.frame()->loader().loadType(); | 121 const FrameLoadType loadType = document.frame()->loader().loadType(); |
122 const bool isReload = loadType == FrameLoadTypeReload || loadType == FrameLo
adTypeReloadBypassingCache || loadType == FrameLoadTypeReloadMainResource; | 122 if (isReloadLoadType(loadType)) { |
123 if (isReload) { | |
124 // Recording this metric since an increase in number of reloads for page
s | 123 // Recording this metric since an increase in number of reloads for page
s |
125 // where a script was blocked could be indicative of a page break. | 124 // where a script was blocked could be indicative of a page break. |
126 document.loader()->didObserveLoadingBehavior(WebLoadingBehaviorFlag::Web
LoadingBehaviorDocumentWriteBlockReload); | 125 document.loader()->didObserveLoadingBehavior(WebLoadingBehaviorFlag::Web
LoadingBehaviorDocumentWriteBlockReload); |
127 return false; | 126 return false; |
128 } | 127 } |
129 | 128 |
130 // Add the metadata that this page has scripts inserted via document.write | 129 // Add the metadata that this page has scripts inserted via document.write |
131 // that are eligible for blocking. Note that if there are multiple scripts | 130 // that are eligible for blocking. Note that if there are multiple scripts |
132 // the flag will be conveyed to the browser process only once. | 131 // the flag will be conveyed to the browser process only once. |
133 document.loader()->didObserveLoadingBehavior(WebLoadingBehaviorFlag::WebLoad
ingBehaviorDocumentWriteBlock); | 132 document.loader()->didObserveLoadingBehavior(WebLoadingBehaviorFlag::WebLoad
ingBehaviorDocumentWriteBlock); |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 } | 819 } |
821 | 820 |
822 DEFINE_TRACE(FrameFetchContext) | 821 DEFINE_TRACE(FrameFetchContext) |
823 { | 822 { |
824 visitor->trace(m_document); | 823 visitor->trace(m_document); |
825 visitor->trace(m_documentLoader); | 824 visitor->trace(m_documentLoader); |
826 FetchContext::trace(visitor); | 825 FetchContext::trace(visitor); |
827 } | 826 } |
828 | 827 |
829 } // namespace blink | 828 } // namespace blink |
OLD | NEW |