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/child/web_socket_stream_handle_impl.h" | 25 #include "content/child/web_socket_stream_handle_impl.h" |
25 #include "content/common/frame_messages.h" | 26 #include "content/common/frame_messages.h" |
27 #include "content/common/service_worker/service_worker_types.h" | |
26 #include "content/common/socket_stream_handle_data.h" | 28 #include "content/common/socket_stream_handle_data.h" |
27 #include "content/common/swapped_out_messages.h" | 29 #include "content/common/swapped_out_messages.h" |
28 #include "content/common/view_messages.h" | 30 #include "content/common/view_messages.h" |
29 #include "content/public/common/bindings_policy.h" | 31 #include "content/public/common/bindings_policy.h" |
30 #include "content/public/common/content_constants.h" | 32 #include "content/public/common/content_constants.h" |
31 #include "content/public/common/content_switches.h" | 33 #include "content/public/common/content_switches.h" |
32 #include "content/public/common/context_menu_params.h" | 34 #include "content/public/common/context_menu_params.h" |
33 #include "content/public/common/url_constants.h" | 35 #include "content/public/common/url_constants.h" |
34 #include "content/public/common/url_utils.h" | 36 #include "content/public/common/url_utils.h" |
35 #include "content/public/renderer/content_renderer_client.h" | 37 #include "content/public/renderer/content_renderer_client.h" |
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1172 blink::WebDataSource* datasource) { | 1174 blink::WebDataSource* datasource) { |
1173 DCHECK(!frame_ || frame_ == frame); | 1175 DCHECK(!frame_ || frame_ == frame); |
1174 | 1176 |
1175 // TODO(nasko): Move implementation here. Needed state: | 1177 // TODO(nasko): Move implementation here. Needed state: |
1176 // * pending_navigation_params_ | 1178 // * pending_navigation_params_ |
1177 // * webview | 1179 // * webview |
1178 // Needed methods: | 1180 // Needed methods: |
1179 // * PopulateDocumentStateFromPending | 1181 // * PopulateDocumentStateFromPending |
1180 // * CreateNavigationStateFromPending | 1182 // * CreateNavigationStateFromPending |
1181 render_view_->didCreateDataSource(frame, datasource); | 1183 render_view_->didCreateDataSource(frame, datasource); |
1184 | |
1185 // Create the serviceworker's per-document network observing object. | |
1186 scoped_ptr<ServiceWorkerNetworkProvider> | |
1187 network_provider(new ServiceWorkerNetworkProvider()); | |
1188 ServiceWorkerNetworkProvider::AttachToDocumentState( | |
1189 DocumentState::FromDataSource(datasource), | |
1190 network_provider.Pass()); | |
1182 } | 1191 } |
1183 | 1192 |
1184 void RenderFrameImpl::didStartProvisionalLoad(blink::WebFrame* frame) { | 1193 void RenderFrameImpl::didStartProvisionalLoad(blink::WebFrame* frame) { |
1185 DCHECK(!frame_ || frame_ == frame); | 1194 DCHECK(!frame_ || frame_ == frame); |
1186 WebDataSource* ds = frame->provisionalDataSource(); | 1195 WebDataSource* ds = frame->provisionalDataSource(); |
1187 | 1196 |
1188 // In fast/loader/stop-provisional-loads.html, we abort the load before this | 1197 // In fast/loader/stop-provisional-loads.html, we abort the load before this |
1189 // callback is invoked. | 1198 // callback is invoked. |
1190 if (!ds) | 1199 if (!ds) |
1191 return; | 1200 return; |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1728 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); | 1737 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); |
1729 } else { | 1738 } else { |
1730 // If the navigation is browser-initiated, the NavigationState contains the | 1739 // If the navigation is browser-initiated, the NavigationState contains the |
1731 // correct value instead of the WebDataSource. | 1740 // correct value instead of the WebDataSource. |
1732 // | 1741 // |
1733 // TODO(davidben): Avoid this awkward duplication of state. See comment on | 1742 // TODO(davidben): Avoid this awkward duplication of state. See comment on |
1734 // NavigationState::should_replace_current_entry(). | 1743 // NavigationState::should_replace_current_entry(). |
1735 should_replace_current_entry = | 1744 should_replace_current_entry = |
1736 navigation_state->should_replace_current_entry(); | 1745 navigation_state->should_replace_current_entry(); |
1737 } | 1746 } |
1747 | |
1748 // TODO(michaeln): Add WebDataSource* as a param to willSendRequest so | |
1749 // this ambiguity about which datasource can be removed. | |
michaeln
2014/03/04 04:27:49
i don't plan on leaving this comment here
| |
1750 int provider_id = kInvalidServiceWorkerProviderId; | |
1751 if (request.targetType() == blink::WebURLRequest::TargetIsMainFrame || | |
1752 request.targetType() == blink::WebURLRequest::TargetIsSubframe) { | |
1753 if (frame->provisionalDataSource()) { // May be null is some tests. | |
michaeln
2014/03/04 04:27:49
i'll remove the 'tests' comment since this can app
kinuko
2014/03/04 12:53:08
When you remove the comment can you add a brief co
| |
1754 ServiceWorkerNetworkProvider* provider = | |
1755 ServiceWorkerNetworkProvider::FromDocumentState( | |
1756 DocumentState::FromDataSource(frame->provisionalDataSource())); | |
1757 provider_id = provider->provider_id(); | |
1758 } | |
1759 } else if (frame->dataSource()) { | |
1760 ServiceWorkerNetworkProvider* provider = | |
1761 ServiceWorkerNetworkProvider::FromDocumentState( | |
1762 DocumentState::FromDataSource(frame->dataSource())); | |
1763 provider_id = provider->provider_id(); | |
1764 } | |
1765 | |
1738 int parent_routing_id = frame->parent() ? | 1766 int parent_routing_id = frame->parent() ? |
1739 FromWebFrame(frame->parent())->GetRoutingID() : -1; | 1767 FromWebFrame(frame->parent())->GetRoutingID() : -1; |
1740 request.setExtraData( | 1768 request.setExtraData( |
1741 new RequestExtraData(render_view_->visibilityState(), | 1769 new RequestExtraData(render_view_->visibilityState(), |
1742 custom_user_agent, | 1770 custom_user_agent, |
1743 was_after_preconnect_request, | 1771 was_after_preconnect_request, |
1744 routing_id_, | 1772 routing_id_, |
1745 (frame == top_frame), | 1773 (frame == top_frame), |
1746 GURL(frame->document().securityOrigin().toString()), | 1774 GURL(frame->document().securityOrigin().toString()), |
1747 frame->parent() == top_frame, | 1775 frame->parent() == top_frame, |
1748 parent_routing_id, | 1776 parent_routing_id, |
1749 navigation_state->allow_download(), | 1777 navigation_state->allow_download(), |
1750 transition_type, | 1778 transition_type, |
1751 should_replace_current_entry, | 1779 should_replace_current_entry, |
1752 navigation_state->transferred_request_child_id(), | 1780 navigation_state->transferred_request_child_id(), |
1753 navigation_state->transferred_request_request_id())); | 1781 navigation_state->transferred_request_request_id(), |
1782 provider_id)); | |
1754 | 1783 |
1755 DocumentState* top_document_state = | 1784 DocumentState* top_document_state = |
1756 DocumentState::FromDataSource(top_data_source); | 1785 DocumentState::FromDataSource(top_data_source); |
1757 if (top_document_state) { | 1786 if (top_document_state) { |
1758 // TODO(gavinp): separate out prefetching and prerender field trials | 1787 // TODO(gavinp): separate out prefetching and prerender field trials |
1759 // if the rel=prerender rel type is sticking around. | 1788 // if the rel=prerender rel type is sticking around. |
1760 if (request.targetType() == WebURLRequest::TargetIsPrefetch) | 1789 if (request.targetType() == WebURLRequest::TargetIsPrefetch) |
1761 top_document_state->set_was_prefetcher(true); | 1790 top_document_state->set_was_prefetcher(true); |
1762 | 1791 |
1763 if (was_after_preconnect_request) | 1792 if (was_after_preconnect_request) |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2274 | 2303 |
2275 void RenderFrameImpl::didStartLoading() { | 2304 void RenderFrameImpl::didStartLoading() { |
2276 Send(new FrameHostMsg_DidStartLoading(routing_id_)); | 2305 Send(new FrameHostMsg_DidStartLoading(routing_id_)); |
2277 } | 2306 } |
2278 | 2307 |
2279 void RenderFrameImpl::didStopLoading() { | 2308 void RenderFrameImpl::didStopLoading() { |
2280 Send(new FrameHostMsg_DidStopLoading(routing_id_)); | 2309 Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
2281 } | 2310 } |
2282 | 2311 |
2283 } // namespace content | 2312 } // namespace content |
OLD | NEW |