| 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 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1213 blink::WebDataSource* datasource) { | 1215 blink::WebDataSource* datasource) { |
| 1214 DCHECK(!frame_ || frame_ == frame); | 1216 DCHECK(!frame_ || frame_ == frame); |
| 1215 | 1217 |
| 1216 // TODO(nasko): Move implementation here. Needed state: | 1218 // TODO(nasko): Move implementation here. Needed state: |
| 1217 // * pending_navigation_params_ | 1219 // * pending_navigation_params_ |
| 1218 // * webview | 1220 // * webview |
| 1219 // Needed methods: | 1221 // Needed methods: |
| 1220 // * PopulateDocumentStateFromPending | 1222 // * PopulateDocumentStateFromPending |
| 1221 // * CreateNavigationStateFromPending | 1223 // * CreateNavigationStateFromPending |
| 1222 render_view_->didCreateDataSource(frame, datasource); | 1224 render_view_->didCreateDataSource(frame, datasource); |
| 1225 |
| 1226 // Create the serviceworker's per-document network observing object. |
| 1227 scoped_ptr<ServiceWorkerNetworkProvider> |
| 1228 network_provider(new ServiceWorkerNetworkProvider()); |
| 1229 ServiceWorkerNetworkProvider::AttachToDocumentState( |
| 1230 DocumentState::FromDataSource(datasource), |
| 1231 network_provider.Pass()); |
| 1223 } | 1232 } |
| 1224 | 1233 |
| 1225 void RenderFrameImpl::didStartProvisionalLoad(blink::WebFrame* frame) { | 1234 void RenderFrameImpl::didStartProvisionalLoad(blink::WebFrame* frame) { |
| 1226 DCHECK(!frame_ || frame_ == frame); | 1235 DCHECK(!frame_ || frame_ == frame); |
| 1227 WebDataSource* ds = frame->provisionalDataSource(); | 1236 WebDataSource* ds = frame->provisionalDataSource(); |
| 1228 | 1237 |
| 1229 // In fast/loader/stop-provisional-loads.html, we abort the load before this | 1238 // In fast/loader/stop-provisional-loads.html, we abort the load before this |
| 1230 // callback is invoked. | 1239 // callback is invoked. |
| 1231 if (!ds) | 1240 if (!ds) |
| 1232 return; | 1241 return; |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1769 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); | 1778 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); |
| 1770 } else { | 1779 } else { |
| 1771 // If the navigation is browser-initiated, the NavigationState contains the | 1780 // If the navigation is browser-initiated, the NavigationState contains the |
| 1772 // correct value instead of the WebDataSource. | 1781 // correct value instead of the WebDataSource. |
| 1773 // | 1782 // |
| 1774 // TODO(davidben): Avoid this awkward duplication of state. See comment on | 1783 // TODO(davidben): Avoid this awkward duplication of state. See comment on |
| 1775 // NavigationState::should_replace_current_entry(). | 1784 // NavigationState::should_replace_current_entry(). |
| 1776 should_replace_current_entry = | 1785 should_replace_current_entry = |
| 1777 navigation_state->should_replace_current_entry(); | 1786 navigation_state->should_replace_current_entry(); |
| 1778 } | 1787 } |
| 1788 |
| 1789 int provider_id = kInvalidServiceWorkerProviderId; |
| 1790 if (request.targetType() == blink::WebURLRequest::TargetIsMainFrame || |
| 1791 request.targetType() == blink::WebURLRequest::TargetIsSubframe) { |
| 1792 // |provisionalDataSource| may be null in some content::ResourceFetcher |
| 1793 // use cases, we don't hook those requests. |
| 1794 if (frame->provisionalDataSource()) { |
| 1795 ServiceWorkerNetworkProvider* provider = |
| 1796 ServiceWorkerNetworkProvider::FromDocumentState( |
| 1797 DocumentState::FromDataSource(frame->provisionalDataSource())); |
| 1798 provider_id = provider->provider_id(); |
| 1799 } |
| 1800 } else if (frame->dataSource()) { |
| 1801 ServiceWorkerNetworkProvider* provider = |
| 1802 ServiceWorkerNetworkProvider::FromDocumentState( |
| 1803 DocumentState::FromDataSource(frame->dataSource())); |
| 1804 provider_id = provider->provider_id(); |
| 1805 } |
| 1806 |
| 1779 int parent_routing_id = frame->parent() ? | 1807 int parent_routing_id = frame->parent() ? |
| 1780 FromWebFrame(frame->parent())->GetRoutingID() : -1; | 1808 FromWebFrame(frame->parent())->GetRoutingID() : -1; |
| 1781 request.setExtraData( | 1809 request.setExtraData( |
| 1782 new RequestExtraData(render_view_->visibilityState(), | 1810 new RequestExtraData(render_view_->visibilityState(), |
| 1783 custom_user_agent, | 1811 custom_user_agent, |
| 1784 was_after_preconnect_request, | 1812 was_after_preconnect_request, |
| 1785 routing_id_, | 1813 routing_id_, |
| 1786 (frame == top_frame), | 1814 (frame == top_frame), |
| 1787 GURL(frame->document().securityOrigin().toString()), | 1815 GURL(frame->document().securityOrigin().toString()), |
| 1788 frame->parent() == top_frame, | 1816 frame->parent() == top_frame, |
| 1789 parent_routing_id, | 1817 parent_routing_id, |
| 1790 navigation_state->allow_download(), | 1818 navigation_state->allow_download(), |
| 1791 transition_type, | 1819 transition_type, |
| 1792 should_replace_current_entry, | 1820 should_replace_current_entry, |
| 1793 navigation_state->transferred_request_child_id(), | 1821 navigation_state->transferred_request_child_id(), |
| 1794 navigation_state->transferred_request_request_id())); | 1822 navigation_state->transferred_request_request_id(), |
| 1823 provider_id)); |
| 1795 | 1824 |
| 1796 DocumentState* top_document_state = | 1825 DocumentState* top_document_state = |
| 1797 DocumentState::FromDataSource(top_data_source); | 1826 DocumentState::FromDataSource(top_data_source); |
| 1798 if (top_document_state) { | 1827 if (top_document_state) { |
| 1799 // TODO(gavinp): separate out prefetching and prerender field trials | 1828 // TODO(gavinp): separate out prefetching and prerender field trials |
| 1800 // if the rel=prerender rel type is sticking around. | 1829 // if the rel=prerender rel type is sticking around. |
| 1801 if (request.targetType() == WebURLRequest::TargetIsPrefetch) | 1830 if (request.targetType() == WebURLRequest::TargetIsPrefetch) |
| 1802 top_document_state->set_was_prefetcher(true); | 1831 top_document_state->set_was_prefetcher(true); |
| 1803 | 1832 |
| 1804 if (was_after_preconnect_request) | 1833 if (was_after_preconnect_request) |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2576 policy == blink::WebNavigationPolicyNewForegroundTab || | 2605 policy == blink::WebNavigationPolicyNewForegroundTab || |
| 2577 policy == blink::WebNavigationPolicyNewWindow || | 2606 policy == blink::WebNavigationPolicyNewWindow || |
| 2578 policy == blink::WebNavigationPolicyNewPopup) { | 2607 policy == blink::WebNavigationPolicyNewPopup) { |
| 2579 WebUserGestureIndicator::consumeUserGesture(); | 2608 WebUserGestureIndicator::consumeUserGesture(); |
| 2580 } | 2609 } |
| 2581 | 2610 |
| 2582 Send(new FrameHostMsg_OpenURL(routing_id_, params)); | 2611 Send(new FrameHostMsg_OpenURL(routing_id_, params)); |
| 2583 } | 2612 } |
| 2584 | 2613 |
| 2585 } // namespace content | 2614 } // namespace content |
| OLD | NEW |