OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 15 matching lines...) Expand all Loading... | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "core/loader/appcache/ApplicationCacheHost.h" | 31 #include "core/loader/appcache/ApplicationCacheHost.h" |
32 | 32 |
33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
34 #include "core/events/ApplicationCacheErrorEvent.h" | 34 #include "core/events/ApplicationCacheErrorEvent.h" |
35 #include "core/events/ProgressEvent.h" | 35 #include "core/events/ProgressEvent.h" |
36 #include "core/frame/Deprecation.h" | |
36 #include "core/frame/LocalFrame.h" | 37 #include "core/frame/LocalFrame.h" |
38 #include "core/frame/OriginsUsingFeatures.h" | |
37 #include "core/frame/Settings.h" | 39 #include "core/frame/Settings.h" |
40 #include "core/frame/UseCounter.h" | |
38 #include "core/inspector/InspectorApplicationCacheAgent.h" | 41 #include "core/inspector/InspectorApplicationCacheAgent.h" |
39 #include "core/inspector/InspectorInstrumentation.h" | 42 #include "core/inspector/InspectorInstrumentation.h" |
40 #include "core/loader/DocumentLoader.h" | 43 #include "core/loader/DocumentLoader.h" |
41 #include "core/loader/FrameLoader.h" | 44 #include "core/loader/FrameLoader.h" |
42 #include "core/loader/FrameLoaderClient.h" | 45 #include "core/loader/FrameLoaderClient.h" |
43 #include "core/loader/appcache/ApplicationCache.h" | 46 #include "core/loader/appcache/ApplicationCache.h" |
44 #include "core/page/FrameTree.h" | 47 #include "core/page/FrameTree.h" |
45 #include "core/page/Page.h" | 48 #include "core/page/Page.h" |
46 #include "platform/exported/WrappedResourceRequest.h" | 49 #include "platform/exported/WrappedResourceRequest.h" |
47 #include "platform/exported/WrappedResourceResponse.h" | 50 #include "platform/exported/WrappedResourceResponse.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 // response in the SubstituteData out argument, instead we return the appcac hed response thru | 109 // response in the SubstituteData out argument, instead we return the appcac hed response thru |
107 // the usual resource loading pipeline. | 110 // the usual resource loading pipeline. |
108 } | 111 } |
109 | 112 |
110 void ApplicationCacheHost::selectCacheWithoutManifest() | 113 void ApplicationCacheHost::selectCacheWithoutManifest() |
111 { | 114 { |
112 if (m_host) | 115 if (m_host) |
113 m_host->selectCacheWithoutManifest(); | 116 m_host->selectCacheWithoutManifest(); |
114 } | 117 } |
115 | 118 |
116 void ApplicationCacheHost::selectCacheWithManifest(const KURL& manifestURL) | 119 void ApplicationCacheHost::selectCacheWithManifest(const KURL& manifestURL) |
michaeln
2016/02/23 22:26:34
fyi: This will miss counting/warning for documents
jww
2016/02/23 23:51:42
Great point. I'm not sure what the correct thing t
| |
117 { | 120 { |
121 DCHECK(m_documentLoader); | |
122 | |
123 LocalFrame* frame = m_documentLoader->frame(); | |
124 Document* document = frame->document(); | |
125 // This is required by isSecureContext() but isn't actually used. | |
126 String insecureOriginMessage; | |
127 if (document->isSecureContext(insecureOriginMessage)) { | |
Yoav Weiss
2016/02/23 22:09:54
Can't we use this variant of isSecureContext https
jww
2016/02/23 23:51:42
I didn't know about that variant; done.
| |
128 UseCounter::count(document, UseCounter::ApplicationCacheManifestSelectSe cureOrigin); | |
129 UseCounter::countCrossOriginIframe(*document, UseCounter::ApplicationCac heManifestSelectSecureOrigin); | |
130 } else { | |
131 Deprecation::countDeprecation(document, UseCounter::ApplicationCacheMani festSelectInsecureOrigin); | |
132 UseCounter::countCrossOriginIframe(*document, UseCounter::ApplicationCac heManifestSelectInsecureOrigin); | |
133 OriginsUsingFeatures::countAnyWorld(*document, OriginsUsingFeatures::Fea ture::ApplicationCacheManifestSelectInsecureOrigin); | |
134 } | |
118 if (m_host && !m_host->selectCacheWithManifest(manifestURL)) { | 135 if (m_host && !m_host->selectCacheWithManifest(manifestURL)) { |
119 // It's a foreign entry, restart the current navigation from the top | 136 // It's a foreign entry, restart the current navigation from the top |
120 // of the navigation algorithm. The navigation will not result in the | 137 // of the navigation algorithm. The navigation will not result in the |
121 // same resource being loaded, because "foreign" entries are never picke d | 138 // same resource being loaded, because "foreign" entries are never picke d |
122 // during navigation. | 139 // during navigation. |
123 // see ApplicationCacheGroup::selectCache() | 140 // see ApplicationCacheGroup::selectCache() |
124 LocalFrame* frame = m_documentLoader->frame(); | 141 frame->navigate(*document, document->url(), true, UserGestureStatus::Non e); |
125 frame->navigate(*frame->document(), frame->document()->url(), true, User GestureStatus::None); | |
126 } | 142 } |
127 } | 143 } |
128 | 144 |
129 void ApplicationCacheHost::didReceiveResponseForMainResource(const ResourceRespo nse& response) | 145 void ApplicationCacheHost::didReceiveResponseForMainResource(const ResourceRespo nse& response) |
130 { | 146 { |
131 if (m_host) { | 147 if (m_host) { |
132 WrappedResourceResponse wrapped(response); | 148 WrappedResourceResponse wrapped(response); |
133 m_host->didReceiveResponseForMainResource(wrapped); | 149 m_host->didReceiveResponseForMainResource(wrapped); |
134 } | 150 } |
135 } | 151 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
265 } | 281 } |
266 | 282 |
267 bool ApplicationCacheHost::isApplicationCacheEnabled() | 283 bool ApplicationCacheHost::isApplicationCacheEnabled() |
268 { | 284 { |
269 ASSERT(m_documentLoader->frame()); | 285 ASSERT(m_documentLoader->frame()); |
270 return m_documentLoader->frame()->settings() && m_documentLoader->frame()->s ettings()->offlineWebApplicationCacheEnabled(); | 286 return m_documentLoader->frame()->settings() && m_documentLoader->frame()->s ettings()->offlineWebApplicationCacheEnabled(); |
271 } | 287 } |
272 | 288 |
273 void ApplicationCacheHost::didChangeCacheAssociation() | 289 void ApplicationCacheHost::didChangeCacheAssociation() |
274 { | 290 { |
275 // FIXME: Prod the inspector to update its notion of what cache the page is using. | 291 // FIXME: Prod the inspector to update its notion of what cache the page is using. |
michaeln
2016/02/23 22:26:34
CacheInfo info = applicationCacheInfo();
I think
jww
2016/02/23 23:51:42
Let me know what you think about my comment above.
| |
276 } | 292 } |
277 | 293 |
278 void ApplicationCacheHost::notifyEventListener(WebApplicationCacheHost::EventID eventID) | 294 void ApplicationCacheHost::notifyEventListener(WebApplicationCacheHost::EventID eventID) |
279 { | 295 { |
280 notifyApplicationCache(static_cast<ApplicationCacheHost::EventID>(eventID), 0, 0, WebApplicationCacheHost::UnknownError, String(), 0, String()); | 296 notifyApplicationCache(static_cast<ApplicationCacheHost::EventID>(eventID), 0, 0, WebApplicationCacheHost::UnknownError, String(), 0, String()); |
281 } | 297 } |
282 | 298 |
283 void ApplicationCacheHost::notifyProgressEventListener(const WebURL&, int progre ssTotal, int progressDone) | 299 void ApplicationCacheHost::notifyProgressEventListener(const WebURL&, int progre ssTotal, int progressDone) |
284 { | 300 { |
285 notifyApplicationCache(PROGRESS_EVENT, progressTotal, progressDone, WebAppli cationCacheHost::UnknownError, String(), 0, String()); | 301 notifyApplicationCache(PROGRESS_EVENT, progressTotal, progressDone, WebAppli cationCacheHost::UnknownError, String(), 0, String()); |
286 } | 302 } |
287 | 303 |
288 void ApplicationCacheHost::notifyErrorEventListener(WebApplicationCacheHost::Err orReason reason, const WebURL& url, int status, const WebString& message) | 304 void ApplicationCacheHost::notifyErrorEventListener(WebApplicationCacheHost::Err orReason reason, const WebURL& url, int status, const WebString& message) |
289 { | 305 { |
290 notifyApplicationCache(ERROR_EVENT, 0, 0, reason, url.string(), status, mess age); | 306 notifyApplicationCache(ERROR_EVENT, 0, 0, reason, url.string(), status, mess age); |
291 } | 307 } |
292 | 308 |
293 DEFINE_TRACE(ApplicationCacheHost) | 309 DEFINE_TRACE(ApplicationCacheHost) |
294 { | 310 { |
295 visitor->trace(m_domApplicationCache); | 311 visitor->trace(m_domApplicationCache); |
296 visitor->trace(m_documentLoader); | 312 visitor->trace(m_documentLoader); |
297 } | 313 } |
298 | 314 |
299 } // namespace blink | 315 } // namespace blink |
OLD | NEW |