Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/debug/alias.h" | 11 #include "base/debug/alias.h" |
| 12 #include "base/debug/dump_without_crashing.h" | 12 #include "base/debug/dump_without_crashing.h" |
| 13 #include "base/i18n/char_iterator.h" | 13 #include "base/i18n/char_iterator.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/process/kill.h" | 15 #include "base/process/kill.h" |
| 16 #include "base/process/process.h" | 16 #include "base/process/process.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "content/child/appcache/appcache_dispatcher.h" | 19 #include "content/child/appcache/appcache_dispatcher.h" |
| 20 #include "content/child/plugin_messages.h" | 20 #include "content/child/plugin_messages.h" |
| 21 #include "content/child/quota_dispatcher.h" | 21 #include "content/child/quota_dispatcher.h" |
| 22 #include "content/child/request_extra_data.h" | 22 #include "content/child/request_extra_data.h" |
| 23 #include "content/child/service_worker/service_worker_network_provider.h" | |
| 23 #include "content/child/service_worker/web_service_worker_provider_impl.h" | 24 #include "content/child/service_worker/web_service_worker_provider_impl.h" |
| 24 #include "content/common/frame_messages.h" | 25 #include "content/common/frame_messages.h" |
| 26 #include "content/common/service_worker/service_worker_types.h" | |
| 25 #include "content/common/socket_stream_handle_data.h" | 27 #include "content/common/socket_stream_handle_data.h" |
| 26 #include "content/common/swapped_out_messages.h" | 28 #include "content/common/swapped_out_messages.h" |
| 27 #include "content/common/view_messages.h" | 29 #include "content/common/view_messages.h" |
| 28 #include "content/public/common/bindings_policy.h" | 30 #include "content/public/common/bindings_policy.h" |
| 29 #include "content/public/common/content_constants.h" | 31 #include "content/public/common/content_constants.h" |
| 30 #include "content/public/common/content_switches.h" | 32 #include "content/public/common/content_switches.h" |
| 31 #include "content/public/common/context_menu_params.h" | 33 #include "content/public/common/context_menu_params.h" |
| 32 #include "content/public/common/url_constants.h" | 34 #include "content/public/common/url_constants.h" |
| 33 #include "content/public/common/url_utils.h" | 35 #include "content/public/common/url_utils.h" |
| 34 #include "content/public/renderer/content_renderer_client.h" | 36 #include "content/public/renderer/content_renderer_client.h" |
| (...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1171 blink::WebDataSource* datasource) { | 1173 blink::WebDataSource* datasource) { |
| 1172 DCHECK(!frame_ || frame_ == frame); | 1174 DCHECK(!frame_ || frame_ == frame); |
| 1173 | 1175 |
| 1174 // TODO(nasko): Move implementation here. Needed state: | 1176 // TODO(nasko): Move implementation here. Needed state: |
| 1175 // * pending_navigation_params_ | 1177 // * pending_navigation_params_ |
| 1176 // * webview | 1178 // * webview |
| 1177 // Needed methods: | 1179 // Needed methods: |
| 1178 // * PopulateDocumentStateFromPending | 1180 // * PopulateDocumentStateFromPending |
| 1179 // * CreateNavigationStateFromPending | 1181 // * CreateNavigationStateFromPending |
| 1180 render_view_->didCreateDataSource(frame, datasource); | 1182 render_view_->didCreateDataSource(frame, datasource); |
| 1183 | |
| 1184 // Create the serviceworker's per-document network observing object. | |
| 1185 scoped_ptr<ServiceWorkerNetworkProvider> | |
| 1186 network_provider(new ServiceWorkerNetworkProvider()); | |
| 1187 ServiceWorkerNetworkProvider::AttachToDocumentState( | |
| 1188 DocumentState::FromDataSource(datasource), | |
| 1189 network_provider.Pass()); | |
| 1181 } | 1190 } |
| 1182 | 1191 |
| 1183 void RenderFrameImpl::didStartProvisionalLoad(blink::WebFrame* frame) { | 1192 void RenderFrameImpl::didStartProvisionalLoad(blink::WebFrame* frame) { |
| 1184 DCHECK(!frame_ || frame_ == frame); | 1193 DCHECK(!frame_ || frame_ == frame); |
| 1185 WebDataSource* ds = frame->provisionalDataSource(); | 1194 WebDataSource* ds = frame->provisionalDataSource(); |
| 1186 | 1195 |
| 1187 // In fast/loader/stop-provisional-loads.html, we abort the load before this | 1196 // In fast/loader/stop-provisional-loads.html, we abort the load before this |
| 1188 // callback is invoked. | 1197 // callback is invoked. |
| 1189 if (!ds) | 1198 if (!ds) |
| 1190 return; | 1199 return; |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1727 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); | 1736 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); |
| 1728 } else { | 1737 } else { |
| 1729 // If the navigation is browser-initiated, the NavigationState contains the | 1738 // If the navigation is browser-initiated, the NavigationState contains the |
| 1730 // correct value instead of the WebDataSource. | 1739 // correct value instead of the WebDataSource. |
| 1731 // | 1740 // |
| 1732 // TODO(davidben): Avoid this awkward duplication of state. See comment on | 1741 // TODO(davidben): Avoid this awkward duplication of state. See comment on |
| 1733 // NavigationState::should_replace_current_entry(). | 1742 // NavigationState::should_replace_current_entry(). |
| 1734 should_replace_current_entry = | 1743 should_replace_current_entry = |
| 1735 navigation_state->should_replace_current_entry(); | 1744 navigation_state->should_replace_current_entry(); |
| 1736 } | 1745 } |
| 1746 | |
| 1747 // TODO(michaeln): Add WebDataSource* as a param to willSendRequest so | |
| 1748 // this ambiguity about which datasource can be removed. | |
| 1749 int provider_id = kInvalidServiceWorkerProviderId; | |
| 1750 if (request.targetType() == blink::WebURLRequest::TargetIsMainFrame || | |
| 1751 request.targetType() == blink::WebURLRequest::TargetIsSubframe) { | |
| 1752 if (frame->provisionalDataSource()) { // May be null is some tests. | |
|
michaeln
2014/03/04 00:13:55
The ResourceFetcher tests all do this,
fetcher->
| |
| 1753 ServiceWorkerNetworkProvider* provider = | |
| 1754 ServiceWorkerNetworkProvider::FromDocumentState( | |
| 1755 DocumentState::FromDataSource(frame->provisionalDataSource())); | |
| 1756 provider_id = provider->provider_id(); | |
| 1757 } | |
| 1758 } else if (frame->dataSource()) { | |
| 1759 ServiceWorkerNetworkProvider* provider = | |
| 1760 ServiceWorkerNetworkProvider::FromDocumentState( | |
| 1761 DocumentState::FromDataSource(frame->dataSource())); | |
| 1762 provider_id = provider->provider_id(); | |
| 1763 } | |
| 1764 | |
| 1737 // TODO(creis): Remove the second routing ID from the request, now that we | 1765 // TODO(creis): Remove the second routing ID from the request, now that we |
| 1738 // use routing IDs instead of frame IDs. (This is a viral change, so I'm | 1766 // use routing IDs instead of frame IDs. (This is a viral change, so I'm |
| 1739 // splitting it into multiple CLs.) | 1767 // splitting it into multiple CLs.) |
| 1740 int parent_routing_id = frame->parent() ? | 1768 int parent_routing_id = frame->parent() ? |
| 1741 FromWebFrame(frame->parent())->GetRoutingID() : -1; | 1769 FromWebFrame(frame->parent())->GetRoutingID() : -1; |
| 1742 request.setExtraData( | 1770 request.setExtraData( |
| 1743 new RequestExtraData(render_view_->visibilityState(), | 1771 new RequestExtraData(render_view_->visibilityState(), |
| 1744 custom_user_agent, | 1772 custom_user_agent, |
| 1745 was_after_preconnect_request, | 1773 was_after_preconnect_request, |
| 1746 routing_id_, | 1774 routing_id_, |
| 1747 (frame == top_frame), | 1775 (frame == top_frame), |
| 1748 routing_id_, | 1776 routing_id_, |
| 1749 GURL(frame->document().securityOrigin().toString()), | 1777 GURL(frame->document().securityOrigin().toString()), |
| 1750 frame->parent() == top_frame, | 1778 frame->parent() == top_frame, |
| 1751 parent_routing_id, | 1779 parent_routing_id, |
| 1752 navigation_state->allow_download(), | 1780 navigation_state->allow_download(), |
| 1753 transition_type, | 1781 transition_type, |
| 1754 should_replace_current_entry, | 1782 should_replace_current_entry, |
| 1755 navigation_state->transferred_request_child_id(), | 1783 navigation_state->transferred_request_child_id(), |
| 1756 navigation_state->transferred_request_request_id())); | 1784 navigation_state->transferred_request_request_id(), |
| 1785 provider_id)); | |
| 1757 | 1786 |
| 1758 DocumentState* top_document_state = | 1787 DocumentState* top_document_state = |
| 1759 DocumentState::FromDataSource(top_data_source); | 1788 DocumentState::FromDataSource(top_data_source); |
| 1760 if (top_document_state) { | 1789 if (top_document_state) { |
| 1761 // TODO(gavinp): separate out prefetching and prerender field trials | 1790 // TODO(gavinp): separate out prefetching and prerender field trials |
| 1762 // if the rel=prerender rel type is sticking around. | 1791 // if the rel=prerender rel type is sticking around. |
| 1763 if (request.targetType() == WebURLRequest::TargetIsPrefetch) | 1792 if (request.targetType() == WebURLRequest::TargetIsPrefetch) |
| 1764 top_document_state->set_was_prefetcher(true); | 1793 top_document_state->set_was_prefetcher(true); |
| 1765 | 1794 |
| 1766 if (was_after_preconnect_request) | 1795 if (was_after_preconnect_request) |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2276 | 2305 |
| 2277 void RenderFrameImpl::didStartLoading() { | 2306 void RenderFrameImpl::didStartLoading() { |
| 2278 Send(new FrameHostMsg_DidStartLoading(routing_id_)); | 2307 Send(new FrameHostMsg_DidStartLoading(routing_id_)); |
| 2279 } | 2308 } |
| 2280 | 2309 |
| 2281 void RenderFrameImpl::didStopLoading() { | 2310 void RenderFrameImpl::didStopLoading() { |
| 2282 Send(new FrameHostMsg_DidStopLoading(routing_id_)); | 2311 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
| 2283 } | 2312 } |
| 2284 | 2313 |
| 2285 } // namespace content | 2314 } // namespace content |
| OLD | NEW |