| 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 20 matching lines...) Expand all Loading... |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "web/WebDataSourceImpl.h" | 32 #include "web/WebDataSourceImpl.h" |
| 33 | 33 |
| 34 #include "core/dom/Document.h" | 34 #include "core/dom/Document.h" |
| 35 #include "public/platform/WebURL.h" | 35 #include "public/platform/WebURL.h" |
| 36 #include "public/platform/WebURLError.h" | 36 #include "public/platform/WebURLError.h" |
| 37 #include "public/platform/WebVector.h" | 37 #include "public/platform/WebVector.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 static OwnPtrWillBePersistent<WebPluginLoadObserver>& nextPluginLoadObserver() | |
| 42 { | |
| 43 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WebPluginLoadObserver>, nextPlugi
nLoadObserver, ()); | |
| 44 return nextPluginLoadObserver; | |
| 45 } | |
| 46 | |
| 47 PassRefPtrWillBeRawPtr<WebDataSourceImpl> WebDataSourceImpl::create(LocalFrame*
frame, const ResourceRequest& request, const SubstituteData& data) | 41 PassRefPtrWillBeRawPtr<WebDataSourceImpl> WebDataSourceImpl::create(LocalFrame*
frame, const ResourceRequest& request, const SubstituteData& data) |
| 48 { | 42 { |
| 49 return adoptRefWillBeNoop(new WebDataSourceImpl(frame, request, data)); | 43 return adoptRefWillBeNoop(new WebDataSourceImpl(frame, request, data)); |
| 50 } | 44 } |
| 51 | 45 |
| 52 const WebURLRequest& WebDataSourceImpl::originalRequest() const | 46 const WebURLRequest& WebDataSourceImpl::originalRequest() const |
| 53 { | 47 { |
| 54 m_originalRequestWrapper.bind(DocumentLoader::originalRequest()); | 48 m_originalRequestWrapper.bind(DocumentLoader::originalRequest()); |
| 55 return m_originalRequestWrapper; | 49 return m_originalRequestWrapper; |
| 56 } | 50 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 case NavigationTypeReload: | 124 case NavigationTypeReload: |
| 131 return WebNavigationTypeReload; | 125 return WebNavigationTypeReload; |
| 132 case NavigationTypeFormResubmitted: | 126 case NavigationTypeFormResubmitted: |
| 133 return WebNavigationTypeFormResubmitted; | 127 return WebNavigationTypeFormResubmitted; |
| 134 case NavigationTypeOther: | 128 case NavigationTypeOther: |
| 135 default: | 129 default: |
| 136 return WebNavigationTypeOther; | 130 return WebNavigationTypeOther; |
| 137 } | 131 } |
| 138 } | 132 } |
| 139 | 133 |
| 140 void WebDataSourceImpl::setNextPluginLoadObserver(PassOwnPtrWillBeRawPtr<WebPlug
inLoadObserver> observer) | |
| 141 { | |
| 142 nextPluginLoadObserver() = observer; | |
| 143 } | |
| 144 | |
| 145 WebDataSourceImpl::WebDataSourceImpl(LocalFrame* frame, const ResourceRequest& r
equest, const SubstituteData& data) | 134 WebDataSourceImpl::WebDataSourceImpl(LocalFrame* frame, const ResourceRequest& r
equest, const SubstituteData& data) |
| 146 : DocumentLoader(frame, request, data) | 135 : DocumentLoader(frame, request, data) |
| 147 { | 136 { |
| 148 if (!nextPluginLoadObserver()) | |
| 149 return; | |
| 150 // When a new frame is created, it initially gets a data source for an | |
| 151 // empty document. Then it is navigated to the source URL of the | |
| 152 // frame, which results in a second data source being created. We want | |
| 153 // to wait to attach the WebPluginLoadObserver to that data source. | |
| 154 if (request.url().isEmpty()) | |
| 155 return; | |
| 156 | |
| 157 ASSERT(nextPluginLoadObserver()->url() == WebURL(request.url())); | |
| 158 m_pluginLoadObserver = nextPluginLoadObserver().release(); | |
| 159 } | 137 } |
| 160 | 138 |
| 161 WebDataSourceImpl::~WebDataSourceImpl() | 139 WebDataSourceImpl::~WebDataSourceImpl() |
| 162 { | 140 { |
| 163 // Verify that detachFromFrame() has been called. | 141 // Verify that detachFromFrame() has been called. |
| 164 ASSERT(!m_extraData); | 142 ASSERT(!m_extraData); |
| 165 } | 143 } |
| 166 | 144 |
| 167 void WebDataSourceImpl::detachFromFrame() | 145 void WebDataSourceImpl::detachFromFrame() |
| 168 { | 146 { |
| 169 RefPtrWillBeRawPtr<DocumentLoader> protect(this); | 147 RefPtrWillBeRawPtr<DocumentLoader> protect(this); |
| 170 | 148 |
| 171 DocumentLoader::detachFromFrame(); | 149 DocumentLoader::detachFromFrame(); |
| 172 m_extraData.clear(); | 150 m_extraData.clear(); |
| 173 m_pluginLoadObserver.clear(); | |
| 174 } | 151 } |
| 175 | 152 |
| 176 DEFINE_TRACE(WebDataSourceImpl) | 153 DEFINE_TRACE(WebDataSourceImpl) |
| 177 { | 154 { |
| 178 visitor->trace(m_pluginLoadObserver); | |
| 179 DocumentLoader::trace(visitor); | 155 DocumentLoader::trace(visitor); |
| 180 } | 156 } |
| 181 | 157 |
| 182 } // namespace blink | 158 } // namespace blink |
| OLD | NEW |